devcoach 2.2.0-next.510.gb225f7e → 2.2.0-next.512.gc165fb2
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 +7 -5
- package/dist/{app-OQMXB6MX.js → app-56UHVZWZ.js} +1 -1
- package/dist/bin.js +1 -1
- package/dist/{chunk-IWLGZVJY.js → chunk-J35FEB7C.js} +1 -1
- package/dist/{chunk-J7DLMRUC.js → chunk-MHB2M5QZ.js} +1 -1
- package/dist/{chunk-XCRYC22O.js → chunk-WIV6K3EQ.js} +1 -1
- package/dist/commands-KBOTDLAH.js +37 -0
- package/dist/{hooks-Z5SOR4CL.js → hooks-VMLDC3D7.js} +1 -1
- package/dist/{server-O4OBRKIQ.js → server-C2WCQFVN.js} +1 -1
- package/package.json +1 -1
- package/dist/commands-BWQ3Q46D.js +0 -33
package/README.md
CHANGED
|
@@ -496,14 +496,16 @@ devcoach writes to `~/.devcoach/coaching.db`. If you get a permission error, che
|
|
|
496
496
|
|
|
497
497
|
## Uninstallation
|
|
498
498
|
|
|
499
|
+
One command undoes everything `devcoach install` wired up — the MCP registration, the hook entries and the skill — for Claude Code and Claude Desktop (add `--gemini`, `--codex` or `--all` for the beta agents). Your coaching data stays unless you ask for it to go:
|
|
500
|
+
|
|
499
501
|
```bash
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
502
|
+
devcoach uninstall # remove MCP server + hooks + skill (Claude Code + Claude Desktop)
|
|
503
|
+
devcoach uninstall --all --data # every agent, and delete ~/.devcoach (asks first; devcoach backup before)
|
|
504
|
+
npm uninstall -g devcoach # then remove the program (npx: nothing to remove)
|
|
505
|
+
brew uninstall devcoach # or, via Homebrew (brew untap UltimaPhoenix/tap to drop the tap)
|
|
504
506
|
```
|
|
505
507
|
|
|
506
|
-
|
|
508
|
+
Run `devcoach uninstall` **before** `brew uninstall` / `npm uninstall`: Homebrew formulae have no uninstall hook, and once the binary is gone the hooks left in `~/.claude/settings.json` would error on every turn. Using the Claude Code plugin instead? `/plugin uninstall devcoach` removes its hooks, skill and server in one go.
|
|
507
509
|
|
|
508
510
|
---
|
|
509
511
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {c,d,a}from'./chunk-
|
|
2
|
+
import {c,d,a}from'./chunk-WIV6K3EQ.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-J35FEB7C.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-VMLDC3D7.js');o(t);}else {let{runCli:o}=await import('./commands-KBOTDLAH.js');await o();}}catch(o){console.error(o),process.exit(1);}
|
|
@@ -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.512.gc165fb2"};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 {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-J35FEB7C.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
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {R,Q}from'./chunk-
|
|
2
|
+
import {R,Q}from'./chunk-J35FEB7C.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};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {e,g,b,d as d$1}from'./chunk-MHB2M5QZ.js';export{c as buildLessonCue,d as cmdLessonReady,b as cmdOnboardHook,g as cmdPromptHook,e as cmdStopHook,a as parseHookPayload}from'./chunk-MHB2M5QZ.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-WIV6K3EQ.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-J35FEB7C.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
|
+
`)}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
|
+
`),`${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
|
+
`),`${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}
|
|
6
|
+
`),`${n.green("\u2713")} Installed into ${e}`}function Vo(e){return Q()?`${n.yellow("Skipped")} \u2014 bundled with the devcoach Gemini extension`:fe(H,e)}function E(e,o){let t=C(e);return t.ok&&(t.data.hooks?.[o]??[]).some(r=>(r.hooks??[]).some(i=>ee(i.command??"")))}function we(){let e=[{name:"Claude Code",dir:q,cmd:"devcoach install",hooked:()=>E(I,"Stop")},{name:"Gemini/Codex",dir:H,cmd:"devcoach install --gemini (or --codex)",hooked:()=>E(_,"AfterAgent")||E(M,"Stop")}];for(let o of e){let t=P(o.dir);if(t==="outdated")return `${n.yellow("\u2192")} The devcoach ${o.name} skill is out of date \u2014 run ${n.bold(o.cmd)} to refresh it.`;if(t==="missing"&&o.hooked())return `${n.yellow("\u2192")} The devcoach ${o.name} skill is not installed \u2014 run ${n.bold(o.cmd)} to add it.`}return ""}function $o(e){let o=e.claudeCode||e.claudeDesktop||e.gemini||e.codex,t=e.claudeCode||!o,r=e.claudeDesktop||!o,i=yo(),a=false;if(c(n.bold("Setting up devcoach")+n.dim(` (${i.command} ${i.args.join(" ")})`)),c(),t){c(n.bold("Claude Code"));let s=Go("user",e.force);if(!s){let l=join(homedir(),".claude.json");s=me(l,{type:"stdio",env:{},...i},e.force),a=true;}c(` MCP server\u2026 ${s}`),e.skipHook||c(` Hooks\u2026 ${zo()}`),c(` Skill\u2026 ${fe(q,e.force)}`),c();}if(r&&(c(n.bold("Claude Desktop")),c(` MCP server\u2026 ${me(ko(),i,e.force)}`),a=true,c()),e.gemini){c(n.bold("Gemini CLI (beta)"));let s=po("gemini",["mcp","add","-s","user","devcoach",i.command,...i.args],e.force?["mcp","remove","-s","user","devcoach"]:null);s||(s=me(_,i,e.force)),c(` MCP server\u2026 ${s}`),e.skipHook||c(` Hooks\u2026 ${Ko()}`),c(` Skill\u2026 ${Vo(e.force)}`),c();}if(e.codex){c(n.bold("Codex CLI (beta)"));let s=po("codex",["mcp","add","devcoach","--",i.command,...i.args],e.force?["mcp","remove","devcoach"]:null);s||(s=`${n.yellow("Manual step")} \u2014 codex CLI not found. Add to ${X}:
|
|
7
|
+
[mcp_servers.devcoach]
|
|
8
|
+
command = "${i.command}"
|
|
9
|
+
args = [${i.args.map(l=>`"${l}"`).join(", ")}]`),c(` MCP server\u2026 ${s}`),e.skipHook||c(` Hooks\u2026 ${ve(M,Uo())}`),c(` Skill\u2026 ${fe(H,e.force)}`),c(` ${n.yellow("\u2192")} Codex asks once to trust new hooks \u2014 approve devcoach on the next run.`),c();}a&&c(`${n.yellow("\u2192")} Restart Claude Desktop to pick up the new server.
|
|
10
|
+
`),c(n.dim(`Tip: run devcoach backup to export your profile, lessons and settings.
|
|
11
|
+
run devcoach restore <file> to import a backup on a new machine.
|
|
12
|
+
After upgrading devcoach (npm, Homebrew), re-run devcoach install to refresh the skill.`));}function Ce(e){let o=[];for(let[t,r]of Object.entries(e.hooks??{}))for(let i of r??[])for(let a of i.hooks??[])ee(a.command??"")&&o.push({event:t,cmd:a});return o}function Se(e,o,t){for(let{cmd:r}of o){let i=r.command.split(" ")[0]??"";i.startsWith("/")&&!existsSync(i)&&e.bad(`hook command not found: ${i} \u2014 re-run ${n.bold(t)}`),r.command.startsWith("npx ")&&e.warn("hook runs via npx \u2014 needs the npx cache (or network) on every stop"),r.timeout==null&&e.warn(`hook entry has no timeout (${r.command})`);}}function Jo(e){c(n.bold(`
|
|
13
|
+
Gemini CLI wiring (beta)`));let o=C(_),t=Q();if(!o.ok){e.bad(`${_} is not valid JSON \u2014 hooks cannot run`);return}let r=Ce(o.data);t&&r.length?e.bad("devcoach hooks are registered TWICE (extension + settings.json) \u2014 interactions are double-counted. Uninstall the extension or remove the settings.json entries."):t?e.ok("hooks provided by the devcoach Gemini extension"):r.length?(r.some(a=>a.event==="AfterAgent")?e.ok("AfterAgent stop hook wired"):e.warn(`no AfterAgent stop hook \u2014 run ${n.bold("devcoach install --gemini")}`),r.some(a=>a.event==="BeforeAgent")?e.ok("BeforeAgent priming hook wired"):e.warn(`no BeforeAgent priming hook \u2014 run ${n.bold("devcoach install --gemini")} (lessons land more reliably)`),Se(e,r,"devcoach install --gemini")):e.warn(`no devcoach hooks in ${_} \u2014 run ${n.bold("devcoach install --gemini")}`);let i=P(H);t?e.ok("skill bundled with the devcoach Gemini extension"):i==="current"?e.ok("skill installed (~/.agents/skills, current version)"):i==="outdated"?e.warn(`skill is out of date \u2014 run ${n.bold("devcoach install --gemini")}`):e.warn(`skill not installed \u2014 run ${n.bold("devcoach install --gemini")}`),o.data.mcpServers?.devcoach?e.ok("MCP server registered (settings.json)"):e.warn(`MCP server not found in settings.json \u2014 it may be registered elsewhere (check with ${n.bold("gemini mcp list")})`);}function Wo(e){c(n.bold(`
|
|
14
|
+
Codex CLI wiring (beta)`));let o=C(M);if(!o.ok){e.bad(`${M} is not valid JSON \u2014 hooks cannot run`);return}let t=Ce(o.data);t.length?(t.some(a=>a.event==="Stop")?e.ok("Stop hook wired"):e.warn(`no Stop hook \u2014 run ${n.bold("devcoach install --codex")}`),t.some(a=>a.event==="UserPromptSubmit")?e.ok("UserPromptSubmit priming hook wired"):e.warn(`no UserPromptSubmit priming hook \u2014 run ${n.bold("devcoach install --codex")} (lessons land more reliably)`),Se(e,t,"devcoach install --codex"),e.warn("Codex runs hooks only after you trust them once \u2014 check the prompt on the next run")):e.warn(`no devcoach hooks in ${M} \u2014 run ${n.bold("devcoach install --codex")}`);let r=P(H);r==="current"?e.ok("skill installed (~/.agents/skills, current version)"):r==="outdated"?e.warn(`skill is out of date \u2014 run ${n.bold("devcoach install --codex")}`):e.warn(`skill not installed \u2014 run ${n.bold("devcoach install --codex")}`);let i=existsSync(X)?readFileSync(X,"utf8"):"";/\[mcp_servers\.devcoach\]/.test(i)?e.ok("MCP server registered (config.toml)"):e.warn(`MCP server not found in config.toml \u2014 it may be registered elsewhere (check with ${n.bold("codex mcp list")})`);}function vo(){let e={ok:s=>c(` ${n.green("\u2713")} ${s}`),warn:s=>c(` ${n.yellow("\u2192")} ${s}`),bad:s=>c(` ${n.red("\u2717")} ${s}`)},{ok:o$1,warn:t,bad:r}=e;c(`
|
|
15
|
+
${n.bold("devcoach doctor")} ${n.dim(`v${Q$1}`)}
|
|
16
|
+
`),c(n.bold("Environment")),Number.parseInt(process.versions.node.split(".")[0]??"0",10)>=24?o$1(`Node ${process.versions.node} (\u2265 24)`):r(`Node ${process.versions.node} \u2014 devcoach needs Node \u2265 24 (embedded node:sqlite)`),c(n.bold(`
|
|
17
|
+
Claude Code wiring`));let a=C(I);if(!a.ok)r(`${I} is not valid JSON \u2014 hooks cannot run`);else {let s=$e(a.data),l=Ce(a.data);if(s&&l.length)r("devcoach hooks are registered TWICE (plugin + settings.json) \u2014 interactions are double-counted. Disable the plugin or remove the settings.json entries.");else if(s)o$1("hooks provided by the devcoach plugin");else if(!l.length)r(`no devcoach hooks in ${I} \u2014 run ${n.bold("devcoach install")}`);else {let p=l.filter(({cmd:f})=>f.command.includes("onboard-hook")||f.command.includes("lesson-ready")),u=l.filter(f=>f.event==="Stop").length;p.length?t(`legacy two-entry Stop layout \u2014 run ${n.bold("devcoach install")} to merge into one stop-hook entry (fewer spawns per stop)`):u>1?t(`${u} devcoach Stop entries \u2014 interactions are counted ${u}\xD7 per stop; run ${n.bold("devcoach install")} to keep only the current one`):o$1(`Stop hook wired (${u} entry)`),l.some(f=>f.event==="UserPromptSubmit")?o$1("UserPromptSubmit priming hook wired"):t(`no UserPromptSubmit priming hook \u2014 run ${n.bold("devcoach install")} to add it (lessons land more reliably)`),Se(e,l,"devcoach install");}let m=P(q);m==="current"?o$1("Claude Code skill installed (current version)"):s?o$1("Claude Code skill bundled with the plugin"):t(m==="outdated"?`Claude Code skill is out of date \u2014 run ${n.bold("devcoach install")}`:`Claude Code skill not installed \u2014 run ${n.bold("devcoach install")}`);let g=C(join(homedir(),".claude.json"));g.ok&&g.data.mcpServers?.devcoach?o$1("MCP server registered (user scope)"):t(`MCP server not found in ~/.claude.json \u2014 it may be registered elsewhere (check with ${n.bold("claude mcp get devcoach")})`);}if(existsSync(ke)&&Jo(e),existsSync(be)&&Wo(e),c(n.bold(`
|
|
18
|
+
Database & pacing`)),!existsSync(i)){t(`no database yet (${i}) \u2014 onboarding runs on the first technical task`),c();return}try{o(s=>{o$1(`database opens (${i})`),M$1(s).knowledge_ready?o$1("onboarding complete"):t("onboarding not complete \u2014 the next stop cues it");let l=G(s);c(` settings: max_per_day=${l.max_per_day} \xB7 min_gap_minutes=${l.min_gap_minutes} \xB7 nudge_every=${l.nudge_every} \xB7 nudge_scope=${l.nudge_scope}`);let m=I$1(s),g=m.reduce((y,b)=>y+b.interactions,0);c(` pacing: ${m.length} session(s) counted, ${g} interaction(s) total`+(m[0]?` \u2014 latest ${m[0].session_id.slice(0,8)}\u2026 at ${m[0].interactions}`:""));let p=K(s);p.pending?t(`a cue is pending since ${p.last_cue_at} (retry threshold armed)`):p.last_skip_reason&&c(` last skip: "${p.last_skip_reason}"`);let u=_$1(s);u.allowed?o$1("rate limit: allowed"):t(`rate limit: ${u.reason}`),c(n.bold(`
|
|
19
|
+
Verdict`));let f=ga(s,m[0]?.session_id??null);f.wouldCue?o$1("the next eligible stop WOULD cue a lesson"):t("the next eligible stop would NOT cue a lesson:");for(let y of f.reasons)c(` \xB7 ${y}`);});}catch(s){r(`database check failed: ${s}`);}c();}function ue(e){if(!existsSync(e))return `${n.yellow("Not registered")} (${e} does not exist)`;let o=C(e);if(!o.ok)return o.error;let t=o.data.mcpServers;return t?.devcoach?(delete t.devcoach,writeFileSync(e,`${JSON.stringify(o.data,null,2)}
|
|
20
|
+
`),`${n.green("\u2713")} Removed from ${e}`):`${n.yellow("Not registered")} in ${e}`}function pe(e,o){if(!Z(e))return "";let t=spawnSync(e,o,{encoding:"utf8"}),r=`${t.stderr??""}${t.stdout??""}`.toLowerCase();return t.status===0?`${n.green("\u2713")} Removed via \`${e} mcp remove\``:/not found|no .*server|does not exist|no such/.test(r)?`${n.yellow("Not registered")} in ${e}`:`${n.red(`${e} mcp remove failed:`)} ${(t.stderr||t.stdout||"").trim()}`}function ge(e){if(!existsSync(e))return `${n.yellow("No hooks")} (${e} does not exist)`;let o=C(e);if(!o.ok)return o.error;let t=o.data.hooks??{},r=[];for(let[i,a]of Object.entries(t)){if(!a)continue;let s=a.filter(l=>!(l.hooks??[]).some(m=>ee(m.command??"")));s.length!==a.length&&(r.push(i),s.length?t[i]=s:delete t[i]);}return r.length===0?`${n.yellow("No devcoach hooks")} in ${e}`:(Object.keys(t).length===0&&delete o.data.hooks,writeFileSync(e,`${JSON.stringify(o.data,null,2)}
|
|
21
|
+
`),`${n.green("\u2713")} Hooks removed from ${e} (${r.join(" + ")})`)}function go(e){return existsSync(join(e,"SKILL.md"))?(rmSync(e,{recursive:true,force:true}),`${n.green("\u2713")} Removed ${e}`):`${n.yellow("Not installed")} (${e})`}async function Yo(e){if(e)return true;if(!process.stdin.isTTY)return c(`${n.yellow("\u2192")} Not a terminal \u2014 pass --yes to delete ${h} without a prompt.`),false;let o=createInterface({input:process.stdin,output:process.stdout});try{let t=await o.question(`Delete ${h} \u2014 every lesson, your profile and the notebook? [y/N] `);return /^y(es)?$/i.test(t.trim())}finally{o.close();}}async function wo(e){let o=e.claudeCode||e.claudeDesktop||e.gemini||e.codex,t=e.all||e.claudeCode||!o,r=e.all||e.claudeDesktop||!o,i=e.all||e.gemini,a=e.all||e.codex;if(c(n.bold("Removing devcoach from your agents")),c(),t){c(n.bold("Claude Code"));let s=C(I);s.ok&&$e(s.data)&&c(` ${n.yellow("\u2192")} The devcoach plugin is enabled \u2014 its hooks, skill and MCP server go away with /plugin uninstall devcoach; only user-level entries are removed here.`);let l=pe("claude",["mcp","remove","--scope","user","devcoach"]);l||(l=ue(join(homedir(),".claude.json"))),c(` MCP server\u2026 ${l}`),c(` Hooks\u2026 ${ge(I)}`),c(` Skill\u2026 ${go(q)}`),c();}if(r&&(c(n.bold("Claude Desktop")),c(` MCP server\u2026 ${ue(ko())}`),c(` ${n.yellow("\u2192")} Restart Claude Desktop to drop the server.`),c()),i){c(n.bold("Gemini CLI (beta)"));let s=pe("gemini",["mcp","remove","-s","user","devcoach"]);s||(s=ue(_)),c(` MCP server\u2026 ${s}`),c(` Hooks\u2026 ${ge(_)}`),Q()&&c(` ${n.yellow("\u2192")} The devcoach Gemini extension is installed \u2014 remove it with: gemini extensions uninstall devcoach`),c();}if(a){c(n.bold("Codex CLI (beta)"));let s=pe("codex",["mcp","remove","devcoach"]);s||(s=`${n.yellow("Manual step")} \u2014 codex CLI not found. Delete the [mcp_servers.devcoach] table from ${X}`),c(` MCP server\u2026 ${s}`),c(` Hooks\u2026 ${ge(M)}`),c();}if(i||a){let s=!i&&E(_,"AfterAgent")||!a&&E(M,"Stop");c(n.bold("Shared skill (Gemini + Codex)")),c(` Skill\u2026 ${s?`${n.yellow("Kept")} \u2014 still used by the other client (${H})`:go(H)}`),c();}e.data?(c(n.bold("Coaching data")),existsSync(h)?await Yo(e.yes)?(rmSync(h,{recursive:true,force:true}),c(` ${n.green("\u2713")} Deleted ${h}`)):c(` ${n.yellow("Kept")} ${h}`):c(` ${n.yellow("Nothing to delete")} (${h} does not exist)`),c()):c(n.dim(`Your lessons, profile and notebook are still in ${h} \u2014 keep them for a
|
|
22
|
+
reinstall, or delete them with: devcoach uninstall --data (devcoach backup first).`)),c(n.dim(`Then remove the program itself: brew uninstall devcoach \xB7 npm uninstall -g devcoach
|
|
23
|
+
(npx: nothing to remove).`));}var d=(e="")=>{console.log(e);},xo=e=>e==="junior"?n.green(e):e==="mid"?n.yellow(e):e==="senior"?n.red(e):e,en=e=>e==="know"?` ${n.green("\u2713")}`:e==="dont_know"?` ${n.red("\u2717")}`:"",on=e=>e==="know"?n.green("\u2713 I know this"):e==="dont_know"?n.red("\u2717 I don't know this"):n.dim("no feedback");function _o(e,o){let t=new Map;for(let i of e.groups)for(let a of i.topics)t.set(a,i.name);let r=[...e.knowledge].sort((i,a)=>a.confidence-i.confidence).map(i=>{let a=uo(i.confidence);return [i.topic,t.get(i.topic)??"Other",le(a,`${i.confidence}/10`),le(a,mo(i.confidence))]});return A(o,[{header:"Topic"},{header:"Group"},{header:"Confidence",justify:"right"},{header:"Bar"}],r)}function nn(){let e=o(o=>$(o));d(_o(e,"Knowledge Map"));}function tn(e){let o$1=o(s=>r(s,{period:e.period==="all"?null:e.period,category:e.category,level:e.level,project:e.project,repository:e.repository,branch:e.branch,commit:e.commit,starred:e.starred?true:null,imported:e.imported?true:null,feedback:e.feedback,date_from:e.dateFrom,date_to:e.dateTo,sort:e.sort,order:e.order}));if(o$1.length===0){d(n.dim("No lessons found."));return}let t=o$1.some(s=>s.project||s.branch||s.commit_hash),r$1=[{header:""},{header:"Date"},{header:"Topic"},{header:"Title"},{header:"Level",justify:"center"},{header:"Categories"}];t&&r$1.push({header:"Project"},{header:"Branch"},{header:"Commit"});let i=o$1.some(s=>s.imported);i&&r$1.push({header:"Shared by"});let a=o$1.map(s=>{let l=[s.starred?n.yellow("\u2605"):n.dim("\xB7"),s.timestamp.slice(0,10),n.cyan(s.topic_id),s.title+en(s.feedback),xo(s.level),s.categories.join(", ")];return t&&l.push(s.project??"",s.branch?n.magenta(s.branch):"",s.commit_hash?n.cyan(s.commit_hash.slice(0,7)):""),i&&l.push(s.imported?s.shared_by??n.dim("anonymous"):""),l});d(A("Lessons",r$1,a));}function rn(e){let o$1=o(r=>x(r,e));o$1===null&&(d(n.red(`Lesson '${e}' not found.`)),process.exit(1)),d(W(n.bold(o$1.title))),d(`${n.dim("ID:")} ${o$1.id}`),d(`${n.dim("Date:")} ${o$1.timestamp.slice(0,19).replace("T"," ")}`),d(`${n.dim("Topic:")} ${o$1.topic_id}`),d(`${n.dim("Categories:")} ${o$1.categories.join(", ")}`),d(`${n.dim("Level:")} ${xo(o$1.level)}`);let t=o$1.starred?n.yellow("\u2605 starred"):n.dim("\u2606 not starred");if(d(`${n.dim("Star:")} ${t} ${n.dim("Feedback:")} ${on(o$1.feedback)}`),o$1.imported&&d(`${n.dim("Shared by:")} ${o$1.shared_by??n.dim("anonymous")}`),o$1.task_context&&d(`${n.dim("Context:")} ${o$1.task_context}`),o$1.project||o$1.repository||o$1.branch||o$1.commit_hash||o$1.folder){let r=[];o$1.project&&r.push(`project=${o$1.project}`),o$1.repository&&r.push(`repo=${o$1.repository}`),o$1.branch&&r.push(`branch=${n.magenta(o$1.branch)}`),o$1.commit_hash&&r.push(`commit=${n.cyan(o$1.commit_hash.slice(0,7))}`),o$1.folder&&r.push(`folder=${o$1.folder}`),d(`${n.dim("Git:")} ${r.join(" \xB7 ")}`);}d(W()),d(o$1.summary);}function Co(e,o$1){o(r=>x(r,e)===null?false:(t(r,e,o$1),true))||(d(n.red(`Lesson '${e}' not found.`)),process.exit(1)),d(o$1?`Lesson ${n.cyan(e)} \u2192 ${n.yellow("\u2605 starred")}`:`Lesson ${n.cyan(e)} \u2192 ${n.dim("\u2606 unstarred")}`);}function sn(e){o(t=>s(t,e))||(d(n.red(`Lesson '${e}' not found.`)),process.exit(1)),d(`Lesson ${n.cyan(e)} deleted.`);}function an(e,o$1){["know","dont_know","clear"].includes(o$1)||(d(n.red(`Invalid feedback '${o$1}'. Use: know | dont_know | clear`)),process.exit(1));let t=o$1==="clear"?null:o$1,r=o(s=>{let l=ba(s,e,t);if(l===null)return null;let m=s.prepare("SELECT confidence FROM knowledge WHERE topic = ?").get(l);return {topicId:l,newConf:m?m.confidence:5}});r===null&&(d(n.red(`Lesson '${e}' not found.`)),process.exit(1));let i;if(t==="know"||t==="dont_know"){let s=r.newConf+(t==="know"?-1:1);i=`${n.cyan(r.topicId)} confidence: ${s} \u2192 ${n.bold(String(r.newConf))}`;}else i="feedback cleared";let a=t==="know"?n.green("\u2713 I know this"):t==="dont_know"?n.red("\u2717 I don't know this"):n.dim("cleared");d(`Lesson ${n.cyan(e)} \u2192 ${a} (${i})`);}function dn(){let e=o(i=>G(i)),o$1=Math.floor(e.min_gap_minutes/60),t=e.min_gap_minutes%60,r=o$1?`${o$1}h ${t}m`:`${t}m`;d(A("Settings",[{header:"Key"},{header:"Value",justify:"right"}],[["max_per_day",String(e.max_per_day)],["min_gap_minutes",`${e.min_gap_minutes} (${r})`],["nudge_every",e.nudge_every===0?"0 (off)":String(e.nudge_every)],["nudge_scope",e.nudge_scope],["share_name",e.share_name??n.dim("(unset \u2192 git user.name)")]]));}function cn(){let{stats:e,rateLimit:o$1,settings:t}=o(m=>({stats:ca(m),rateLimit:_$1(m),settings:G(m)})),r=m=>Number(e[m]??0),i=o$1.allowed?n.green("Available now"):n.yellow(o$1.reason??"");d(A("Coaching Stats",[{header:"Metric"},{header:"Value",justify:"right"}],[["Total lessons",String(r("total_lessons"))],["Lessons today (24h)",`${r("lessons_today")} / ${t.max_per_day}`],["Lessons this week",String(r("lessons_this_week"))],["Next lesson",i]],false));let a=e.weakest_topics??[],s=e.strongest_topics??[];if(a.length||s.length){let m=[];for(let g=0;g<Math.max(a.length,s.length);g++){let p=a[g],u=s[g];m.push([p?`${n.red(p.topic)} ${n.dim(`(${p.confidence})`)}`:"",u?`${n.green(u.topic)} ${n.dim(`(${u.confidence})`)}`:""]);}d(A(void 0,[{header:"Weakest topics"},{header:"Strongest topics"}],m));}let l=we();l&&d(`
|
|
24
|
+
${l}`);}function ln(e,o$1){let t=["max_per_day","min_gap_minutes","nudge_every","nudge_scope","share_name"];if(t.includes(e)||(d(n.red(`Unknown key '${e}'. Valid keys: ${t.join(", ")}`)),process.exit(1)),e==="nudge_scope"&&o$1!=="session"&&o$1!=="global"&&(d(n.red(`Invalid nudge_scope '${o$1}'. Use: session | global`)),process.exit(1)),e==="share_name"){o$1.trim().length>l&&(d(n.red(`share_name must be at most ${l} characters.`)),process.exit(1));let r=m(o$1);o(i=>H$1(i,e,r)),d(r?n.green(`Set share_name = ${r}`):n.green("Cleared share_name"));return}if(e==="nudge_every"){let r=Number.parseInt(o$1,10);(!Number.isInteger(r)||r<0)&&(d(n.red(`Invalid nudge_every '${o$1}'. Use a non-negative integer (0 = off).`)),process.exit(1));}o(r=>H$1(r,e,o$1)),d(n.green(`Set ${e} = ${o$1}`));}function mn(e,o$1,t){let r=e.trim();r||(d(n.red("Topic name must not be empty.")),process.exit(1)),o(a=>{A$1(a,r,o$1),t&&t!=="Other"&&E$1(a,r,t);});let i=t&&t!=="Other"?` \u2192 ${n.cyan(t)}`:"";d(`${n.green("Added")} ${n.bold(r)} (confidence ${n.cyan(String(o$1))})${i}`);}function un(e){let o$1=o(t=>B(t,e));d(o$1?`${n.green("Removed")} ${n.bold(e)} from knowledge map`:n.yellow(`Topic '${e}' not found.`));}function pn(e){let o$1=e.trim();(!o$1||o$1==="Other")&&(d(n.red("Invalid group name.")),process.exit(1)),o(t=>C$1(t,o$1)),d(`${n.green(`Group '${n.cyan(o$1)}' ready.`)} Assign topics with: devcoach group-assign <topic> "${o$1}"`);}function gn(e){let o$1=o(t=>D$1(t,e));d(o$1?`${n.green(`Removed group '${n.cyan(e)}'`)}`:n.yellow(`Group '${e}' not found.`));}function fn(e,o$1){o(r=>r.prepare("SELECT topic FROM knowledge WHERE topic = ?").get(e)===void 0?false:(o$1==="Other"?F(r,e):E$1(r,e,o$1),true))||(d(n.red(`Topic '${e}' not in knowledge map. Add it first.`)),process.exit(1)),d(o$1==="Other"?`${n.green("Moved")} ${n.bold(e)} \u2192 Other (ungrouped)`:`${n.green("Moved")} ${n.bold(e)} \u2192 ${n.cyan(o$1)}`);}function hn(e){let{lessonsCount:o$1,knowledgeCount:t,data:r}=o(a=>({lessonsCount:v(a).length,knowledgeCount:z(a).length,data:O(a)}));writeFileSync(e,r);let i=existsSync(j)?" + notebook":"";d(`${n.green("Backup saved:")} ${e} (${n.cyan(String(o$1))} lessons, ${n.cyan(String(t))} topics${i})`);}function kn(e){existsSync(e)||(d(n.red(`File not found: ${e}`)),process.exit(1));let o$1=o(r=>P$1(r,readFileSync(e)));o$1.settings&&d(`${n.green("\u2713")} Settings restored`),o$1.topics&&d(`${n.green("\u2713")} Knowledge map restored (${n.cyan(String(o$1.topics))} topics)`);let t=[`${n.cyan(String(o$1.lessons))} imported`];o$1.skipped&&t.push(`${n.yellow(String(o$1.skipped))} duplicates skipped`),o$1.invalid&&t.push(`${n.red(String(o$1.invalid))} rejected (invalid)`),d(`${n.green("\u2713")} Lessons: ${t.join(", ")}`),o$1.learning_state&&d(`${n.green("\u2713")} Notebook restored`);}var oe=e=>{console.error(n.dim(e));};function bn(e,o$1){o$1.by!==void 0&&o$1.anonymous&&(d(n.red("Use either --by <name> or --anonymous, not both.")),process.exit(1)),!e&&!o$1.last&&(d(n.red("Give a lesson id, or --last for the most recent one.")),process.exit(2));let t=o(a$1=>{let s=o$1.last?r(a$1,{imported:false,page:1,per_page:1})[0]??null:x(a$1,e);if(!s)return null;let l=G(a$1),m$1=T({explicit:o$1.by??null,anonymous:o$1.anonymous,setting:l.share_name,gitUserName:a()}),g=false;return o$1.by?.trim()&&!l.share_name&&(H$1(a$1,"share_name",m(o$1.by)),g=true),{payload:S$1(s,{includeContext:!!o$1.withContext,sharedBy:m$1}),remembered:g}});t||(d(n.red(o$1.last?"No lessons to share yet.":`Lesson '${e}' not found.`)),process.exit(1));let{payload:r$1,remembered:i}=t;if(o$1.file!==void 0&&o$1.file!==false){let a=typeof o$1.file=="string"?o$1.file:Y(r$1);writeFileSync(a,Z$1(r$1)),d(`${n.green("Saved:")} ${a}`);}else o$1.link?d(X$1(r$1)):(d(W$1(r$1)),U(r$1).length>16e3&&oe("Long lesson \u2014 prefer --file for a friendlier hand-off."));i&&oe("(remembered as share_name \u2014 change it with: devcoach set share_name <name>)"),r$1.shared_by===null&&oe("Shared anonymously (set a name with: devcoach set share_name <name>)");}function yn(){let e=process.platform==="darwin"?[["pbpaste",[]]]:process.platform==="win32"?[["powershell",["-NoProfile","-Command","Get-Clipboard"]]]:[["wl-paste",["--no-newline"]],["xclip",["-selection","clipboard","-o"]],["xsel",["--clipboard","--output"]]];for(let[o,t]of e)try{let r=execFileSync(o,t,{encoding:"utf8",timeout:3e3,stdio:["ignore","pipe","ignore"]});if(r.trim())return r}catch{}throw new R("Clipboard is empty or unavailable \u2014 pass the code, a link or a file, or pipe it: devcoach import -")}async function $n(e){return e===void 0?yn():e==="-"?text(process.stdin):existsSync(e)?readFileSync(e,"utf8"):c$2(e)&&!e.includes("#devcoach:lesson:")?d$2(e):e}async function vn(e){try{let o$1=await $n(e),t=o(a=>da(a,o$1));if(t.kind==="lessons"){let a=[`${n.cyan(String(t.inserted))} imported`];t.duplicated&&a.push(`${n.yellow(String(t.duplicated))} duplicates skipped`),t.invalid&&a.push(`${n.red(String(t.invalid))} rejected (invalid)`),d(`${n.green("\u2713")} Lessons: ${a.join(", ")}`);return}let r=t.lesson;r||(d(n.red("Could not store the lesson.")),process.exit(1));let i=r.shared_by?`shared by ${r.shared_by}`:"shared anonymously";t.duplicated?d(`${n.yellow("Already in your log")} as ${n.cyan(r.id)} (${i})`):d(`${n.green("\u2713 Imported")} ${n.bold(`"${r.title}"`)} (${i}) as ${n.cyan(r.id)} \u2014 topic ${n.cyan(r.topic_id)}`),t.topic_tracked===!1&&oe(`Topic '${r.topic_id}' is not in your knowledge map \u2014 track it with: devcoach knowledge-add ${r.topic_id}`);}catch(o){if(!(o instanceof R))throw o;d(n.red(o.message)),process.exit(1);}}async function wn(){let e=createInterface({input:process.stdin,output:process.stdout}),o$1=async(r,i="")=>{let a=i?` [${i}]`:"";return (await e.question(`${r}${a}: `)).trim()||i},t=async(r,i,a,s)=>{for(;;){let l=await o$1(r,String(i)),m=Number.parseInt(l,10);if(!Number.isNaN(m)&&m>=a&&m<=s)return m;d(n.red(`Must be ${a}\u2013${s}.`));}};try{d(W(n.bold("devcoach setup"))),d(`
|
|
25
|
+
${n.bold("Step 1")} \u2014 Restore from backup`);let r=await o$1("Path to existing backup zip (Enter to skip)","");if(r){existsSync(r)||(d(n.red(`File not found: ${r}`)),process.exit(1));let p=o(u=>P$1(u,readFileSync(r)));d(`${n.green("\u2713")} Restored: ${p.topics} topics, ${p.lessons} lessons${p.learning_state?", notebook":""}`),d(n.green("Setup complete!"));return}d(`
|
|
26
|
+
${n.bold("Step 2")} \u2014 Build your knowledge profile`);let i=(await o$1("Mode: [a]utomatic (detect from files) / [m]anual (type your stack)","a")).toLowerCase(),a={};if(i.startsWith("a")){let u=b$1().folder??process.cwd(),f=c$1(),y=b$2(a$1(u),f.detected_stack),b=Object.keys(y).sort((v,R)=>v.localeCompare(R));if(f.scanned_projects>0){d(`
|
|
27
|
+
${n.dim(`Scanned ${f.scanned_projects} Claude Code project(s) from your history:`)}`);for(let v of f.projects.slice(0,8))d(n.dim(` ${v.name} \u2014 ${v.topics.join(", ")||"no stack signals"}`));}if(b.length){d(`
|
|
28
|
+
${n.dim(`Detected (history + ${n.cyan(u)}):`)}`);for(let v of b){let R=y[v]??5,_e=await o$1(` ${n.cyan(v)} (Enter=keep, 0-10=override, s=skip)`,String(R));if(_e.toLowerCase()==="s")continue;let Ie=Number.parseInt(_e,10);a[v]=Number.isNaN(Ie)?R:Math.max(0,Math.min(10,Ie));}}else d(n.dim("No technology files detected in current directory."));let G=await o$1(`
|
|
29
|
+
Add additional topics (comma-separated, or Enter to skip)`,"");for(let v of G.split(",").map(R=>R.trim()).filter(Boolean))a[v]=await t(` Confidence for ${n.cyan(v)}`,5,0,10);}else for(d(n.dim(`
|
|
30
|
+
Enter topics: 'topic_id confidence' (e.g. python 7). Blank line when done.`));;){let p=(await o$1("Topic (Enter when done)","")).trim();if(!p)break;let u=p.split(/\s+/),f=u[0]??"",y=Number.parseInt(u[1]??"",10),b=Number.isNaN(y)?5:Math.max(0,Math.min(10,y));a[f]=b,d(` ${n.green("+")} ${n.cyan(f)} \u2192 ${b}`);}let s={};if(Object.keys(a).length&&(d(`
|
|
31
|
+
${n.bold("Step 3")} \u2014 Organise into groups`),(await o$1("Organise topics into groups? [y/N]","n")).toLowerCase().startsWith("y"))){let u=[];for(let f of Object.keys(a).sort((y,b)=>y.localeCompare(b))){let y=u.length?u.join(", "):"(none yet)",b=await o$1(` Group for ${n.cyan(f)} existing: ${n.dim(y)} (Enter=Other)`,"");if(b&&b!=="Other"){let G=s[b]??[];G.push(f),s[b]=G,u.includes(b)||u.push(b);}}}d(`
|
|
32
|
+
${n.bold("Step 4")} \u2014 Rate-limit settings`);let l=await t("Max lessons per day",2,1,20),m=await t("Min gap between lessons (minutes)",240,0,1440),g=o(p=>{p.exec("DELETE FROM knowledge; DELETE FROM knowledge_groups; DELETE FROM knowledge_group_names;");for(let[u,f]of Object.entries(a))A$1(p,u,f);for(let[u,f]of Object.entries(s))for(let y of f)E$1(p,y,u);return H$1(p,"max_per_day",String(l)),H$1(p,"min_gap_minutes",String(m)),$(p)});d(_o(g,"Knowledge Profile")),d(`
|
|
33
|
+
${n.green("Setup complete!")} ${Object.keys(a).length} topics saved.`);}finally{e.close();}}function Cn(){let e=[["mcp","Start the MCP server (stdio) for Claude Code / Claude Desktop"],["ui [--port N]","Launch the web dashboard (default port: 7860)"],["setup","First-run wizard: import backup or build your knowledge profile"],["install","Register MCP server + hooks + skill (Claude default; --gemini/--codex beta)"],["uninstall","Remove the MCP server, hooks and skill (--all: every agent; --data: wipe ~/.devcoach)"],["onboard-hook","Claude Code Stop hook: cue onboarding when no profile exists"],["lesson-ready","Claude Code Stop hook: cue a lesson when one is due"],["doctor","Diagnose the agent wiring \u2014 explains why a lesson would(n't) fire"],["profile","Show the knowledge map"],["stats","Coaching statistics and rate-limit status"],["settings / set","Show / update settings (max_per_day | min_gap_minutes)"],["lessons / lesson","List past lessons / show one in detail"],["star / unstar / delete","Manage a lesson"],["feedback <id>","Record know / dont_know feedback"],["share / import","Hand a lesson to a teammate / add a shared lesson to your log"],["knowledge-add / -remove","Add / remove a topic"],["group-add / -remove / -assign","Manage knowledge groups"],["backup / restore","Export / import a full backup zip"]];d(`
|
|
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
|
+
${n.dim("Run")} ${n.bold("devcoach <command> --help")} ${n.dim("for per-command options.")}
|
|
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-C2WCQFVN.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-56UHVZWZ.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-MHB2M5QZ.js';import'./chunk-J35FEB7C.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-XCRYC22O.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-IWLGZVJY.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-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
|
|
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.512.gc165fb2",
|
|
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",
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {e,g,b,d}from'./chunk-J7DLMRUC.js';export{c as buildLessonCue,d as cmdLessonReady,b as cmdOnboardHook,g as cmdPromptHook,e as cmdStopHook,a as parseHookPayload}from'./chunk-J7DLMRUC.js';import {c,b as b$2,a as a$2,e as e$1,f}from'./chunk-MRABMPXO.js';import {a as a$1,b as b$1,c as c$1,d as d$1}from'./chunk-XCRYC22O.js';import {Q,o,$,r,x as x$1,t,s,ba,G,T as T$1,H,m as m$1,S as S$1,Y,Z,X,W,U,da,R as R$1,_,ca,l,A,E as E$1,B,C,D,F,O as O$1,z as z$1,v as v$1,j as j$1,P,i,M,I,K as K$1,ga}from'./chunk-IWLGZVJY.js';import {spawnSync,execFileSync}from'child_process';import {writeFileSync,existsSync,readFileSync,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 vo=!!process.stdout.isTTY&&!process.env.NO_COLOR,x=(e,o)=>vo?styleText(e,o):o,n={green:e=>x("green",e),red:e=>x("red",e),yellow:e=>x("yellow",e),cyan:e=>x("cyan",e),magenta:e=>x("magenta",e),dim:e=>x("dim",e),bold:e=>x("bold",e)};function te(e,o){return e==="green"?n.green(o):e==="yellow"?n.yellow(o):n.red(o)}var Co=/\[[0-9;]*m/g,So=e=>e.replace(Co,""),z=e=>[...So(e)].length;function ro(e,o,t){let r=Math.max(0,o-z(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 O(e,o,t,r=true){let i=o.map((g,p)=>Math.max(r?z(g.header):0,...t.map(c=>z(c[p]??"")))),d=(g,p,c)=>g+i.map(f=>"\u2500".repeat(f+2)).join(p)+c,s=g=>`\u2502${g.map((p,c)=>` ${ro(p??"",i[c]??0,o[c]?.justify??"left")} `).join("\u2502")}\u2502`,u=i.reduce((g,p)=>g+p+3,1),l=[];e&&l.push(ro(n.bold(e),u,"center")),l.push(d("\u256D","\u252C","\u256E")),r&&l.push(s(o.map(g=>n.bold(g.header))),d("\u251C","\u253C","\u2524"));for(let g of t)l.push(s(g));return l.push(d("\u2570","\u2534","\u256F")),l.join(`
|
|
3
|
-
`)}function K(e=""){if(!e)return "\u2500".repeat(60);let t=` ${e} `,r=Math.max(2,60-z(t)),i=Math.floor(r/2);return "\u2500".repeat(i)+t+"\u2500".repeat(r-i)}var io=e=>{let o=Math.max(0,Math.min(10,Math.round(e)));return "\u2588".repeat(o)+"\u2591".repeat(10-o)},so=e=>e>=7?"green":e>=4?"yellow":"red";var m=(e="")=>{console.log(e);};function Oo(){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 j=join(homedir(),".claude","settings.json"),ce=join(homedir(),".claude","skills","devcoach"),le=join(homedir(),".gemini"),T=join(le,"settings.json"),jo=join(le,"extensions","devcoach","gemini-extension.json"),me=join(homedir(),".codex"),E=join(me,"hooks.json"),se=join(me,"config.toml"),N=join(homedir(),".agents","skills","devcoach");function lo(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 ue=e=>lo(e)!==null;function mo(){return ue("devcoach")?{command:"devcoach",args:["mcp"]}:{command:"npx",args:["-y","devcoach","mcp"]}}function pe(){let e=lo("devcoach");return e?e.includes("fnm_multishells")?"devcoach":e:"npx -y devcoach"}function ao(e,o,t){if(!ue(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 To(e,o){if(!ue("claude"))return "";o&&spawnSync("claude",["mcp","remove","--scope",e,"devcoach"],{encoding:"utf8"});let t=mo(),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 S(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 re(e,o,t){let r=S(e);if(!r.ok)return r.error;let i=r.data;i.mcpServers??={};let d=i.mcpServers;return d.devcoach&&!t?`${n.yellow("Already registered")} in ${e} (use --force to overwrite)`:(d.devcoach=o,mkdirSync(dirname(e),{recursive:true}),writeFileSync(e,`${JSON.stringify(i,null,2)}
|
|
4
|
-
`),`${n.green("\u2713")} Installed into ${e}`)}function Ho(){let e=pe();return {Stop:{hooks:[{type:"command",command:`${e} stop-hook`,timeout:60}]},UserPromptSubmit:{hooks:[{type:"command",command:`${e} prompt-hook`,timeout:30}]}}}function Eo(){let e=pe();return {AfterAgent:{hooks:[{type:"command",command:`${e} gemini-stop-hook`,timeout:6e4}]},BeforeAgent:{hooks:[{type:"command",command:`${e} gemini-prompt-hook`,timeout:3e4}]}}}function No(){let e=pe();return {Stop:{hooks:[{type:"command",command:`${e} codex-stop-hook`,timeout:60}]},UserPromptSubmit:{hooks:[{type:"command",command:`${e} codex-prompt-hook`,timeout:30}]}}}function uo(e){return Object.entries(e.enabledPlugins??{}).some(([o,t])=>t&&o.startsWith("devcoach@"))}function ge(){return existsSync(jo)}function fe(e){return /dev-?coach/i.test(e)&&/\b(?:stop-hook|prompt-hook|onboard-hook|lesson-ready)\b/.test(e)}function he(e,o){let t=S(e);if(!t.ok)return t.error;let r=t.data;r.hooks??={};let i=r.hooks,d=false;for(let[s,u]of Object.entries(o)){i[s]??=[];let l=i[s],g=l.map((c,f)=>[c,f]).filter(([c])=>(c.hooks??[]).some(f=>fe(f.command??""))).map(([,c])=>c),[p]=g;if(!(g.length===1&&p!==void 0&&JSON.stringify(l[p])===JSON.stringify(u))){for(let c of g.toReversed())l.splice(c,1);l.push(u),d=true;}}return d?(mkdirSync(dirname(e),{recursive:true}),writeFileSync(e,`${JSON.stringify(r,null,2)}
|
|
5
|
-
`),`${n.green("\u2713")} Hooks installed into ${e} (${Object.keys(o).join(" + ")})`):`${n.yellow("Already installed")} in ${e} (current layout)`}function Ro(){let e=S(j);return e.ok?uo(e.data)?`${n.yellow("Skipped")} \u2014 the devcoach plugin already provides the hooks (installing both would double-count interactions)`:he(j,Ho()):e.error}function Ao(){return ge()?`${n.yellow("Skipped")} \u2014 the devcoach Gemini extension already provides the hooks (installing both would double-count interactions)`:he(T,Eo())}function R(e){if(!existsSync(join(e,"SKILL.md")))return "missing";try{if(readFileSync(join(e,".devcoach-version"),"utf8").trim()===Q)return "current"}catch{}return "outdated"}function ae(e,o){if(!o&&R(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}
|
|
6
|
-
`),`${n.green("\u2713")} Installed into ${e}`}function Do(e){return ge()?`${n.yellow("Skipped")} \u2014 bundled with the devcoach Gemini extension`:ae(N,e)}function ie(e,o){let t=S(e);return t.ok&&(t.data.hooks?.[o]??[]).some(r=>(r.hooks??[]).some(i=>fe(i.command??"")))}function ke(){let e=[{name:"Claude Code",dir:ce,cmd:"devcoach install",hooked:()=>ie(j,"Stop")},{name:"Gemini/Codex",dir:N,cmd:"devcoach install --gemini (or --codex)",hooked:()=>ie(T,"AfterAgent")||ie(E,"Stop")}];for(let o of e){let t=R(o.dir);if(t==="outdated")return `${n.yellow("\u2192")} The devcoach ${o.name} skill is out of date \u2014 run ${n.bold(o.cmd)} to refresh it.`;if(t==="missing"&&o.hooked())return `${n.yellow("\u2192")} The devcoach ${o.name} skill is not installed \u2014 run ${n.bold(o.cmd)} to add it.`}return ""}function po(e){let o=e.claudeCode||e.claudeDesktop||e.gemini||e.codex,t=e.claudeCode||!o,r=e.claudeDesktop||!o,i=mo(),d=false;if(m(n.bold("Setting up devcoach")+n.dim(` (${i.command} ${i.args.join(" ")})`)),m(),t){m(n.bold("Claude Code"));let s=To("user",e.force);if(!s){let u=join(homedir(),".claude.json");s=re(u,{type:"stdio",env:{},...i},e.force),d=true;}m(` MCP server\u2026 ${s}`),e.skipHook||m(` Hooks\u2026 ${Ro()}`),m(` Skill\u2026 ${ae(ce,e.force)}`),m();}if(r&&(m(n.bold("Claude Desktop")),m(` MCP server\u2026 ${re(Oo(),i,e.force)}`),d=true,m()),e.gemini){m(n.bold("Gemini CLI (beta)"));let s=ao("gemini",["mcp","add","-s","user","devcoach",i.command,...i.args],e.force?["mcp","remove","-s","user","devcoach"]:null);s||(s=re(T,i,e.force)),m(` MCP server\u2026 ${s}`),e.skipHook||m(` Hooks\u2026 ${Ao()}`),m(` Skill\u2026 ${Do(e.force)}`),m();}if(e.codex){m(n.bold("Codex CLI (beta)"));let s=ao("codex",["mcp","add","devcoach","--",i.command,...i.args],e.force?["mcp","remove","devcoach"]:null);s||(s=`${n.yellow("Manual step")} \u2014 codex CLI not found. Add to ${se}:
|
|
7
|
-
[mcp_servers.devcoach]
|
|
8
|
-
command = "${i.command}"
|
|
9
|
-
args = [${i.args.map(u=>`"${u}"`).join(", ")}]`),m(` MCP server\u2026 ${s}`),e.skipHook||m(` Hooks\u2026 ${he(E,No())}`),m(` Skill\u2026 ${ae(N,e.force)}`),m(` ${n.yellow("\u2192")} Codex asks once to trust new hooks \u2014 approve devcoach on the next run.`),m();}d&&m(`${n.yellow("\u2192")} Restart Claude Desktop to pick up the new server.
|
|
10
|
-
`),m(n.dim(`Tip: run devcoach backup to export your profile, lessons and settings.
|
|
11
|
-
run devcoach restore <file> to import a backup on a new machine.
|
|
12
|
-
After upgrading devcoach (npm, Homebrew), re-run devcoach install to refresh the skill.`));}function be(e){let o=[];for(let[t,r]of Object.entries(e.hooks??{}))for(let i of r??[])for(let d of i.hooks??[])fe(d.command??"")&&o.push({event:t,cmd:d});return o}function ye(e,o,t){for(let{cmd:r}of o){let i=r.command.split(" ")[0]??"";i.startsWith("/")&&!existsSync(i)&&e.bad(`hook command not found: ${i} \u2014 re-run ${n.bold(t)}`),r.command.startsWith("npx ")&&e.warn("hook runs via npx \u2014 needs the npx cache (or network) on every stop"),r.timeout==null&&e.warn(`hook entry has no timeout (${r.command})`);}}function Po(e){m(n.bold(`
|
|
13
|
-
Gemini CLI wiring (beta)`));let o=S(T),t=ge();if(!o.ok){e.bad(`${T} is not valid JSON \u2014 hooks cannot run`);return}let r=be(o.data);t&&r.length?e.bad("devcoach hooks are registered TWICE (extension + settings.json) \u2014 interactions are double-counted. Uninstall the extension or remove the settings.json entries."):t?e.ok("hooks provided by the devcoach Gemini extension"):r.length?(r.some(d=>d.event==="AfterAgent")?e.ok("AfterAgent stop hook wired"):e.warn(`no AfterAgent stop hook \u2014 run ${n.bold("devcoach install --gemini")}`),r.some(d=>d.event==="BeforeAgent")?e.ok("BeforeAgent priming hook wired"):e.warn(`no BeforeAgent priming hook \u2014 run ${n.bold("devcoach install --gemini")} (lessons land more reliably)`),ye(e,r,"devcoach install --gemini")):e.warn(`no devcoach hooks in ${T} \u2014 run ${n.bold("devcoach install --gemini")}`);let i=R(N);t?e.ok("skill bundled with the devcoach Gemini extension"):i==="current"?e.ok("skill installed (~/.agents/skills, current version)"):i==="outdated"?e.warn(`skill is out of date \u2014 run ${n.bold("devcoach install --gemini")}`):e.warn(`skill not installed \u2014 run ${n.bold("devcoach install --gemini")}`),o.data.mcpServers?.devcoach?e.ok("MCP server registered (settings.json)"):e.warn(`MCP server not found in settings.json \u2014 it may be registered elsewhere (check with ${n.bold("gemini mcp list")})`);}function Go(e){m(n.bold(`
|
|
14
|
-
Codex CLI wiring (beta)`));let o=S(E);if(!o.ok){e.bad(`${E} is not valid JSON \u2014 hooks cannot run`);return}let t=be(o.data);t.length?(t.some(d=>d.event==="Stop")?e.ok("Stop hook wired"):e.warn(`no Stop hook \u2014 run ${n.bold("devcoach install --codex")}`),t.some(d=>d.event==="UserPromptSubmit")?e.ok("UserPromptSubmit priming hook wired"):e.warn(`no UserPromptSubmit priming hook \u2014 run ${n.bold("devcoach install --codex")} (lessons land more reliably)`),ye(e,t,"devcoach install --codex"),e.warn("Codex runs hooks only after you trust them once \u2014 check the prompt on the next run")):e.warn(`no devcoach hooks in ${E} \u2014 run ${n.bold("devcoach install --codex")}`);let r=R(N);r==="current"?e.ok("skill installed (~/.agents/skills, current version)"):r==="outdated"?e.warn(`skill is out of date \u2014 run ${n.bold("devcoach install --codex")}`):e.warn(`skill not installed \u2014 run ${n.bold("devcoach install --codex")}`);let i=existsSync(se)?readFileSync(se,"utf8"):"";/\[mcp_servers\.devcoach\]/.test(i)?e.ok("MCP server registered (config.toml)"):e.warn(`MCP server not found in config.toml \u2014 it may be registered elsewhere (check with ${n.bold("codex mcp list")})`);}function go(){let e={ok:s=>m(` ${n.green("\u2713")} ${s}`),warn:s=>m(` ${n.yellow("\u2192")} ${s}`),bad:s=>m(` ${n.red("\u2717")} ${s}`)},{ok:o$1,warn:t,bad:r}=e;m(`
|
|
15
|
-
${n.bold("devcoach doctor")} ${n.dim(`v${Q}`)}
|
|
16
|
-
`),m(n.bold("Environment")),Number.parseInt(process.versions.node.split(".")[0]??"0",10)>=24?o$1(`Node ${process.versions.node} (\u2265 24)`):r(`Node ${process.versions.node} \u2014 devcoach needs Node \u2265 24 (embedded node:sqlite)`),m(n.bold(`
|
|
17
|
-
Claude Code wiring`));let d=S(j);if(!d.ok)r(`${j} is not valid JSON \u2014 hooks cannot run`);else {let s=uo(d.data),u=be(d.data);if(s&&u.length)r("devcoach hooks are registered TWICE (plugin + settings.json) \u2014 interactions are double-counted. Disable the plugin or remove the settings.json entries.");else if(s)o$1("hooks provided by the devcoach plugin");else if(!u.length)r(`no devcoach hooks in ${j} \u2014 run ${n.bold("devcoach install")}`);else {let p=u.filter(({cmd:f})=>f.command.includes("onboard-hook")||f.command.includes("lesson-ready")),c=u.filter(f=>f.event==="Stop").length;p.length?t(`legacy two-entry Stop layout \u2014 run ${n.bold("devcoach install")} to merge into one stop-hook entry (fewer spawns per stop)`):c>1?t(`${c} devcoach Stop entries \u2014 interactions are counted ${c}\xD7 per stop; run ${n.bold("devcoach install")} to keep only the current one`):o$1(`Stop hook wired (${c} entry)`),u.some(f=>f.event==="UserPromptSubmit")?o$1("UserPromptSubmit priming hook wired"):t(`no UserPromptSubmit priming hook \u2014 run ${n.bold("devcoach install")} to add it (lessons land more reliably)`),ye(e,u,"devcoach install");}let l=R(ce);l==="current"?o$1("Claude Code skill installed (current version)"):s?o$1("Claude Code skill bundled with the plugin"):t(l==="outdated"?`Claude Code skill is out of date \u2014 run ${n.bold("devcoach install")}`:`Claude Code skill not installed \u2014 run ${n.bold("devcoach install")}`);let g=S(join(homedir(),".claude.json"));g.ok&&g.data.mcpServers?.devcoach?o$1("MCP server registered (user scope)"):t(`MCP server not found in ~/.claude.json \u2014 it may be registered elsewhere (check with ${n.bold("claude mcp get devcoach")})`);}if(existsSync(le)&&Po(e),existsSync(me)&&Go(e),m(n.bold(`
|
|
18
|
-
Database & pacing`)),!existsSync(i)){t(`no database yet (${i}) \u2014 onboarding runs on the first technical task`),m();return}try{o(s=>{o$1(`database opens (${i})`),M(s).knowledge_ready?o$1("onboarding complete"):t("onboarding not complete \u2014 the next stop cues it");let u=G(s);m(` settings: max_per_day=${u.max_per_day} \xB7 min_gap_minutes=${u.min_gap_minutes} \xB7 nudge_every=${u.nudge_every} \xB7 nudge_scope=${u.nudge_scope}`);let l=I(s),g=l.reduce((y,b)=>y+b.interactions,0);m(` pacing: ${l.length} session(s) counted, ${g} interaction(s) total`+(l[0]?` \u2014 latest ${l[0].session_id.slice(0,8)}\u2026 at ${l[0].interactions}`:""));let p=K$1(s);p.pending?t(`a cue is pending since ${p.last_cue_at} (retry threshold armed)`):p.last_skip_reason&&m(` last skip: "${p.last_skip_reason}"`);let c=_(s);c.allowed?o$1("rate limit: allowed"):t(`rate limit: ${c.reason}`),m(n.bold(`
|
|
19
|
-
Verdict`));let f=ga(s,l[0]?.session_id??null);f.wouldCue?o$1("the next eligible stop WOULD cue a lesson"):t("the next eligible stop would NOT cue a lesson:");for(let y of f.reasons)m(` \xB7 ${y}`);});}catch(s){r(`database check failed: ${s}`);}m();}var a=(e="")=>{console.log(e);},ko=e=>e==="junior"?n.green(e):e==="mid"?n.yellow(e):e==="senior"?n.red(e):e,Ko=e=>e==="know"?` ${n.green("\u2713")}`:e==="dont_know"?` ${n.red("\u2717")}`:"",Wo=e=>e==="know"?n.green("\u2713 I know this"):e==="dont_know"?n.red("\u2717 I don't know this"):n.dim("no feedback");function bo(e,o){let t=new Map;for(let i of e.groups)for(let d of i.topics)t.set(d,i.name);let r=[...e.knowledge].sort((i,d)=>d.confidence-i.confidence).map(i=>{let d=so(i.confidence);return [i.topic,t.get(i.topic)??"Other",te(d,`${i.confidence}/10`),te(d,io(i.confidence))]});return O(o,[{header:"Topic"},{header:"Group"},{header:"Confidence",justify:"right"},{header:"Bar"}],r)}function Jo(){let e=o(o=>$(o));a(bo(e,"Knowledge Map"));}function Vo(e){let o$1=o(s=>r(s,{period:e.period==="all"?null:e.period,category:e.category,level:e.level,project:e.project,repository:e.repository,branch:e.branch,commit:e.commit,starred:e.starred?true:null,imported:e.imported?true:null,feedback:e.feedback,date_from:e.dateFrom,date_to:e.dateTo,sort:e.sort,order:e.order}));if(o$1.length===0){a(n.dim("No lessons found."));return}let t=o$1.some(s=>s.project||s.branch||s.commit_hash),r$1=[{header:""},{header:"Date"},{header:"Topic"},{header:"Title"},{header:"Level",justify:"center"},{header:"Categories"}];t&&r$1.push({header:"Project"},{header:"Branch"},{header:"Commit"});let i=o$1.some(s=>s.imported);i&&r$1.push({header:"Shared by"});let d=o$1.map(s=>{let u=[s.starred?n.yellow("\u2605"):n.dim("\xB7"),s.timestamp.slice(0,10),n.cyan(s.topic_id),s.title+Ko(s.feedback),ko(s.level),s.categories.join(", ")];return t&&u.push(s.project??"",s.branch?n.magenta(s.branch):"",s.commit_hash?n.cyan(s.commit_hash.slice(0,7)):""),i&&u.push(s.imported?s.shared_by??n.dim("anonymous"):""),u});a(O("Lessons",r$1,d));}function Yo(e){let o$1=o(r=>x$1(r,e));o$1===null&&(a(n.red(`Lesson '${e}' not found.`)),process.exit(1)),a(K(n.bold(o$1.title))),a(`${n.dim("ID:")} ${o$1.id}`),a(`${n.dim("Date:")} ${o$1.timestamp.slice(0,19).replace("T"," ")}`),a(`${n.dim("Topic:")} ${o$1.topic_id}`),a(`${n.dim("Categories:")} ${o$1.categories.join(", ")}`),a(`${n.dim("Level:")} ${ko(o$1.level)}`);let t=o$1.starred?n.yellow("\u2605 starred"):n.dim("\u2606 not starred");if(a(`${n.dim("Star:")} ${t} ${n.dim("Feedback:")} ${Wo(o$1.feedback)}`),o$1.imported&&a(`${n.dim("Shared by:")} ${o$1.shared_by??n.dim("anonymous")}`),o$1.task_context&&a(`${n.dim("Context:")} ${o$1.task_context}`),o$1.project||o$1.repository||o$1.branch||o$1.commit_hash||o$1.folder){let r=[];o$1.project&&r.push(`project=${o$1.project}`),o$1.repository&&r.push(`repo=${o$1.repository}`),o$1.branch&&r.push(`branch=${n.magenta(o$1.branch)}`),o$1.commit_hash&&r.push(`commit=${n.cyan(o$1.commit_hash.slice(0,7))}`),o$1.folder&&r.push(`folder=${o$1.folder}`),a(`${n.dim("Git:")} ${r.join(" \xB7 ")}`);}a(K()),a(o$1.summary);}function fo(e,o$1){o(r=>x$1(r,e)===null?false:(t(r,e,o$1),true))||(a(n.red(`Lesson '${e}' not found.`)),process.exit(1)),a(o$1?`Lesson ${n.cyan(e)} \u2192 ${n.yellow("\u2605 starred")}`:`Lesson ${n.cyan(e)} \u2192 ${n.dim("\u2606 unstarred")}`);}function Xo(e){o(t=>s(t,e))||(a(n.red(`Lesson '${e}' not found.`)),process.exit(1)),a(`Lesson ${n.cyan(e)} deleted.`);}function Zo(e,o$1){["know","dont_know","clear"].includes(o$1)||(a(n.red(`Invalid feedback '${o$1}'. Use: know | dont_know | clear`)),process.exit(1));let t=o$1==="clear"?null:o$1,r=o(s=>{let u=ba(s,e,t);if(u===null)return null;let l=s.prepare("SELECT confidence FROM knowledge WHERE topic = ?").get(u);return {topicId:u,newConf:l?l.confidence:5}});r===null&&(a(n.red(`Lesson '${e}' not found.`)),process.exit(1));let i;if(t==="know"||t==="dont_know"){let s=r.newConf+(t==="know"?-1:1);i=`${n.cyan(r.topicId)} confidence: ${s} \u2192 ${n.bold(String(r.newConf))}`;}else i="feedback cleared";let d=t==="know"?n.green("\u2713 I know this"):t==="dont_know"?n.red("\u2717 I don't know this"):n.dim("cleared");a(`Lesson ${n.cyan(e)} \u2192 ${d} (${i})`);}function qo(){let e=o(i=>G(i)),o$1=Math.floor(e.min_gap_minutes/60),t=e.min_gap_minutes%60,r=o$1?`${o$1}h ${t}m`:`${t}m`;a(O("Settings",[{header:"Key"},{header:"Value",justify:"right"}],[["max_per_day",String(e.max_per_day)],["min_gap_minutes",`${e.min_gap_minutes} (${r})`],["nudge_every",e.nudge_every===0?"0 (off)":String(e.nudge_every)],["nudge_scope",e.nudge_scope],["share_name",e.share_name??n.dim("(unset \u2192 git user.name)")]]));}function Qo(){let{stats:e,rateLimit:o$1,settings:t}=o(l=>({stats:ca(l),rateLimit:_(l),settings:G(l)})),r=l=>Number(e[l]??0),i=o$1.allowed?n.green("Available now"):n.yellow(o$1.reason??"");a(O("Coaching Stats",[{header:"Metric"},{header:"Value",justify:"right"}],[["Total lessons",String(r("total_lessons"))],["Lessons today (24h)",`${r("lessons_today")} / ${t.max_per_day}`],["Lessons this week",String(r("lessons_this_week"))],["Next lesson",i]],false));let d=e.weakest_topics??[],s=e.strongest_topics??[];if(d.length||s.length){let l=[];for(let g=0;g<Math.max(d.length,s.length);g++){let p=d[g],c=s[g];l.push([p?`${n.red(p.topic)} ${n.dim(`(${p.confidence})`)}`:"",c?`${n.green(c.topic)} ${n.dim(`(${c.confidence})`)}`:""]);}a(O(void 0,[{header:"Weakest topics"},{header:"Strongest topics"}],l));}let u=ke();u&&a(`
|
|
20
|
-
${u}`);}function en(e,o$1){let t=["max_per_day","min_gap_minutes","nudge_every","nudge_scope","share_name"];if(t.includes(e)||(a(n.red(`Unknown key '${e}'. Valid keys: ${t.join(", ")}`)),process.exit(1)),e==="nudge_scope"&&o$1!=="session"&&o$1!=="global"&&(a(n.red(`Invalid nudge_scope '${o$1}'. Use: session | global`)),process.exit(1)),e==="share_name"){o$1.trim().length>l&&(a(n.red(`share_name must be at most ${l} characters.`)),process.exit(1));let r=m$1(o$1);o(i=>H(i,e,r)),a(r?n.green(`Set share_name = ${r}`):n.green("Cleared share_name"));return}if(e==="nudge_every"){let r=Number.parseInt(o$1,10);(!Number.isInteger(r)||r<0)&&(a(n.red(`Invalid nudge_every '${o$1}'. Use a non-negative integer (0 = off).`)),process.exit(1));}o(r=>H(r,e,o$1)),a(n.green(`Set ${e} = ${o$1}`));}function on(e,o$1,t){let r=e.trim();r||(a(n.red("Topic name must not be empty.")),process.exit(1)),o(d=>{A(d,r,o$1),t&&t!=="Other"&&E$1(d,r,t);});let i=t&&t!=="Other"?` \u2192 ${n.cyan(t)}`:"";a(`${n.green("Added")} ${n.bold(r)} (confidence ${n.cyan(String(o$1))})${i}`);}function nn(e){let o$1=o(t=>B(t,e));a(o$1?`${n.green("Removed")} ${n.bold(e)} from knowledge map`:n.yellow(`Topic '${e}' not found.`));}function tn(e){let o$1=e.trim();(!o$1||o$1==="Other")&&(a(n.red("Invalid group name.")),process.exit(1)),o(t=>C(t,o$1)),a(`${n.green(`Group '${n.cyan(o$1)}' ready.`)} Assign topics with: devcoach group-assign <topic> "${o$1}"`);}function rn(e){let o$1=o(t=>D(t,e));a(o$1?`${n.green(`Removed group '${n.cyan(e)}'`)}`:n.yellow(`Group '${e}' not found.`));}function sn(e,o$1){o(r=>r.prepare("SELECT topic FROM knowledge WHERE topic = ?").get(e)===void 0?false:(o$1==="Other"?F(r,e):E$1(r,e,o$1),true))||(a(n.red(`Topic '${e}' not in knowledge map. Add it first.`)),process.exit(1)),a(o$1==="Other"?`${n.green("Moved")} ${n.bold(e)} \u2192 Other (ungrouped)`:`${n.green("Moved")} ${n.bold(e)} \u2192 ${n.cyan(o$1)}`);}function an(e){let{lessonsCount:o$1,knowledgeCount:t,data:r}=o(d=>({lessonsCount:v$1(d).length,knowledgeCount:z$1(d).length,data:O$1(d)}));writeFileSync(e,r);let i=existsSync(j$1)?" + notebook":"";a(`${n.green("Backup saved:")} ${e} (${n.cyan(String(o$1))} lessons, ${n.cyan(String(t))} topics${i})`);}function dn(e){existsSync(e)||(a(n.red(`File not found: ${e}`)),process.exit(1));let o$1=o(r=>P(r,readFileSync(e)));o$1.settings&&a(`${n.green("\u2713")} Settings restored`),o$1.topics&&a(`${n.green("\u2713")} Knowledge map restored (${n.cyan(String(o$1.topics))} topics)`);let t=[`${n.cyan(String(o$1.lessons))} imported`];o$1.skipped&&t.push(`${n.yellow(String(o$1.skipped))} duplicates skipped`),o$1.invalid&&t.push(`${n.red(String(o$1.invalid))} rejected (invalid)`),a(`${n.green("\u2713")} Lessons: ${t.join(", ")}`),o$1.learning_state&&a(`${n.green("\u2713")} Notebook restored`);}var V=e=>{console.error(n.dim(e));};function cn(e,o$1){o$1.by!==void 0&&o$1.anonymous&&(a(n.red("Use either --by <name> or --anonymous, not both.")),process.exit(1)),!e&&!o$1.last&&(a(n.red("Give a lesson id, or --last for the most recent one.")),process.exit(2));let t=o(d=>{let s=o$1.last?r(d,{imported:false,page:1,per_page:1})[0]??null:x$1(d,e);if(!s)return null;let u=G(d),l=T$1({explicit:o$1.by??null,anonymous:o$1.anonymous,setting:u.share_name,gitUserName:a$1()}),g=false;return o$1.by?.trim()&&!u.share_name&&(H(d,"share_name",m$1(o$1.by)),g=true),{payload:S$1(s,{includeContext:!!o$1.withContext,sharedBy:l}),remembered:g}});t||(a(n.red(o$1.last?"No lessons to share yet.":`Lesson '${e}' not found.`)),process.exit(1));let{payload:r$1,remembered:i}=t;if(o$1.file!==void 0&&o$1.file!==false){let d=typeof o$1.file=="string"?o$1.file:Y(r$1);writeFileSync(d,Z(r$1)),a(`${n.green("Saved:")} ${d}`);}else o$1.link?a(X(r$1)):(a(W(r$1)),U(r$1).length>16e3&&V("Long lesson \u2014 prefer --file for a friendlier hand-off."));i&&V("(remembered as share_name \u2014 change it with: devcoach set share_name <name>)"),r$1.shared_by===null&&V("Shared anonymously (set a name with: devcoach set share_name <name>)");}function ln(){let e=process.platform==="darwin"?[["pbpaste",[]]]:process.platform==="win32"?[["powershell",["-NoProfile","-Command","Get-Clipboard"]]]:[["wl-paste",["--no-newline"]],["xclip",["-selection","clipboard","-o"]],["xsel",["--clipboard","--output"]]];for(let[o,t]of e)try{let r=execFileSync(o,t,{encoding:"utf8",timeout:3e3,stdio:["ignore","pipe","ignore"]});if(r.trim())return r}catch{}throw new R$1("Clipboard is empty or unavailable \u2014 pass the code, a link or a file, or pipe it: devcoach import -")}async function mn(e){return e===void 0?ln():e==="-"?text(process.stdin):existsSync(e)?readFileSync(e,"utf8"):c$1(e)&&!e.includes("#devcoach:lesson:")?d$1(e):e}async function un(e){try{let o$1=await mn(e),t=o(d=>da(d,o$1));if(t.kind==="lessons"){let d=[`${n.cyan(String(t.inserted))} imported`];t.duplicated&&d.push(`${n.yellow(String(t.duplicated))} duplicates skipped`),t.invalid&&d.push(`${n.red(String(t.invalid))} rejected (invalid)`),a(`${n.green("\u2713")} Lessons: ${d.join(", ")}`);return}let r=t.lesson;r||(a(n.red("Could not store the lesson.")),process.exit(1));let i=r.shared_by?`shared by ${r.shared_by}`:"shared anonymously";t.duplicated?a(`${n.yellow("Already in your log")} as ${n.cyan(r.id)} (${i})`):a(`${n.green("\u2713 Imported")} ${n.bold(`"${r.title}"`)} (${i}) as ${n.cyan(r.id)} \u2014 topic ${n.cyan(r.topic_id)}`),t.topic_tracked===!1&&V(`Topic '${r.topic_id}' is not in your knowledge map \u2014 track it with: devcoach knowledge-add ${r.topic_id}`);}catch(o){if(!(o instanceof R$1))throw o;a(n.red(o.message)),process.exit(1);}}async function pn(){let e=createInterface({input:process.stdin,output:process.stdout}),o$1=async(r,i="")=>{let d=i?` [${i}]`:"";return (await e.question(`${r}${d}: `)).trim()||i},t=async(r,i,d,s)=>{for(;;){let u=await o$1(r,String(i)),l=Number.parseInt(u,10);if(!Number.isNaN(l)&&l>=d&&l<=s)return l;a(n.red(`Must be ${d}\u2013${s}.`));}};try{a(K(n.bold("devcoach setup"))),a(`
|
|
21
|
-
${n.bold("Step 1")} \u2014 Restore from backup`);let r=await o$1("Path to existing backup zip (Enter to skip)","");if(r){existsSync(r)||(a(n.red(`File not found: ${r}`)),process.exit(1));let p=o(c=>P(c,readFileSync(r)));a(`${n.green("\u2713")} Restored: ${p.topics} topics, ${p.lessons} lessons${p.learning_state?", notebook":""}`),a(n.green("Setup complete!"));return}a(`
|
|
22
|
-
${n.bold("Step 2")} \u2014 Build your knowledge profile`);let i=(await o$1("Mode: [a]utomatic (detect from files) / [m]anual (type your stack)","a")).toLowerCase(),d={};if(i.startsWith("a")){let c$1=b$1().folder??process.cwd(),f=c(),y=b$2(a$2(c$1),f.detected_stack),b=Object.keys(y).sort(($,L)=>$.localeCompare(L));if(f.scanned_projects>0){a(`
|
|
23
|
-
${n.dim(`Scanned ${f.scanned_projects} Claude Code project(s) from your history:`)}`);for(let $ of f.projects.slice(0,8))a(n.dim(` ${$.name} \u2014 ${$.topics.join(", ")||"no stack signals"}`));}if(b.length){a(`
|
|
24
|
-
${n.dim(`Detected (history + ${n.cyan(c$1)}):`)}`);for(let $ of b){let L=y[$]??5,we=await o$1(` ${n.cyan($)} (Enter=keep, 0-10=override, s=skip)`,String(L));if(we.toLowerCase()==="s")continue;let ve=Number.parseInt(we,10);d[$]=Number.isNaN(ve)?L:Math.max(0,Math.min(10,ve));}}else a(n.dim("No technology files detected in current directory."));let A=await o$1(`
|
|
25
|
-
Add additional topics (comma-separated, or Enter to skip)`,"");for(let $ of A.split(",").map(L=>L.trim()).filter(Boolean))d[$]=await t(` Confidence for ${n.cyan($)}`,5,0,10);}else for(a(n.dim(`
|
|
26
|
-
Enter topics: 'topic_id confidence' (e.g. python 7). Blank line when done.`));;){let p=(await o$1("Topic (Enter when done)","")).trim();if(!p)break;let c=p.split(/\s+/),f=c[0]??"",y=Number.parseInt(c[1]??"",10),b=Number.isNaN(y)?5:Math.max(0,Math.min(10,y));d[f]=b,a(` ${n.green("+")} ${n.cyan(f)} \u2192 ${b}`);}let s={};if(Object.keys(d).length&&(a(`
|
|
27
|
-
${n.bold("Step 3")} \u2014 Organise into groups`),(await o$1("Organise topics into groups? [y/N]","n")).toLowerCase().startsWith("y"))){let c=[];for(let f of Object.keys(d).sort((y,b)=>y.localeCompare(b))){let y=c.length?c.join(", "):"(none yet)",b=await o$1(` Group for ${n.cyan(f)} existing: ${n.dim(y)} (Enter=Other)`,"");if(b&&b!=="Other"){let A=s[b]??[];A.push(f),s[b]=A,c.includes(b)||c.push(b);}}}a(`
|
|
28
|
-
${n.bold("Step 4")} \u2014 Rate-limit settings`);let u=await t("Max lessons per day",2,1,20),l=await t("Min gap between lessons (minutes)",240,0,1440),g=o(p=>{p.exec("DELETE FROM knowledge; DELETE FROM knowledge_groups; DELETE FROM knowledge_group_names;");for(let[c,f]of Object.entries(d))A(p,c,f);for(let[c,f]of Object.entries(s))for(let y of f)E$1(p,y,c);return H(p,"max_per_day",String(u)),H(p,"min_gap_minutes",String(l)),$(p)});a(bo(g,"Knowledge Profile")),a(`
|
|
29
|
-
${n.green("Setup complete!")} ${Object.keys(d).length} topics saved.`);}finally{e.close();}}function gn(){let e=[["mcp","Start the MCP server (stdio) for Claude Code / Claude Desktop"],["ui [--port N]","Launch the web dashboard (default port: 7860)"],["setup","First-run wizard: import backup or build your knowledge profile"],["install","Register MCP server + hooks + skill (Claude default; --gemini/--codex beta)"],["onboard-hook","Claude Code Stop hook: cue onboarding when no profile exists"],["lesson-ready","Claude Code Stop hook: cue a lesson when one is due"],["doctor","Diagnose the agent wiring \u2014 explains why a lesson would(n't) fire"],["profile","Show the knowledge map"],["stats","Coaching statistics and rate-limit status"],["settings / set","Show / update settings (max_per_day | min_gap_minutes)"],["lessons / lesson","List past lessons / show one in detail"],["star / unstar / delete","Manage a lesson"],["feedback <id>","Record know / dont_know feedback"],["share / import","Hand a lesson to a teammate / add a shared lesson to your log"],["knowledge-add / -remove","Add / remove a topic"],["group-add / -remove / -assign","Manage knowledge groups"],["backup / restore","Export / import a full backup zip"]];a(`
|
|
30
|
-
${n.bold(`devcoach ${n.dim(`v${Q}`)}`)}`);for(let[t,r]of e)a(` ${n.cyan(`devcoach ${t}`.padEnd(32))} ${n.dim(r)}`);a(`
|
|
31
|
-
${n.dim("Run")} ${n.bold("devcoach <command> --help")} ${n.dim("for per-command options.")}
|
|
32
|
-
`);let o=ke();o&&a(`${o}
|
|
33
|
-
`);}function v(e){return e??null}function fn(){let e$1=new Command;return e$1.exitOverride(),e$1.name("devcoach").description("devcoach \u2014 progressive technical coaching").version(`devcoach ${Q}`,"-v, --version","output the version number").allowExcessArguments(false).showHelpAfterError("(add --help for usage)").action(()=>gn()),e$1.command("mcp").description("Start the MCP server (stdio transport)").action(async()=>{let{runStdio:o}=await import('./server-O4OBRKIQ.js');await o();}),e$1.command("profile").description("Show the knowledge map").action(Jo),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=>Vo({period:o.period??"all",category:v(o.category),project:v(o.project),repository:v(o.repository),branch:v(o.branch),commit:v(o.commit),starred:!!o.starred,imported:!!o.imported,feedback:v(o.feedback),level:v(o.level),dateFrom:v(o.dateFrom),dateTo:v(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=>Yo(o)),e$1.command("star").description("Mark a lesson as starred").argument("<id>","Lesson ID").action(o=>fo(o,true)),e$1.command("unstar").description("Remove the starred mark from a lesson").argument("<id>","Lesson ID").action(o=>fo(o,false)),e$1.command("delete").description("Permanently delete a lesson").argument("<id>","Lesson ID").action(o=>Xo(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)=>Zo(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)=>cn(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=>un(o)),e$1.command("settings").description("Show current settings").action(qo),e$1.command("stats").description("Coaching statistics and rate-limit status").action(Qo),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)=>en(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)=>on(o,Math.max(0,Math.min(10,Number.parseInt(t.confidence??"5",10)||5)),v(t.group))),e$1.command("knowledge-remove").description("Remove a topic from the knowledge map").argument("<topic>","Topic ID").action(o=>nn(o)),e$1.command("group-add").description("Register a new knowledge group").argument("<name>","Group name").action(o=>tn(o)),e$1.command("group-remove").description("Delete a knowledge group (topics move to Other)").argument("<name>","Group name").action(o=>rn(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)=>sn(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=>an(o)),e$1.command("restore").description("Restore from a backup zip file").argument("<file>","Path to backup zip").action(o=>dn(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=>po({claudeCode:!!o.claudeCode,claudeDesktop:!!o.claudeDesktop,gemini:!!o.gemini,codex:!!o.codex,force:!!o.force,skipHook:!!o.skipHook})),e$1.command("doctor").description("Diagnose the devcoach \u21C4 agent wiring and the lesson pacing state").action(go),e$1.command("ui").description("Launch the web dashboard").option("--port <port>","Port","7860").action(async o=>{let{startUi:t}=await import('./app-OQMXB6MX.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(pn),e$1.command("stop-hook",{hidden:true}).description("Claude Code Stop hook: onboarding check + lesson cue in one spawn").action(()=>e()),e$1.command("prompt-hook",{hidden:true}).description("Claude Code UserPromptSubmit hook: prime the model when a lesson is due").action(()=>g()),e$1.command("gemini-stop-hook",{hidden:true}).description("Gemini CLI AfterAgent hook: onboarding check + lesson cue in one spawn").action(()=>e(void 0,"gemini")),e$1.command("gemini-prompt-hook",{hidden:true}).description("Gemini CLI BeforeAgent hook: prime the model when a lesson is due").action(()=>g(void 0,"gemini")),e$1.command("codex-stop-hook",{hidden:true}).description("Codex CLI Stop hook: onboarding check + lesson cue in one spawn").action(()=>e(void 0,"codex")),e$1.command("codex-prompt-hook",{hidden:true}).description("Codex CLI UserPromptSubmit hook: prime the model when a lesson is due").action(()=>g(void 0,"codex")),e$1.command("onboard-hook",{hidden:true}).description("Claude Code Stop hook: cue onboarding (legacy two-entry layout)").action(()=>b()),e$1.command("lesson-ready",{hidden:true}).description("Claude Code Stop hook: signal a lesson is due (legacy two-entry layout)").action(()=>d()),e$1}async function Gn(){let e=fn();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{Gn as runCli};
|