devcoach 0.8.3 → 0.9.1

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.
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
- import {e as e$1,f,b,d}from'./chunk-JTR6RJFB.js';export{c as buildLessonCue,d as cmdLessonReady,b as cmdOnboardHook,f as cmdPromptHook,e as cmdStopHook,a as parseHookPayload}from'./chunk-JTR6RJFB.js';import {e,b as b$1,a,c,d as d$1}from'./chunk-NVEMYNQQ.js';import {m,S,p,w as w$1,r,q,U as U$1,F,R as R$1,V,G,z,D,A,B,C,E,P,y,t as t$1,j,Q,i,N as N$1,H,J,Y}from'./chunk-227BHE2B.js';import {spawnSync}from'child_process';import {writeFileSync,existsSync,readFileSync,mkdirSync,accessSync,constants}from'fs';import {homedir,platform}from'os';import {join,dirname}from'path';import {createInterface}from'readline/promises';import {Command}from'commander';import {styleText}from'util';var He=!!process.stdout.isTTY&&!process.env.NO_COLOR,w=(e,o)=>He?styleText(e,o):o,t={green:e=>w("green",e),red:e=>w("red",e),yellow:e=>w("yellow",e),cyan:e=>w("cyan",e),magenta:e=>w("magenta",e),dim:e=>w("dim",e),bold:e=>w("bold",e)};function K(e,o){return e==="green"?t.green(o):e==="yellow"?t.yellow(o):t.red(o)}var Ae=/\[[0-9;]*m/g,Fe=e=>e.replace(Ae,""),R=e=>[...Fe(e)].length;function $e(e,o,n){let r=Math.max(0,o-R(e));if(n==="right")return " ".repeat(r)+e;if(n==="center"){let a=Math.floor(r/2);return " ".repeat(a)+e+" ".repeat(r-a)}return e+" ".repeat(r)}function L(e,o,n,r=true){let a=o.map((p,d)=>Math.max(r?R(p.header):0,...n.map(c=>R(c[d]??"")))),i=(p,d,c)=>p+a.map(g=>"\u2500".repeat(g+2)).join(d)+c,l=p=>`\u2502${p.map((d,c)=>` ${$e(d??"",a[c]??0,o[c]?.justify??"left")} `).join("\u2502")}\u2502`,m=a.reduce((p,d)=>p+d+3,1),u=[];e&&u.push($e(t.bold(e),m,"center")),u.push(i("\u256D","\u252C","\u256E")),r&&u.push(l(o.map(p=>t.bold(p.header))),i("\u251C","\u253C","\u2524"));for(let p of n)u.push(l(p));return u.push(i("\u2570","\u2534","\u256F")),u.join(`
3
- `)}function N(e=""){if(!e)return "\u2500".repeat(60);let n=` ${e} `,r=Math.max(2,60-R(n)),a=Math.floor(r/2);return "\u2500".repeat(a)+n+"\u2500".repeat(r-a)}var we=e=>{let o=Math.max(0,Math.min(10,Math.round(e)));return "\u2588".repeat(o)+"\u2591".repeat(10-o)},ve=e=>e>=7?"green":e>=4?"yellow":"red";var s=(e="")=>{console.log(e);},Le=e=>e==="junior"?t.green(e):e==="mid"?t.yellow(e):e==="senior"?t.red(e):e,We=e=>e==="know"?` ${t.green("\u2713")}`:e==="dont_know"?` ${t.red("\u2717")}`:"",Je=e=>e==="know"?t.green("\u2713 I know this"):e==="dont_know"?t.red("\u2717 I don't know this"):t.dim("no feedback");function Te(e,o){let n=new Map;for(let a of e.groups)for(let i of a.topics)n.set(i,a.name);let r=[...e.knowledge].sort((a,i)=>i.confidence-a.confidence).map(a=>{let i=ve(a.confidence);return [a.topic,n.get(a.topic)??"Other",K(i,`${a.confidence}/10`),K(i,we(a.confidence))]});return L(o,[{header:"Topic"},{header:"Group"},{header:"Confidence",justify:"right"},{header:"Bar"}],r)}function Ye(){let e=m(o=>S(o));s(Te(e,"Knowledge Map"));}function Ve(e){let o=m(i=>p(i,{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,feedback:e.feedback,date_from:e.dateFrom,date_to:e.dateTo,sort:e.sort,order:e.order}));if(o.length===0){s(t.dim("No lessons found."));return}let n=o.some(i=>i.project||i.branch||i.commit_hash),r=[{header:""},{header:"Date"},{header:"Topic"},{header:"Title"},{header:"Level",justify:"center"},{header:"Categories"}];n&&r.push({header:"Project"},{header:"Branch"},{header:"Commit"});let a=o.map(i=>{let l=[i.starred?t.yellow("\u2605"):t.dim("\xB7"),i.timestamp.slice(0,10),t.cyan(i.topic_id),i.title+We(i.feedback),Le(i.level),i.categories.join(", ")];return n&&l.push(i.project??"",i.branch?t.magenta(i.branch):"",i.commit_hash?t.cyan(i.commit_hash.slice(0,7)):""),l});s(L("Lessons",r,a));}function Ze(e){let o=m(r=>w$1(r,e));o===null&&(s(t.red(`Lesson '${e}' not found.`)),process.exit(1)),s(N(t.bold(o.title))),s(`${t.dim("ID:")} ${o.id}`),s(`${t.dim("Date:")} ${o.timestamp.slice(0,19).replace("T"," ")}`),s(`${t.dim("Topic:")} ${o.topic_id}`),s(`${t.dim("Categories:")} ${o.categories.join(", ")}`),s(`${t.dim("Level:")} ${Le(o.level)}`);let n=o.starred?t.yellow("\u2605 starred"):t.dim("\u2606 not starred");if(s(`${t.dim("Star:")} ${n} ${t.dim("Feedback:")} ${Je(o.feedback)}`),o.task_context&&s(`${t.dim("Context:")} ${o.task_context}`),o.project||o.repository||o.branch||o.commit_hash||o.folder){let r=[];o.project&&r.push(`project=${o.project}`),o.repository&&r.push(`repo=${o.repository}`),o.branch&&r.push(`branch=${t.magenta(o.branch)}`),o.commit_hash&&r.push(`commit=${t.cyan(o.commit_hash.slice(0,7))}`),o.folder&&r.push(`folder=${o.folder}`),s(`${t.dim("Git:")} ${r.join(" \xB7 ")}`);}s(N()),s(o.summary);}function Se(e,o){m(r$1=>w$1(r$1,e)===null?false:(r(r$1,e,o),true))||(s(t.red(`Lesson '${e}' not found.`)),process.exit(1)),s(o?`Lesson ${t.cyan(e)} \u2192 ${t.yellow("\u2605 starred")}`:`Lesson ${t.cyan(e)} \u2192 ${t.dim("\u2606 unstarred")}`);}function qe(e){m(n=>q(n,e))||(s(t.red(`Lesson '${e}' not found.`)),process.exit(1)),s(`Lesson ${t.cyan(e)} deleted.`);}function Xe(e,o){["know","dont_know","clear"].includes(o)||(s(t.red(`Invalid feedback '${o}'. Use: know | dont_know | clear`)),process.exit(1));let n=o==="clear"?null:o,r=m(l=>{let m=U$1(l,e,n);if(m===null)return null;let u=l.prepare("SELECT confidence FROM knowledge WHERE topic = ?").get(m);return {topicId:m,newConf:u?u.confidence:5}});r===null&&(s(t.red(`Lesson '${e}' not found.`)),process.exit(1));let a;if(n==="know"||n==="dont_know"){let l=r.newConf+(n==="know"?-1:1);a=`${t.cyan(r.topicId)} confidence: ${l} \u2192 ${t.bold(String(r.newConf))}`;}else a="feedback cleared";let i=n==="know"?t.green("\u2713 I know this"):n==="dont_know"?t.red("\u2717 I don't know this"):t.dim("cleared");s(`Lesson ${t.cyan(e)} \u2192 ${i} (${a})`);}function Qe(){let e=m(a=>F(a)),o=Math.floor(e.min_gap_minutes/60),n=e.min_gap_minutes%60,r=o?`${o}h ${n}m`:`${n}m`;s(L("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]]));}function eo(){let{stats:e,rateLimit:o,settings:n}=m(u=>({stats:V(u),rateLimit:R$1(u),settings:F(u)})),r=u=>Number(e[u]??0),a=o.allowed?t.green("Available now"):t.yellow(o.reason??"");s(L("Coaching Stats",[{header:"Metric"},{header:"Value",justify:"right"}],[["Total lessons",String(r("total_lessons"))],["Lessons today (24h)",`${r("lessons_today")} / ${n.max_per_day}`],["Lessons this week",String(r("lessons_this_week"))],["Next lesson",a]],false));let i=e.weakest_topics??[],l=e.strongest_topics??[];if(i.length||l.length){let u=[];for(let p=0;p<Math.max(i.length,l.length);p++){let d=i[p],c=l[p];u.push([d?`${t.red(d.topic)} ${t.dim(`(${d.confidence})`)}`:"",c?`${t.green(c.topic)} ${t.dim(`(${c.confidence})`)}`:""]);}s(L(void 0,[{header:"Weakest topics"},{header:"Strongest topics"}],u));}let m$1=Ie();m$1&&s(`
4
- ${m$1}`);}function oo(e,o){let n=["max_per_day","min_gap_minutes","nudge_every","nudge_scope"];if(n.includes(e)||(s(t.red(`Unknown key '${e}'. Valid keys: ${n.join(", ")}`)),process.exit(1)),e==="nudge_scope"&&o!=="session"&&o!=="global"&&(s(t.red(`Invalid nudge_scope '${o}'. Use: session | global`)),process.exit(1)),e==="nudge_every"){let r=Number.parseInt(o,10);(!Number.isInteger(r)||r<0)&&(s(t.red(`Invalid nudge_every '${o}'. Use a non-negative integer (0 = off).`)),process.exit(1));}m(r=>G(r,e,o)),s(t.green(`Set ${e} = ${o}`));}function to(e,o,n){let r=e.trim();r||(s(t.red("Topic name must not be empty.")),process.exit(1)),m(i=>{z(i,r,o),n&&n!=="Other"&&D(i,r,n);});let a=n&&n!=="Other"?` \u2192 ${t.cyan(n)}`:"";s(`${t.green("Added")} ${t.bold(r)} (confidence ${t.cyan(String(o))})${a}`);}function no(e){let o=m(n=>A(n,e));s(o?`${t.green("Removed")} ${t.bold(e)} from knowledge map`:t.yellow(`Topic '${e}' not found.`));}function ro(e){let o=e.trim();(!o||o==="Other")&&(s(t.red("Invalid group name.")),process.exit(1)),m(n=>B(n,o)),s(`${t.green(`Group '${t.cyan(o)}' ready.`)} Assign topics with: devcoach group-assign <topic> "${o}"`);}function so(e){let o=m(n=>C(n,e));s(o?`${t.green(`Removed group '${t.cyan(e)}'`)}`:t.yellow(`Group '${e}' not found.`));}function io(e,o){m(r=>r.prepare("SELECT topic FROM knowledge WHERE topic = ?").get(e)===void 0?false:(o==="Other"?E(r,e):D(r,e,o),true))||(s(t.red(`Topic '${e}' not in knowledge map. Add it first.`)),process.exit(1)),s(o==="Other"?`${t.green("Moved")} ${t.bold(e)} \u2192 Other (ungrouped)`:`${t.green("Moved")} ${t.bold(e)} \u2192 ${t.cyan(o)}`);}function ao(e){let{lessonsCount:o,knowledgeCount:n,data:r}=m(i=>({lessonsCount:t$1(i).length,knowledgeCount:y(i).length,data:P(i)}));writeFileSync(e,r);let a=existsSync(j)?" + notebook":"";s(`${t.green("Backup saved:")} ${e} (${t.cyan(String(o))} lessons, ${t.cyan(String(n))} topics${a})`);}function co(e){existsSync(e)||(s(t.red(`File not found: ${e}`)),process.exit(1));let o=m(r=>Q(r,readFileSync(e)));o.settings&&s(`${t.green("\u2713")} Settings restored`),o.topics&&s(`${t.green("\u2713")} Knowledge map restored (${t.cyan(String(o.topics))} topics)`);let n=[`${t.cyan(String(o.lessons))} imported`];o.skipped&&n.push(`${t.yellow(String(o.skipped))} duplicates skipped`),o.invalid&&n.push(`${t.red(String(o.invalid))} rejected (invalid)`),s(`${t.green("\u2713")} Lessons: ${n.join(", ")}`),o.learning_state&&s(`${t.green("\u2713")} Notebook restored`);}function lo(){let e=platform();if(e==="darwin")return join(homedir(),"Library","Application Support","Claude","claude_desktop_config.json");if(e==="win32"){let n=process.env.APPDATA??join(homedir(),"AppData","Roaming");return join(n,"Claude","claude_desktop_config.json")}let o=process.env.XDG_CONFIG_HOME??join(homedir(),".config");return join(o,"Claude","claude_desktop_config.json")}var M=join(homedir(),".claude","settings.json"),v=join(homedir(),".claude","skills","devcoach"),Me=join(v,".devcoach-version");function Oe(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 je=e=>Oe(e)!==null;function De(){return je("devcoach")?{command:"devcoach",args:["mcp"]}:{command:"npx",args:["-y","devcoach","mcp"]}}function uo(){let e=Oe("devcoach");return e?e.includes("fnm_multishells")?"devcoach":e:"npx -y devcoach"}function po(e,o){if(!je("claude"))return "";o&&spawnSync("claude",["mcp","remove","--scope",e,"devcoach"],{encoding:"utf8"});let n=De(),r=spawnSync("claude",["mcp","add","--scope",e,"devcoach",n.command,"--",...n.args],{encoding:"utf8"});return r.status===0?`${t.green("\u2713")} Registered via \`claude mcp add\` (scope: ${e})`:`${r.stderr??""}${r.stdout??""}`.toLowerCase().includes("already")?`${t.yellow("Already registered")} in Claude Code (use --force to overwrite)`:`${t.red("claude mcp add failed:")} ${(r.stderr||r.stdout||"").trim()}`}function O(e){if(!existsSync(e))return {ok:true,data:{}};try{return {ok:!0,data:JSON.parse(readFileSync(e,"utf8"))??{}}}catch{return {ok:false,error:`${t.red("\u2717")} ${e} is not valid JSON \u2014 fix it and re-run (left unchanged)`}}}function _e(e,o,n){let r=O(e);if(!r.ok)return r.error;let a=r.data;a.mcpServers??={};let i=a.mcpServers;return i.devcoach&&!n?`${t.yellow("Already registered")} in ${e} (use --force to overwrite)`:(i.devcoach=o,mkdirSync(dirname(e),{recursive:true}),writeFileSync(e,`${JSON.stringify(a,null,2)}
5
- `),`${t.green("\u2713")} Installed into ${e}`)}function mo(){let e=uo();return {Stop:{hooks:[{type:"command",command:`${e} stop-hook`,timeout:60}]},UserPromptSubmit:{hooks:[{type:"command",command:`${e} prompt-hook`,timeout:30}]}}}function Pe(e){return Object.entries(e.enabledPlugins??{}).some(([o,n])=>n&&o.startsWith("devcoach@"))}function U(e){return /dev-?coach/i.test(e)&&/\b(?:stop-hook|prompt-hook|onboard-hook|lesson-ready)\b/.test(e)}function go(){let e=M,o=O(e);if(!o.ok)return o.error;let n=o.data;if(Pe(n))return `${t.yellow("Skipped")} \u2014 the devcoach plugin already provides the hooks (installing both would double-count interactions)`;n.hooks??={};let r=n.hooks,a=false;for(let[i,l]of Object.entries(mo())){r[i]??=[];let m=r[i],u=m.map((d,c)=>[d,c]).filter(([d])=>(d.hooks??[]).some(c=>U(c.command??""))).map(([,d])=>d),[p]=u;if(!(u.length===1&&p!==void 0&&JSON.stringify(m[p])===JSON.stringify(l))){for(let d of u.toReversed())m.splice(d,1);m.push(l),a=true;}}return a?(mkdirSync(dirname(e),{recursive:true}),writeFileSync(e,`${JSON.stringify(n,null,2)}
6
- `),`${t.green("\u2713")} Hooks installed into ${e} (Stop + UserPromptSubmit)`):`${t.yellow("Already installed")} in ${e} (current layout)`}function W(){if(!existsSync(join(v,"SKILL.md")))return "missing";try{if(readFileSync(Me,"utf8").trim()===e)return "current"}catch{}return "outdated"}function fo(e$1){if(!e$1&&W()==="current")return `${t.yellow("Already installed")} in ${v} (current version)`;mkdirSync(v,{recursive:true}),writeFileSync(join(v,"SKILL.md"),c());let o=d$1();if(o.length){let n=join(v,"references");mkdirSync(n,{recursive:true});for(let r of o)writeFileSync(join(n,r.name),r.content);}return writeFileSync(Me,`${e}
7
- `),`${t.green("\u2713")} Installed into ${v}`}function Ie(){let e=W();if(e==="outdated")return `${t.yellow("\u2192")} The devcoach Claude Code skill is out of date \u2014 run ${t.bold("devcoach install")} to refresh it.`;if(e==="missing"){let o=O(M);if(o.ok&&(o.data.hooks?.Stop??[]).some(r=>(r.hooks??[]).some(a=>U(a.command??""))))return `${t.yellow("\u2192")} The devcoach Claude Code skill is not installed \u2014 run ${t.bold("devcoach install")} to add it.`}return ""}function ho(e){let o=e.claudeCode||!e.claudeDesktop,n=e.claudeDesktop||!e.claudeCode,r=De(),a=false;if(s(t.bold("Setting up devcoach")+t.dim(` (${r.command} ${r.args.join(" ")})`)),s(),o){s(t.bold("Claude Code"));let i=po("user",e.force);if(!i){let l=join(homedir(),".claude.json");i=_e(l,{type:"stdio",env:{},...r},e.force),a=true;}s(` MCP server\u2026 ${i}`),e.skipHook||s(` Hooks\u2026 ${go()}`),s(` Skill\u2026 ${fo(e.force)}`),s();}n&&(s(t.bold("Claude Desktop")),s(` MCP server\u2026 ${_e(lo(),r,e.force)}`),a=true,s()),a&&s(`${t.yellow("\u2192")} Restart Claude Desktop to pick up the new server.
8
- `),s(t.dim(`Tip: run devcoach backup to export your profile, lessons and settings.
9
- run devcoach restore <file> to import a backup on a new machine.
10
- After upgrading devcoach (npm, Homebrew), re-run devcoach install to refresh the skill.`));}function bo(){let e$1=i=>s(` ${t.green("\u2713")} ${i}`),o=i=>s(` ${t.yellow("\u2192")} ${i}`),n=i=>s(` ${t.red("\u2717")} ${i}`);s(`
11
- ${t.bold("devcoach doctor")} ${t.dim(`v${e}`)}
12
- `),s(t.bold("Environment")),Number.parseInt(process.versions.node.split(".")[0]??"0",10)>=24?e$1(`Node ${process.versions.node} (\u2265 24)`):n(`Node ${process.versions.node} \u2014 devcoach needs Node \u2265 24 (embedded node:sqlite)`),s(t.bold(`
13
- Claude Code wiring`));let a=O(M);if(!a.ok)n(`${M} is not valid JSON \u2014 hooks cannot run`);else {let i=Pe(a.data),l=[];for(let[p,d]of Object.entries(a.data.hooks??{}))for(let c of d??[])for(let g of c.hooks??[])U(g.command??"")&&l.push({event:p,cmd:g});if(i&&l.length)n("devcoach hooks are registered TWICE (plugin + settings.json) \u2014 interactions are double-counted. Disable the plugin or remove the settings.json entries.");else if(i)e$1("hooks provided by the devcoach plugin");else if(!l.length)n(`no devcoach hooks in ${M} \u2014 run ${t.bold("devcoach install")}`);else {let p=l.filter(({cmd:c})=>c.command.includes("onboard-hook")||c.command.includes("lesson-ready")),d=l.filter(c=>c.event==="Stop").length;p.length?o(`legacy two-entry Stop layout \u2014 run ${t.bold("devcoach install")} to merge into one stop-hook entry (fewer spawns per stop)`):d>1?o(`${d} devcoach Stop entries \u2014 interactions are counted ${d}\xD7 per stop; run ${t.bold("devcoach install")} to keep only the current one`):e$1(`Stop hook wired (${d} entry)`),l.some(c=>c.event==="UserPromptSubmit")?e$1("UserPromptSubmit priming hook wired"):o(`no UserPromptSubmit priming hook \u2014 run ${t.bold("devcoach install")} to add it (lessons land more reliably)`);for(let{cmd:c}of l){let g=c.command.split(" ")[0]??"";g.startsWith("/")&&!existsSync(g)&&n(`hook command not found: ${g} \u2014 re-run ${t.bold("devcoach install")}`),c.command.startsWith("npx ")&&o("hook runs via npx \u2014 needs the npx cache (or network) on every stop"),c.timeout==null&&o(`hook entry has no timeout (${c.command})`);}}let m=W();m==="current"?e$1("Claude Code skill installed (current version)"):i?e$1("Claude Code skill bundled with the plugin"):o(m==="outdated"?`Claude Code skill is out of date \u2014 run ${t.bold("devcoach install")}`:`Claude Code skill not installed \u2014 run ${t.bold("devcoach install")}`);let u=O(join(homedir(),".claude.json"));u.ok&&u.data.mcpServers?.devcoach?e$1("MCP server registered (user scope)"):o(`MCP server not found in ~/.claude.json \u2014 it may be registered elsewhere (check with ${t.bold("claude mcp get devcoach")})`);}if(s(t.bold(`
14
- Database & pacing`)),!existsSync(i)){o(`no database yet (${i}) \u2014 onboarding runs on the first technical task`),s();return}try{m(i$1=>{e$1(`database opens (${i})`),N$1(i$1).knowledge_ready?e$1("onboarding complete"):o("onboarding not complete \u2014 the next stop cues it");let l=F(i$1);s(` 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=H(i$1),u=m.reduce((g,b)=>g+b.interactions,0);s(` pacing: ${m.length} session(s) counted, ${u} interaction(s) total`+(m[0]?` \u2014 latest ${m[0].session_id.slice(0,8)}\u2026 at ${m[0].interactions}`:""));let p=J(i$1);p.pending?o(`a cue is pending since ${p.last_cue_at} (retry threshold armed)`):p.last_skip_reason&&s(` last skip: "${p.last_skip_reason}"`),p.display_pending&&o("a lesson was logged and the next stop will verify its card is visible");let d=R$1(i$1);d.allowed?e$1("rate limit: allowed"):o(`rate limit: ${d.reason}`),s(t.bold(`
15
- Verdict`));let c=Y(i$1,m[0]?.session_id??null);c.wouldCue?e$1("the next eligible stop WOULD cue a lesson"):o("the next eligible stop would NOT cue a lesson:");for(let g of c.reasons)s(` \xB7 ${g}`);});}catch(i){n(`database check failed: ${i}`);}s();}async function ko(){let e=createInterface({input:process.stdin,output:process.stdout}),o=async(r,a="")=>{let i=a?` [${a}]`:"";return (await e.question(`${r}${i}: `)).trim()||a},n=async(r,a,i,l)=>{for(;;){let m=await o(r,String(a)),u=Number.parseInt(m,10);if(!Number.isNaN(u)&&u>=i&&u<=l)return u;s(t.red(`Must be ${i}\u2013${l}.`));}};try{s(N(t.bold("devcoach setup"))),s(`
16
- ${t.bold("Step 1")} \u2014 Restore from backup`);let r=await o("Path to existing backup zip (Enter to skip)","");if(r){existsSync(r)||(s(t.red(`File not found: ${r}`)),process.exit(1));let d=m(c=>Q(c,readFileSync(r)));s(`${t.green("\u2713")} Restored: ${d.topics} topics, ${d.lessons} lessons${d.learning_state?", notebook":""}`),s(t.green("Setup complete!"));return}s(`
17
- ${t.bold("Step 2")} \u2014 Build your knowledge profile`);let a$1=(await o("Mode: [a]utomatic (detect from files) / [m]anual (type your stack)","a")).toLowerCase(),i={};if(a$1.startsWith("a")){let c=b$1().folder??process.cwd(),g=a(c),b=Object.keys(g).sort((y,_)=>y.localeCompare(_));if(b.length){s(`
18
- ${t.dim(`Detected from ${t.cyan(c)}:`)}`);for(let y of b){let _=g[y]??5,J=await o(` ${t.cyan(y)} (Enter=keep, 0-10=override, s=skip)`,String(_));if(J.toLowerCase()==="s")continue;let Y=Number.parseInt(J,10);i[y]=Number.isNaN(Y)?_:Math.max(0,Math.min(10,Y));}}else s(t.dim("No technology files detected in current directory."));let k=await o(`
19
- Add additional topics (comma-separated, or Enter to skip)`,"");for(let y of k.split(",").map(_=>_.trim()).filter(Boolean))i[y]=await n(` Confidence for ${t.cyan(y)}`,5,0,10);}else for(s(t.dim(`
20
- Enter topics: 'topic_id confidence' (e.g. python 7). Blank line when done.`));;){let d=(await o("Topic (Enter when done)","")).trim();if(!d)break;let c=d.split(/\s+/),g=c[0]??"",b=Number.parseInt(c[1]??"",10),k=Number.isNaN(b)?5:Math.max(0,Math.min(10,b));i[g]=k,s(` ${t.green("+")} ${t.cyan(g)} \u2192 ${k}`);}let l={};if(Object.keys(i).length&&(s(`
21
- ${t.bold("Step 3")} \u2014 Organise into groups`),(await o("Organise topics into groups? [y/N]","n")).toLowerCase().startsWith("y"))){let c=[];for(let g of Object.keys(i).sort((b,k)=>b.localeCompare(k))){let b=c.length?c.join(", "):"(none yet)",k=await o(` Group for ${t.cyan(g)} existing: ${t.dim(b)} (Enter=Other)`,"");if(k&&k!=="Other"){let y=l[k]??[];y.push(g),l[k]=y,c.includes(k)||c.push(k);}}}s(`
22
- ${t.bold("Step 4")} \u2014 Rate-limit settings`);let m$1=await n("Max lessons per day",2,1,20),u=await n("Min gap between lessons (minutes)",240,0,1440),p=m(d=>{d.exec("DELETE FROM knowledge; DELETE FROM knowledge_groups; DELETE FROM knowledge_group_names;");for(let[c,g]of Object.entries(i))z(d,c,g);for(let[c,g]of Object.entries(l))for(let b of g)D(d,b,c);return G(d,"max_per_day",String(m$1)),G(d,"min_gap_minutes",String(u)),S(d)});s(Te(p,"Knowledge Profile")),s(`
23
- ${t.green("Setup complete!")} ${Object.keys(i).length} topics saved.`);}finally{e.close();}}function yo(){let e$1=[["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 the MCP server + Stop hooks + skill in Claude Code / Claude Desktop"],["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 Claude Code 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"],["knowledge-add / -remove","Add / remove a topic"],["group-add / -remove / -assign","Manage knowledge groups"],["backup / restore","Export / import a full backup zip"]];s(`
24
- ${t.bold(`devcoach ${t.dim(`v${e}`)}`)}`);for(let[n,r]of e$1)s(` ${t.cyan(`devcoach ${n}`.padEnd(32))} ${t.dim(r)}`);s(`
25
- ${t.dim("Run")} ${t.bold("devcoach <command> --help")} ${t.dim("for per-command options.")}
26
- `);let o=Ie();o&&s(`${o}
27
- `);}function $(e){return e??null}function $o(){let e$2=new Command;return e$2.exitOverride(),e$2.name("devcoach").description("devcoach \u2014 progressive technical coaching").version(`devcoach ${e}`,"-v, --version","output the version number").allowExcessArguments(false).showHelpAfterError("(add --help for usage)").action(()=>yo()),e$2.command("mcp").description("Start the MCP server (stdio transport)").action(async()=>{let{runStdio:o}=await import('./server-KBYJPWN6.js');await o();}),e$2.command("profile").description("Show the knowledge map").action(Ye),e$2.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("--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=>Ve({period:o.period??"all",category:$(o.category),project:$(o.project),repository:$(o.repository),branch:$(o.branch),commit:$(o.commit),starred:!!o.starred,feedback:$(o.feedback),level:$(o.level),dateFrom:$(o.dateFrom),dateTo:$(o.dateTo),sort:o.sort??"timestamp",order:o.order??"desc"})),e$2.command("lesson").description("Show a single lesson in detail").argument("<id>","Lesson ID").action(o=>Ze(o)),e$2.command("star").description("Mark a lesson as starred").argument("<id>","Lesson ID").action(o=>Se(o,true)),e$2.command("unstar").description("Remove the starred mark from a lesson").argument("<id>","Lesson ID").action(o=>Se(o,false)),e$2.command("delete").description("Permanently delete a lesson").argument("<id>","Lesson ID").action(o=>qe(o)),e$2.command("feedback").description("Record know/dont_know feedback for a lesson").argument("<id>","Lesson ID").argument("<value>","know | dont_know | clear").action((o,n)=>Xe(o,n)),e$2.command("settings").description("Show current settings").action(Qe),e$2.command("stats").description("Coaching statistics and rate-limit status").action(eo),e$2.command("set").description("Update a setting (max_per_day | min_gap_minutes)").argument("<key>","Setting key").argument("<value>","New value").action((o,n)=>oo(o,n)),e$2.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,n)=>to(o,Math.max(0,Math.min(10,Number.parseInt(n.confidence??"5",10)||5)),$(n.group))),e$2.command("knowledge-remove").description("Remove a topic from the knowledge map").argument("<topic>","Topic ID").action(o=>no(o)),e$2.command("group-add").description("Register a new knowledge group").argument("<name>","Group name").action(o=>ro(o)),e$2.command("group-remove").description("Delete a knowledge group (topics move to Other)").argument("<name>","Group name").action(o=>so(o)),e$2.command("group-assign").description("Move a topic to a group").argument("<topic>","Topic ID").argument("<group>","Group name (use 'Other' to ungroup)").action((o,n)=>io(o,n)),e$2.command("backup").description("Export a full backup (settings + knowledge + lessons) as zip").argument("[file]","Output zip path","devcoach-backup.zip").action(o=>ao(o)),e$2.command("restore").description("Restore from a backup zip file").argument("<file>","Path to backup zip").action(o=>co(o)),e$2.command("install").description("Register the MCP server + Stop hooks + skill in Claude Code / Claude Desktop").option("--claude-code","Target Claude Code only").option("--claude-desktop","Target Claude Desktop only").option("--force","Overwrite existing devcoach entry").option("--skip-hook","Register MCP server only \u2014 skip the Stop hooks").action(o=>ho({claudeCode:!!o.claudeCode,claudeDesktop:!!o.claudeDesktop,force:!!o.force,skipHook:!!o.skipHook})),e$2.command("doctor").description("Diagnose the devcoach \u21C4 Claude Code wiring and the lesson pacing state").action(bo),e$2.command("ui").description("Launch the web dashboard").option("--port <port>","Port","7860").action(async o=>{let{startUi:n}=await import('./app-IXWAZDVH.js');n(Number.parseInt(o.port??"7860",10)||7860);}),e$2.command("setup").description("First-run wizard: import backup or build your knowledge profile").action(ko),e$2.command("stop-hook",{hidden:true}).description("Claude Code Stop hook: onboarding check + lesson cue in one spawn").action(()=>e$1()),e$2.command("prompt-hook",{hidden:true}).description("Claude Code UserPromptSubmit hook: prime the model when a lesson is due").action(()=>f()),e$2.command("onboard-hook",{hidden:true}).description("Claude Code Stop hook: cue onboarding (legacy two-entry layout)").action(()=>b()),e$2.command("lesson-ready",{hidden:true}).description("Claude Code Stop hook: signal a lesson is due (legacy two-entry layout)").action(()=>d()),e$2}async function Eo(){let e=$o();try{await e.parseAsync(process.argv);}catch(o){let n=o.code??"";if(!n.startsWith("commander."))throw o;if(n==="commander.helpDisplayed"||n==="commander.help"||n==="commander.version")return;process.exit(2);}}export{Eo as runCli};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export{c as buildLessonCue,d as cmdLessonReady,b as cmdOnboardHook,f as cmdPromptHook,e as cmdStopHook,a as parseHookPayload,g as runHook}from'./chunk-JTR6RJFB.js';import'./chunk-227BHE2B.js';
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env node
2
- import {e,b as b$1,a as a$1,d as d$2,c as c$2}from'./chunk-NVEMYNQQ.js';import {c as c$1,b,a,m,O,g,n,I,L,s,T,p,r,q,K,d as d$1,z as z$1,D,A,B,C,f,e as e$1,S,j,F,V,W,o,R,N,k,w,G}from'./chunk-227BHE2B.js';import {spawn}from'child_process';import {mkdirSync,writeFileSync,existsSync,readFileSync,statSync}from'fs';import {dirname}from'path';import {McpServer,ResourceTemplate}from'@modelcontextprotocol/sdk/server/mcp.js';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import {z}from'zod';var l=r=>({type:"text",text:r}),re=r=>({content:[l(JSON.stringify(r))]}),d=r=>({isError:true,content:[l(r)]}),ie=r=>({content:[l(JSON.stringify(r))],structuredContent:r}),ue={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()},pe={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())}))},he={max_per_day:z.number().int(),min_gap_minutes:z.number().int(),ui_theme:e$1,nudge_every:z.number().int(),nudge_scope:f};function c(r,u){return {contents:[{uri:r.href,mimeType:"application/json",text:JSON.stringify(u)}]}}function me(){let r$1=new McpServer({name:"devcoach",version:e},{instructions:"Progressive technical coaching server. Use the devcoach_instructions prompt for full coaching behaviour guidelines."});r$1.registerTool("log_lesson",{title:"Log Lesson",description:"Save a delivered lesson to the coaching log. Git metadata (project, repository, branch, commit_hash, folder, repository_platform) is auto-detected from the workspace when omitted. Returns the saved Lesson with all resolved fields.",inputSchema:{id:z.string().describe("Unique lesson id (uuid or random string)"),timestamp:z.string().describe("ISO 8601 timestamp; normalized to UTC and clamped to now"),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:ue,annotations:{title:"Log Lesson",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async e=>{try{let t=b$1(),o={};try{o=m(s=>O(s));}catch{o={};}let i=g({id:e.id,timestamp:e.timestamp,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??t.project??o.project??null,repository:e.repository??t.repository??o.repository??null,branch:e.branch??t.branch??o.branch??null,commit_hash:e.commit_hash??t.commit_hash??null,folder:e.folder??t.folder??null,repository_platform:e.repository_platform??t.repository_platform??o.repository_platform??null});m(s=>{n(s,i),I(s),L(s);});try{if(r$1.server.getClientCapabilities()?.elicitation){let m$1=await r$1.server.elicitInput({message:"Did that land?",requestedSchema:{type:"object",properties:{feedback:{type:"string",title:"Did that land?",description:"know = got it \xB7 dont_know = need to revisit \xB7 skip = no feedback",enum:["know","dont_know","skip"]}},required:[]}}),p=m$1.action==="accept"?m$1.content?.feedback:void 0;p&&p!=="skip"&&(m(g=>{s(g,e.id,p),T(g,e.topic_id,p==="know"?1:-1);}),i={...i,feedback:p});}}catch{}return {content:[l("Lesson saved. The card must already be visible in your reply \u2014 output NOTHING else now and NEVER print the card a second time."),l(JSON.stringify(i))],structuredContent:i}}catch(t){return d(`log_lesson failed: ${t}`)}}),r$1.registerTool("update_knowledge",{title:"Update Knowledge",description:"Adjust the confidence score for a topic by delta (e.g. +1 or -1). Returns the new confidence (0-10). Creates the topic at confidence 5 if it does not exist.",inputSchema:{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 t=m(o=>T(o,e.topic,e.delta));return {content:[l(String(t))]}}catch(t){return d(`update_knowledge failed for '${e.topic}': ${t}`)}}),r$1.registerTool("get_lessons",{title:"Get Lessons",description:"Query the coaching lesson history. All filters combine. period defaults to all; date_from/date_to override period; limit caps results newest-first (0 = all).",inputSchema:{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"),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 t=m(o=>p(o,{period:e.period,category:e.category,level:e.level,project:e.project,repository:e.repository,branch:e.branch,commit:e.commit,starred:e.starred,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 re(t)}catch{return re([])}}),r$1.registerTool("star_lesson",{title:"Star Lesson",description:"Set the starred (favourite) flag on a lesson. Returns true if found and updated. Idempotent.",inputSchema:{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 t=m(o=>r(o,e.lesson_id,e.starred));return {content:[l(String(t))]}}catch(t){return d(`star_lesson failed for '${e.lesson_id}': ${t}`)}}),r$1.registerTool("delete_lesson",{title:"Delete Lesson",description:"Permanently delete a lesson by id. Returns true if found and deleted.",inputSchema:{lesson_id:z.string().describe("Lesson id to delete")},annotations:{title:"Delete Lesson",destructiveHint:true,idempotentHint:true,openWorldHint:false}},async e=>{try{let t=m(o=>q(o,e.lesson_id));return {content:[l(String(t))]}}catch(t){return d(`delete_lesson failed for '${e.lesson_id}': ${t}`)}}),r$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:{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 t=e.feedback==="clear"?null:e.feedback,o=m(i=>{let s$1=i.prepare("SELECT feedback, topic_id FROM lessons WHERE id = ?").get(e.lesson_id);return s$1?(s$1.feedback===t||(s(i,e.lesson_id,t),(t==="know"||t==="dont_know")&&s$1.topic_id&&T(i,s$1.topic_id,t==="know"?1:-1)),!0):!1});return {content:[l(String(o))]}}catch(t){return d(`submit_feedback failed for '${e.lesson_id}': ${t}`)}}),r$1.registerTool("skip_lesson",{title:"Skip Lesson",description:"Decline a lesson cue: call this when the coaching hook asked for a lesson but the completed work does not warrant one (pure questions, chat, nothing technical). Re-arms the pacing counter so the cue is not repeated immediately. Never call it after delivering a lesson \u2014 log_lesson already resolves the cue.",inputSchema:{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 m(t=>K(t,e.reason)),{content:[l("Cue skipped \u2014 pacing re-armed. Output nothing to the user.")]}}catch(t){return d(`skip_lesson failed: ${t}`)}}),r$1.registerTool("add_topic",{title:"Add Topic",description:"Add a topic to the knowledge map, or update its confidence if it exists. Optionally assign to a group (auto-created). Prefer a single-word topic id. Idempotent.",inputSchema:{topic:z.string().describe("Topic id \u2014 prefer a single word, max 3 words"),confidence:d$1.default(5).describe("Initial confidence 0-10 (default 5)"),group:z.string().nullish().describe("Optional group name; 'Other' if omitted")},annotations:{title:"Add Topic",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async e=>{try{return m(t=>{z$1(t,e.topic,e.confidence),e.group&&e.group!=="Other"&&D(t,e.topic,e.group);}),{content:[l("true")]}}catch(t){return d(`add_topic failed for '${e.topic}': ${t}`)}}),r$1.registerTool("remove_topic",{title:"Remove Topic",description:"Remove a topic from the knowledge map entirely. Returns true if it existed.",inputSchema:{topic:z.string().describe("Topic id to remove")},annotations:{title:"Remove Topic",destructiveHint:true,idempotentHint:true,openWorldHint:false}},async e=>{try{let t=m(o=>A(o,e.topic));return {content:[l(String(t))]}}catch(t){return d(`remove_topic failed for '${e.topic}': ${t}`)}}),r$1.registerTool("add_group",{title:"Add Group",description:"Create a new (initially empty) knowledge group. Idempotent \u2014 returns true either way.",inputSchema:{name:z.string().describe("Group name, e.g. 'Machine Learning'")},annotations:{title:"Add Group",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async e=>{try{return m(t=>B(t,e.name.trim())),{content:[l("true")]}}catch(t){return d(`add_group failed for '${e.name}': ${t}`)}}),r$1.registerTool("remove_group",{title:"Remove Group",description:"Delete a knowledge group. Its topics move to Other. Returns true if it existed.",inputSchema:{name:z.string().describe("Group name to delete")},annotations:{title:"Remove Group",destructiveHint:true,idempotentHint:true,openWorldHint:false}},async e=>{try{let t=m(o=>C(o,e.name));return {content:[l(String(t))]}}catch(t){return d(`remove_group failed for '${e.name}': ${t}`)}}),r$1.registerTool("update_settings",{title:"Update Settings",description:"Update a coaching setting. max_per_day: integer 1-20. min_gap_minutes: integer 0-1440 (0 = no cooldown). nudge_every: integer 0-1000 interactions between lesson cues (0 = cue every turn). nudge_scope: 'session' | 'global'. Returns the full updated Settings.",inputSchema:{key:z.enum(["max_per_day","min_gap_minutes","nudge_every","nudge_scope"]).describe("Setting key"),value:z.string().describe("New value (integer string; or 'session'|'global' for nudge_scope)")},outputSchema:he,annotations:{title:"Update Settings",destructiveHint:false,idempotentHint:true,openWorldHint:false}},e=>{let t=i=>ie(m(s=>(G(s,e.key,i),F(s))));if(e.key==="nudge_scope")return e.value!=="session"&&e.value!=="global"?d("nudge_scope must be 'session' or 'global'"):t(e.value);let o=Number.parseInt(e.value,10);return Number.isNaN(o)?d(`Value must be an integer, got '${e.value}'`):e.key==="max_per_day"&&!(o>=1&&o<=20)?d("max_per_day must be between 1 and 20"):e.key==="min_gap_minutes"&&!(o>=0&&o<=1440)?d("min_gap_minutes must be between 0 and 1440"):e.key==="nudge_every"&&!(o>=0&&o<=1e3)?d("nudge_every must be between 0 and 1000"):t(String(o))}),r$1.registerTool("open_ui",{title:"Open UI",description:"Launch the devcoach web dashboard in the background. port must be 1024-65535.",inputSchema:{port:z.number().int().default(7860).describe("Port (default 7860)")},annotations:{title:"Open UI",destructiveHint:false,idempotentHint:false,openWorldHint:true}},e=>{let t=e.port;return t>=1024&&t<=65535?(spawn(process.execPath,[process.argv[1]??"","ui","--port",String(t)],{detached:true,stdio:"ignore"}).unref(),{content:[l(`devcoach UI starting at http://localhost:${t}`)]}):{content:[l(`error: port ${t} is out of valid range (1024-65535)`)]}}),r$1.registerTool("complete_onboarding",{title:"Complete Onboarding",description:"Save the user's initial knowledge profile and mark onboarding complete. Wipes any default-seeded profile. topics: {topic_id: confidence_0_to_10}. groups: {group_name: [topic_id,...]} (topics not in any group go to 'Other'). Pass the personalized coaching notebook as `notebook`; it is saved to learning-state.md atomically with the profile. Returns the updated Profile.",inputSchema:{topics:z.record(z.string(),d$1).describe("{topic_id: confidence 0-10}"),groups:z.record(z.string(),z.array(z.string())).optional().describe("{group_name: [topic_id, ...]}"),notebook:z.string().optional().describe("Full personalized coaching notebook (markdown) saved verbatim to learning-state.md. Write real observations about THIS user \u2014 background, strengths, gaps, and how they work across ALL their projects (not just this one), per the template in the devcoach skill. If omitted, a minimal placeholder is written so the file is never empty.")},outputSchema:pe,annotations:{title:"Complete Onboarding",destructiveHint:true,idempotentHint:false,openWorldHint:false}},async e=>{try{let t=m(i=>{i.exec("DELETE FROM knowledge; DELETE FROM knowledge_groups; DELETE FROM knowledge_group_names;");for(let[s,m]of Object.entries(e.topics))z$1(i,s,Math.max(0,Math.min(10,m)));if(e.groups)for(let[s,m]of Object.entries(e.groups))for(let p of m)p in e.topics&&D(i,p,s);return S(i)}),o=e.notebook?.trim();return mkdirSync(dirname(j),{recursive:!0}),o?writeFileSync(j,o.endsWith(`
3
- `)?o:`${o}
4
- `):existsSync(j)||writeFileSync(j,`# devcoach \u2014 Coaching Notebook
5
- `),ie(t)}catch(t){return d(`complete_onboarding failed: ${t}`)}}),r$1.registerTool("update_notebook",{title:"Update Coaching Notebook",description:"Overwrite the coaching notebook (~/.devcoach/learning-state.md) with revised markdown. Use it after a lesson to fold in what the user absorbed or struggled with, new recurring patterns, and updated hypotheses \u2014 keeping the prior notes. Pass the full notebook content.",inputSchema:{notebook:z.string().min(1).describe("Full notebook markdown saved verbatim to learning-state.md (overwrites).")},annotations:{title:"Update Coaching Notebook",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async e=>{try{return mkdirSync(dirname(j),{recursive:!0}),writeFileSync(j,e.notebook.endsWith(`
6
- `)?e.notebook:`${e.notebook}
7
- `),{content:[l("notebook updated")]}}catch(t){return d(`update_notebook failed: ${t}`)}});let u=(e,t)=>({title:e,description:t,mimeType:"application/json"});return r$1.registerResource("profile","devcoach://profile",u("Knowledge Profile","Current knowledge map \u2014 topics, confidence scores, and groups."),e=>{try{return c(e,m(t=>S(t)))}catch(t){return c(e,{error:String(t)})}}),r$1.registerResource("notebook","devcoach://notebook",{title:"Coaching Notebook",description:"The coaching notebook (learning-state.md): observations, recurring patterns, recommended focus, and open hypotheses about the user. Read it to decide what to teach.",mimeType:"text/markdown"},e=>{let t="";try{existsSync(j)&&(t=readFileSync(j,"utf8"));}catch{}return {contents:[{uri:e.href,mimeType:"text/markdown",text:t}]}}),r$1.registerResource("settings","devcoach://settings",u("Settings","Current coaching settings (rate limits, UI theme)."),e=>{try{return c(e,m(t=>F(t)))}catch(t){return c(e,{error:String(t)})}}),r$1.registerResource("recent-lessons","devcoach://lessons/recent",u("Recent Lessons","Last 10 lessons from the current week."),e=>{try{return c(e,m(t=>p(t,{period:"week",page:1,per_page:10})))}catch(t){return c(e,[{error:String(t)}])}}),r$1.registerResource("stats","devcoach://stats",u("Stats","Aggregate coaching statistics: counts and weakest/strongest topics."),e=>{try{return c(e,m(t=>V(t)))}catch(t){return c(e,{error:String(t)})}}),r$1.registerResource("taught-topics","devcoach://taught-topics",u("Taught Topics","All topic_ids already taught \u2014 read before selecting a new lesson topic."),e=>{try{return c(e,m(t=>W(t)))}catch{return c(e,[])}}),r$1.registerResource("rate-limit","devcoach://rate-limit",u("Rate Limit","Current rate-limit status and running lesson total."),e=>{try{let{r:t,total:o$1}=m(s=>({r:R(s),total:o(s)})),i={allowed:t.allowed,total_lessons:o$1};return t.reason!=null&&(i.reason=t.reason),c(e,i)}catch(t){return c(e,{allowed:false,reason:`Rate limit check unavailable: ${t}`})}}),r$1.registerResource("briefing","devcoach://briefing",u("Lesson Briefing","Everything needed before delivering a lesson in ONE read: onboarding status, rate limit, taught topics, knowledge profile, and the coaching notebook."),e=>{try{let t="";try{existsSync(j)&&(t=readFileSync(j,"utf8"));}catch{}let o$1=m(i=>{let s=N(i).knowledge_ready,m=t.length>0,p=R(i),g={allowed:p.allowed,total_lessons:o(i)};return p.reason!=null&&(g.reason=p.reason),{onboarding:{knowledge_ready:s,notebook_ready:m,needs_onboarding:!(s&&m)},rate_limit:g,taught_topics:W(i),profile:S(i)}});return c(e,{...o$1,notebook:t})}catch(t){return c(e,{error:String(t)})}}),r$1.registerResource("context","devcoach://context",u("Workspace Context","Auto-detected git context and most-used lesson metadata defaults."),e=>{try{let t=b$1(),o=m(i=>O(i));return c(e,{git:t,usage_defaults:o})}catch(t){return c(e,{error:String(t)})}}),r$1.registerResource("onboarding","devcoach://onboarding",u("Onboarding","Onboarding status, auto-detected stack, and project topic defaults."),e=>{try{let o=m(p=>N(p)).knowledge_ready,i=existsSync(j)&&statSync(j).size>0,s=b$1(),m$1=a$1(s.folder??process.cwd());return c(e,{knowledge_ready:o,notebook_ready:i,needs_onboarding:!(o&&i),detected_stack:m$1,default_topics:k,context_ready:s.branch!==null})}catch(t){return c(e,{error:String(t)})}}),r$1.registerResource("lesson",new ResourceTemplate("devcoach://lessons/{lesson_id}",{list:void 0}),u("Lesson","A single lesson by id."),(e,t)=>{try{let o=String(t.lesson_id),i=m(s=>w(s,o));return i?c(e,i):c(e,{error:`Lesson '${o}' not found`})}catch(o){return c(e,{error:String(o)})}}),r$1.registerPrompt("devcoach_instructions",{title:"devcoach coaching instructions",description:"Full coaching instructions for the devcoach skill (SKILL.md plus its reference files)."},()=>{let e=d$2().map(t=>`
8
-
9
- ---
10
-
11
- <!-- reference: ${t.name} -->
12
-
13
- ${t.content}`).join("");return {messages:[{role:"user",content:{type:"text",text:c$2()+e}}]}}),r$1}async function Ce(){let r=me(),u=new StdioServerTransport;await r.connect(u);}export{me as createServer,Ce as runStdio};