devcoach 2.3.1 → 2.4.0-next.575.g9c67058
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/SKILL.md +3 -2
- package/assets/references/sharing.md +2 -1
- package/assets/static/relative-time.js +78 -15
- package/assets/static/style.css +70 -0
- package/assets/static/table-resize.js +178 -0
- package/dist/{app-SVGKP5WG.js → app-RC2D4BDF.js} +233 -141
- package/dist/bin.js +1 -1
- package/dist/chunk-DGO6MIQO.js +15 -0
- package/dist/chunk-LSO57U2T.js +2 -0
- package/dist/chunk-TQI44CEB.js +75 -0
- package/dist/commands-YNDVJIEM.js +36 -0
- package/dist/{hooks-5YA5PLBW.js → hooks-5UZL55FA.js} +1 -1
- package/dist/server-NLJ7CK6T.js +9 -0
- package/package.json +1 -1
- package/dist/chunk-4PFP67XN.js +0 -2
- package/dist/chunk-JEFYE33I.js +0 -75
- package/dist/chunk-UHF6ARVR.js +0 -15
- package/dist/commands-ECVEHTRX.js +0 -36
- package/dist/server-SM63J4EC.js +0 -9
package/dist/chunk-UHF6ARVR.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {i,o,M,ga,h as h$1,n,fa}from'./chunk-JEFYE33I.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
|
-
`);}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
|
-
`),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
|
-
|
|
6
|
-
${y[o].cue} NOW and follow it exactly \u2014 the skill is the single source of truth for the entire flow, including the explicit no-op when the completed work does not warrant a lesson.
|
|
7
|
-
${i}
|
|
8
|
-
|
|
9
|
-
If the devcoach skill is not available, fall back to: call get_briefing (one call: profile, taught topics, notebook); pick ONE untaught profile topic at or above the user's confidence band; call log_lesson silently (body = 3\u20136 short paragraphs tied to the task plus a \`\u{1F4A1} *Senior tip:*\` line, clean markdown without bands or a title line); THEN write the card as the FINAL message of the turn: plain markdown (no '>' blockquote) between two band headings \`### \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u{1F393} devcoach \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\` and \`### \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 [topic] \xB7 [level] \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\`, with \`**[Title]** \xB7 [Category] \xB7 [Level]\`, the body you passed, and the tip \u2014 saving is not showing; the card in the final message is the only thing the user sees. If instead the work does not warrant a lesson (pure questions, chat, nothing technical), call the devcoach \`skip_lesson\` tool with a one-line reason.
|
|
10
|
-
|
|
11
|
-
The rate-limit check is already done by this hook \u2014 skip it. Work in silence: never narrate devcoach tool calls or resource reads ('checking your profile\u2026'). Output only the lesson card (or nothing). No preamble, no meta-commentary.`}function I(e,o,t){let n=o.permission_mode==="plan";if(o.stop_hook_active)return {kind:"silent",note:"hook-forced continuation"};if(!M(e).knowledge_ready)return !t.onboardCue||n?{kind:"silent",note:"onboarding not complete"}:{kind:"onboard",note:"onboarding cue (empty knowledge)"};let i=fa(e,o.session_id,{planMode:n});return i.cue?{kind:"cue",nextLessonNumber:i.nextLessonNumber,note:i.reason}:{kind:"silent",note:i.reason}}function v(e,o$1,t){let n$1;try{n$1=o(i=>n(i,()=>I(i,o$1,t)));}catch(i){s(e,o$1.session_id,`error: ${i}`),process.exit(0);}switch(s(e,o$1.session_id,n$1.note),n$1.kind){case "onboard":h(t.client,f);break;case "cue":h(t.client,E(n$1.nextLessonNumber,t.client),"\u{1F393} devcoach: checking whether a lesson is due\u2026");break;}process.exit(0);}function T(e=l()){existsSync(i)||process.exit(0),v("lesson-ready",e,{onboardCue:false,client:"claude"});}function k(e=l(),o="claude"){let t=o==="claude"?"stop-hook":`${o}-stop-hook`;existsSync(i)||((e.stop_hook_active||e.permission_mode==="plan")&&process.exit(0),s(t,e.session_id,"onboarding cue (no DB)"),h(o,f)),v(t,e,{onboardCue:true,client:o});}function R(e="claude"){return `devcoach: the lesson pacing threshold will be reached at the end of this turn. Resolve it before finishing:
|
|
12
|
-
- If this task is technical: ${y[e].prime} and follow it exactly to close your reply \u2014 the skill is the single source of truth for the entire lesson flow.
|
|
13
|
-
- If it is not technical: silently call the devcoach \`skip_lesson\` tool with a one-line reason and output nothing about it.
|
|
14
|
-
- Either way, work in silence: never narrate devcoach tool calls or resource reads ('checking your profile\u2026').`}var B={claude:"UserPromptSubmit",gemini:"BeforeAgent",codex:"UserPromptSubmit"};function m(e=l(),o$1="claude"){let t=o$1==="claude"?"prompt-hook":`${o$1}-prompt-hook`;e.permission_mode==="plan"&&process.exit(0),existsSync(i)||process.exit(0);let n;try{n=o(i=>ga(i,e.session_id).wouldCue);}catch(i){s(t,e.session_id,`error: ${i}`),process.exit(0);}s(t,e.session_id,n?"priming":"no prime"),n||process.exit(0),process.stdout.write(`${JSON.stringify({hookSpecificOutput:{hookEventName:B[o$1],additionalContext:R(o$1)}})}
|
|
15
|
-
`),process.exit(0);}function U(e,o){let t=()=>o??l();switch(e){case "stop-hook":k(t());break;case "gemini-stop-hook":k(t(),"gemini");break;case "codex-stop-hook":k(t(),"codex");break;case "prompt-hook":m(t());break;case "gemini-prompt-hook":m(t(),"gemini");break;case "codex-prompt-hook":m(t(),"codex");break;case "onboard-hook":$(t());break;case "lesson-ready":T(t());break;default:process.exit(0);}}export{D as a,$ as b,E as c,T as d,k as e,R as f,m as g,U as h};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {e,g,b,d as d$1}from'./chunk-UHF6ARVR.js';export{c as buildLessonCue,d as cmdLessonReady,b as cmdOnboardHook,g as cmdPromptHook,e as cmdStopHook,a as parseHookPayload}from'./chunk-UHF6ARVR.js';import {a,d as d$2,e as e$1,g as g$1,b as b$3,f}from'./chunk-QU6UQJWC.js';import {c as c$1,b as b$2,a as a$2,e as e$2,f as f$1}from'./chunk-MRABMPXO.js';import {a as a$1,b as b$1,c as c$2,d as d$3}from'./chunk-4PFP67XN.js';import {Q as Q$1,o,$,r,x,t,s,ba,G,T,H as H$1,m,S as S$1,Y as Y$1,Z as Z$1,X as X$1,W as W$1,U,da,R,_ as _$1,ca,l,A as A$1,E,B,C as C$1,D,F,O as O$1,z,v,j as j$1,P,h,i,M,I as I$1,K,ga}from'./chunk-JEFYE33I.js';import {spawn,spawnSync,execFileSync}from'child_process';import {writeFileSync,existsSync,readFileSync,rmSync,mkdirSync,accessSync,constants}from'fs';import {createInterface}from'readline/promises';import {text}from'stream/consumers';import {Command}from'commander';import {homedir,platform}from'os';import {join,dirname}from'path';var c=(e="")=>{console.log(e);};function fo(){let e=platform();if(e==="darwin")return join(homedir(),"Library","Application Support","Claude","claude_desktop_config.json");if(e==="win32"){let t=process.env.APPDATA??join(homedir(),"AppData","Roaming");return join(t,"Claude","claude_desktop_config.json")}let o=process.env.XDG_CONFIG_HOME??join(homedir(),".config");return join(o,"Claude","claude_desktop_config.json")}var I=join(homedir(),".claude","settings.json"),Y=join(homedir(),".claude","skills","devcoach"),fe=join(homedir(),".gemini"),_=join(fe,"settings.json"),Eo=join(fe,"extensions","devcoach","gemini-extension.json"),he=join(homedir(),".codex"),O=join(he,"hooks.json"),W=join(he,"config.toml"),H=join(homedir(),".agents","skills","devcoach");function ho(e){for(let o of (process.env.PATH??"").split(":"))if(o)try{return accessSync(join(o,e),constants.X_OK),join(o,e)}catch{}return null}var X=e=>ho(e)!==null;function ko(){return X("devcoach")?{command:"devcoach",args:["mcp"]}:{command:"npx",args:["-y","devcoach","mcp"]}}function ke(){let e=ho("devcoach");return e?e.includes("fnm_multishells")?"devcoach":e:"npx -y devcoach"}function mo(e,o,t){if(!X(e))return "";t&&spawnSync(e,t,{encoding:"utf8"});let i=spawnSync(e,o,{encoding:"utf8"});return i.status===0?`${a.green("\u2713")} Registered via \`${e} mcp add\``:`${i.stderr??""}${i.stdout??""}`.toLowerCase().includes("already")?`${a.yellow("Already registered")} in ${e} (use --force to overwrite)`:`${a.red(`${e} mcp add failed:`)} ${(i.stderr||i.stdout||"").trim()}`}function Mo(e,o){if(!X("claude"))return "";o&&spawnSync("claude",["mcp","remove","--scope",e,"devcoach"],{encoding:"utf8"});let t=ko(),i=spawnSync("claude",["mcp","add","--scope",e,"devcoach",t.command,"--",...t.args],{encoding:"utf8"});return i.status===0?`${a.green("\u2713")} Registered via \`claude mcp add\` (scope: ${e})`:`${i.stderr??""}${i.stdout??""}`.toLowerCase().includes("already")?`${a.yellow("Already registered")} in Claude Code (use --force to overwrite)`:`${a.red("claude mcp add failed:")} ${(i.stderr||i.stdout||"").trim()}`}function C(e){if(!existsSync(e))return {ok:true,data:{}};try{return {ok:!0,data:JSON.parse(readFileSync(e,"utf8"))??{}}}catch{return {ok:false,error:`${a.red("\u2717")} ${e} is not valid JSON \u2014 fix it and re-run (left unchanged)`}}}function ce(e,o,t){let i=C(e);if(!i.ok)return i.error;let s=i.data;s.mcpServers??={};let a$1=s.mcpServers;return a$1.devcoach&&!t?`${a.yellow("Already registered")} in ${e} (use --force to overwrite)`:(a$1.devcoach=o,mkdirSync(dirname(e),{recursive:true}),writeFileSync(e,`${JSON.stringify(s,null,2)}
|
|
3
|
-
`),`${a.green("\u2713")} Installed into ${e}`)}function No(){let e=ke();return {Stop:{hooks:[{type:"command",command:`${e} stop-hook`,timeout:60}]},UserPromptSubmit:{hooks:[{type:"command",command:`${e} prompt-hook`,timeout:30}]}}}function Ao(){let e=ke();return {AfterAgent:{hooks:[{type:"command",command:`${e} gemini-stop-hook`,timeout:6e4}]},BeforeAgent:{hooks:[{type:"command",command:`${e} gemini-prompt-hook`,timeout:3e4}]}}}function To(){let e=ke();return {Stop:{hooks:[{type:"command",command:`${e} codex-stop-hook`,timeout:60}]},UserPromptSubmit:{hooks:[{type:"command",command:`${e} codex-prompt-hook`,timeout:30}]}}}function be(e){return Object.entries(e.enabledPlugins??{}).some(([o,t])=>t&&o.startsWith("devcoach@"))}function q(){return existsSync(Eo)}function Z(e){return /dev-?coach/i.test(e)&&/\b(?:stop-hook|prompt-hook|onboard-hook|lesson-ready)\b/.test(e)}function ye(e,o){let t=C(e);if(!t.ok)return t.error;let i=t.data;i.hooks??={};let s=i.hooks,a$1=false;for(let[r,l]of Object.entries(o)){s[r]??=[];let m=s[r],k=m.map((u,g)=>[u,g]).filter(([u])=>(u.hooks??[]).some(g=>Z(g.command??""))).map(([,u])=>u),[p]=k;if(!(k.length===1&&p!==void 0&&JSON.stringify(m[p])===JSON.stringify(l))){for(let u of k.toReversed())m.splice(u,1);m.push(l),a$1=true;}}return a$1?(mkdirSync(dirname(e),{recursive:true}),writeFileSync(e,`${JSON.stringify(i,null,2)}
|
|
4
|
-
`),`${a.green("\u2713")} Hooks installed into ${e} (${Object.keys(o).join(" + ")})`):`${a.yellow("Already installed")} in ${e} (current layout)`}function jo(){let e=C(I);return e.ok?be(e.data)?`${a.yellow("Skipped")} \u2014 the devcoach plugin already provides the hooks (installing both would double-count interactions)`:ye(I,No()):e.error}function Po(){return q()?`${a.yellow("Skipped")} \u2014 the devcoach Gemini extension already provides the hooks (installing both would double-count interactions)`:ye(_,Ao())}function j(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 pe(e,o){if(!o&&j(e)==="current")return `${a.yellow("Already installed")} in ${e} (current version)`;mkdirSync(e,{recursive:true}),writeFileSync(join(e,"SKILL.md"),e$2());let t=f$1();if(t.length){let i=join(e,"references");mkdirSync(i,{recursive:true});for(let s of t)writeFileSync(join(i,s.name),s.content);}return writeFileSync(join(e,".devcoach-version"),`${Q$1}
|
|
5
|
-
`),`${a.green("\u2713")} Installed into ${e}`}function Go(e){return q()?`${a.yellow("Skipped")} \u2014 bundled with the devcoach Gemini extension`:pe(H,e)}function A(e,o){let t=C(e);return t.ok&&(t.data.hooks?.[o]??[]).some(i=>(i.hooks??[]).some(s=>Z(s.command??"")))}function $e(){let e=[{name:"Claude Code",dir:Y,cmd:"devcoach install",hooked:()=>A(I,"Stop")},{name:"Gemini/Codex",dir:H,cmd:"devcoach install --gemini (or --codex)",hooked:()=>A(_,"AfterAgent")||A(O,"Stop")}];for(let o of e){let t=j(o.dir);if(t==="outdated")return `${a.yellow("\u2192")} The devcoach ${o.name} skill is out of date \u2014 run ${a.bold(o.cmd)} to refresh it.`;if(t==="missing"&&o.hooked())return `${a.yellow("\u2192")} The devcoach ${o.name} skill is not installed \u2014 run ${a.bold(o.cmd)} to add it.`}return ""}function bo(e){let o=e.claudeCode||e.claudeDesktop||e.gemini||e.codex,t=e.claudeCode||!o,i=e.claudeDesktop||!o,s=ko(),a$1=false;if(c(a.bold("Setting up devcoach")+a.dim(` (${s.command} ${s.args.join(" ")})`)),c(),t){c(a.bold("Claude Code"));let r=Mo("user",e.force);if(!r){let l=join(homedir(),".claude.json");r=ce(l,{type:"stdio",env:{},...s},e.force),a$1=true;}c(` MCP server\u2026 ${r}`),e.skipHook||c(` Hooks\u2026 ${jo()}`),c(` Skill\u2026 ${pe(Y,e.force)}`),c();}if(i&&(c(a.bold("Claude Desktop")),c(` MCP server\u2026 ${ce(fo(),s,e.force)}`),a$1=true,c()),e.gemini){c(a.bold("Gemini CLI (beta)"));let r=mo("gemini",["mcp","add","-s","user","devcoach",s.command,...s.args],e.force?["mcp","remove","-s","user","devcoach"]:null);r||(r=ce(_,s,e.force)),c(` MCP server\u2026 ${r}`),e.skipHook||c(` Hooks\u2026 ${Po()}`),c(` Skill\u2026 ${Go(e.force)}`),c();}if(e.codex){c(a.bold("Codex CLI (beta)"));let r=mo("codex",["mcp","add","devcoach","--",s.command,...s.args],e.force?["mcp","remove","devcoach"]:null);r||(r=`${a.yellow("Manual step")} \u2014 codex CLI not found. Add to ${W}:
|
|
6
|
-
[mcp_servers.devcoach]
|
|
7
|
-
command = "${s.command}"
|
|
8
|
-
args = [${s.args.map(l=>`"${l}"`).join(", ")}]`),c(` MCP server\u2026 ${r}`),e.skipHook||c(` Hooks\u2026 ${ye(O,To())}`),c(` Skill\u2026 ${pe(H,e.force)}`),c(` ${a.yellow("\u2192")} Codex asks once to trust new hooks \u2014 approve devcoach on the next run.`),c();}a$1&&c(`${a.yellow("\u2192")} Restart Claude Desktop to pick up the new server.
|
|
9
|
-
`),c(a.dim(`Tip: run devcoach backup to export your profile, lessons and settings.
|
|
10
|
-
run devcoach restore <file> to import a backup on a new machine.
|
|
11
|
-
After upgrading devcoach (npm, Homebrew), re-run devcoach install to refresh the skill.`));}function ve(e){let o=[];for(let[t,i]of Object.entries(e.hooks??{}))for(let s of i??[])for(let a of s.hooks??[])Z(a.command??"")&&o.push({event:t,cmd:a});return o}function we(e,o,t){for(let{cmd:i}of o){let s=i.command.split(" ")[0]??"";s.startsWith("/")&&!existsSync(s)&&e.bad(`hook command not found: ${s} \u2014 re-run ${a.bold(t)}`),i.command.startsWith("npx ")&&e.warn("hook runs via npx \u2014 needs the npx cache (or network) on every stop"),i.timeout==null&&e.warn(`hook entry has no timeout (${i.command})`);}}function Fo(e){c(a.bold(`
|
|
12
|
-
Gemini CLI wiring (beta)`));let o=C(_),t=q();if(!o.ok){e.bad(`${_} is not valid JSON \u2014 hooks cannot run`);return}let i=ve(o.data);t&&i.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"):i.length?(i.some(a=>a.event==="AfterAgent")?e.ok("AfterAgent stop hook wired"):e.warn(`no AfterAgent stop hook \u2014 run ${a.bold("devcoach install --gemini")}`),i.some(a=>a.event==="BeforeAgent")?e.ok("BeforeAgent priming hook wired"):e.warn(`no BeforeAgent priming hook \u2014 run ${a.bold("devcoach install --gemini")} (lessons land more reliably)`),we(e,i,"devcoach install --gemini")):e.warn(`no devcoach hooks in ${_} \u2014 run ${a.bold("devcoach install --gemini")}`);let s=j(H);t?e.ok("skill bundled with the devcoach Gemini extension"):s==="current"?e.ok("skill installed (~/.agents/skills, current version)"):s==="outdated"?e.warn(`skill is out of date \u2014 run ${a.bold("devcoach install --gemini")}`):e.warn(`skill not installed \u2014 run ${a.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 ${a.bold("gemini mcp list")})`);}function Bo(e){c(a.bold(`
|
|
13
|
-
Codex CLI wiring (beta)`));let o=C(O);if(!o.ok){e.bad(`${O} is not valid JSON \u2014 hooks cannot run`);return}let t=ve(o.data);t.length?(t.some(a=>a.event==="Stop")?e.ok("Stop hook wired"):e.warn(`no Stop hook \u2014 run ${a.bold("devcoach install --codex")}`),t.some(a=>a.event==="UserPromptSubmit")?e.ok("UserPromptSubmit priming hook wired"):e.warn(`no UserPromptSubmit priming hook \u2014 run ${a.bold("devcoach install --codex")} (lessons land more reliably)`),we(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 ${O} \u2014 run ${a.bold("devcoach install --codex")}`);let i=j(H);i==="current"?e.ok("skill installed (~/.agents/skills, current version)"):i==="outdated"?e.warn(`skill is out of date \u2014 run ${a.bold("devcoach install --codex")}`):e.warn(`skill not installed \u2014 run ${a.bold("devcoach install --codex")}`);let s=existsSync(W)?readFileSync(W,"utf8"):"";/\[mcp_servers\.devcoach\]/.test(s)?e.ok("MCP server registered (config.toml)"):e.warn(`MCP server not found in config.toml \u2014 it may be registered elsewhere (check with ${a.bold("codex mcp list")})`);}function yo(){let e={ok:r=>c(` ${a.green("\u2713")} ${r}`),warn:r=>c(` ${a.yellow("\u2192")} ${r}`),bad:r=>c(` ${a.red("\u2717")} ${r}`)},{ok:o$1,warn:t,bad:i$1}=e;c(`
|
|
14
|
-
${a.bold("devcoach doctor")} ${a.dim(`v${Q$1}`)}
|
|
15
|
-
`),c(a.bold("Environment")),Number.parseInt(process.versions.node.split(".")[0]??"0",10)>=24?o$1(`Node ${process.versions.node} (\u2265 24)`):i$1(`Node ${process.versions.node} \u2014 devcoach needs Node \u2265 24 (embedded node:sqlite)`),c(a.bold(`
|
|
16
|
-
Claude Code wiring`));let a$1=C(I);if(!a$1.ok)i$1(`${I} is not valid JSON \u2014 hooks cannot run`);else {let r=be(a$1.data),l=ve(a$1.data);if(r&&l.length)i$1("devcoach hooks are registered TWICE (plugin + settings.json) \u2014 interactions are double-counted. Disable the plugin or remove the settings.json entries.");else if(r)o$1("hooks provided by the devcoach plugin");else if(!l.length)i$1(`no devcoach hooks in ${I} \u2014 run ${a.bold("devcoach install")}`);else {let p=l.filter(({cmd:g})=>g.command.includes("onboard-hook")||g.command.includes("lesson-ready")),u=l.filter(g=>g.event==="Stop").length;p.length?t(`legacy two-entry Stop layout \u2014 run ${a.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 ${a.bold("devcoach install")} to keep only the current one`):o$1(`Stop hook wired (${u} entry)`),l.some(g=>g.event==="UserPromptSubmit")?o$1("UserPromptSubmit priming hook wired"):t(`no UserPromptSubmit priming hook \u2014 run ${a.bold("devcoach install")} to add it (lessons land more reliably)`),we(e,l,"devcoach install");}let m=j(Y);m==="current"?o$1("Claude Code skill installed (current version)"):r?o$1("Claude Code skill bundled with the plugin"):t(m==="outdated"?`Claude Code skill is out of date \u2014 run ${a.bold("devcoach install")}`:`Claude Code skill not installed \u2014 run ${a.bold("devcoach install")}`);let k=C(join(homedir(),".claude.json"));k.ok&&k.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 ${a.bold("claude mcp get devcoach")})`);}if(existsSync(fe)&&Fo(e),existsSync(he)&&Bo(e),c(a.bold(`
|
|
17
|
-
Database & pacing`)),!existsSync(i)){t(`no database yet (${i}) \u2014 onboarding runs on the first technical task`),c();return}try{o(r=>{o$1(`database opens (${i})`),M(r).knowledge_ready?o$1("onboarding complete"):t("onboarding not complete \u2014 the next stop cues it");let l=G(r);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(r),k=m.reduce((y,b)=>y+b.interactions,0);c(` pacing: ${m.length} session(s) counted, ${k} interaction(s) total`+(m[0]?` \u2014 latest ${m[0].session_id.slice(0,8)}\u2026 at ${m[0].interactions}`:""));let p=K(r);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(r);u.allowed?o$1("rate limit: allowed"):t(`rate limit: ${u.reason}`),c(a.bold(`
|
|
18
|
-
Verdict`));let g=ga(r,m[0]?.session_id??null);g.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 g.reasons)c(` \xB7 ${y}`);});}catch(r){i$1(`database check failed: ${r}`);}c();}function le(e){if(!existsSync(e))return `${a.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)}
|
|
19
|
-
`),`${a.green("\u2713")} Removed from ${e}`):`${a.yellow("Not registered")} in ${e}`}function me(e,o){if(!X(e))return "";let t=spawnSync(e,o,{encoding:"utf8"}),i=`${t.stderr??""}${t.stdout??""}`.toLowerCase();return t.status===0?`${a.green("\u2713")} Removed via \`${e} mcp remove\``:/not found|no .*server|does not exist|no such/.test(i)?`${a.yellow("Not registered")} in ${e}`:`${a.red(`${e} mcp remove failed:`)} ${(t.stderr||t.stdout||"").trim()}`}function ue(e){if(!existsSync(e))return `${a.yellow("No hooks")} (${e} does not exist)`;let o=C(e);if(!o.ok)return o.error;let t=o.data.hooks??{},i=[];for(let[s,a]of Object.entries(t)){if(!a)continue;let r=a.filter(l=>!(l.hooks??[]).some(m=>Z(m.command??"")));r.length!==a.length&&(i.push(s),r.length?t[s]=r:delete t[s]);}return i.length===0?`${a.yellow("No devcoach hooks")} in ${e}`:(Object.keys(t).length===0&&delete o.data.hooks,writeFileSync(e,`${JSON.stringify(o.data,null,2)}
|
|
20
|
-
`),`${a.green("\u2713")} Hooks removed from ${e} (${i.join(" + ")})`)}function uo(e){return existsSync(join(e,"SKILL.md"))?(rmSync(e,{recursive:true,force:true}),`${a.green("\u2713")} Removed ${e}`):`${a.yellow("Not installed")} (${e})`}async function Uo(e){if(e)return true;if(!process.stdin.isTTY)return c(`${a.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 $o(e){let o=e.claudeCode||e.claudeDesktop||e.gemini||e.codex,t=e.all||e.claudeCode||!o,i=e.all||e.claudeDesktop||!o,s=e.all||e.gemini,a$1=e.all||e.codex;if(c(a.bold("Removing devcoach from your agents")),c(),t){c(a.bold("Claude Code"));let r=C(I);r.ok&&be(r.data)&&c(` ${a.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=me("claude",["mcp","remove","--scope","user","devcoach"]);l||(l=le(join(homedir(),".claude.json"))),c(` MCP server\u2026 ${l}`),c(` Hooks\u2026 ${ue(I)}`),c(` Skill\u2026 ${uo(Y)}`),c();}if(i&&(c(a.bold("Claude Desktop")),c(` MCP server\u2026 ${le(fo())}`),c(` ${a.yellow("\u2192")} Restart Claude Desktop to drop the server.`),c()),s){c(a.bold("Gemini CLI (beta)"));let r=me("gemini",["mcp","remove","-s","user","devcoach"]);r||(r=le(_)),c(` MCP server\u2026 ${r}`),c(` Hooks\u2026 ${ue(_)}`),q()&&c(` ${a.yellow("\u2192")} The devcoach Gemini extension is installed \u2014 remove it with: gemini extensions uninstall devcoach`),c();}if(a$1){c(a.bold("Codex CLI (beta)"));let r=me("codex",["mcp","remove","devcoach"]);r||(r=`${a.yellow("Manual step")} \u2014 codex CLI not found. Delete the [mcp_servers.devcoach] table from ${W}`),c(` MCP server\u2026 ${r}`),c(` Hooks\u2026 ${ue(O)}`),c();}if(s||a$1){let r=!s&&A(_,"AfterAgent")||!a$1&&A(O,"Stop");c(a.bold("Shared skill (Gemini + Codex)")),c(` Skill\u2026 ${r?`${a.yellow("Kept")} \u2014 still used by the other client (${H})`:uo(H)}`),c();}e.data?(c(a.bold("Coaching data")),existsSync(h)?await Uo(e.yes)?(rmSync(h,{recursive:true,force:true}),c(` ${a.green("\u2713")} Deleted ${h}`)):c(` ${a.yellow("Kept")} ${h}`):c(` ${a.yellow("Nothing to delete")} (${h} does not exist)`),c()):c(a.dim(`Your lessons, profile and notebook are still in ${h} \u2014 keep them for a
|
|
21
|
-
reinstall, or delete them with: devcoach uninstall --data (devcoach backup first).`)),c(a.dim(`Then remove the program itself: brew uninstall devcoach \xB7 npm uninstall -g devcoach
|
|
22
|
-
(npx: nothing to remove).`));}function Ko(e,o){return e==="darwin"?["open",[o]]:e==="win32"?["cmd",["/c","start","",o]]:["xdg-open",[o]]}function Ce(e,o=process.platform){let[t,i]=Ko(o,e);try{let s=spawn(t,i,{detached:!0,stdio:"ignore"});s.on("error",()=>{}),s.unref();}catch{}}var d=(e="")=>{console.log(e);},Co=e=>e==="junior"?a.green(e):e==="mid"?a.yellow(e):e==="senior"?a.red(e):e,Xo=e=>e==="know"?` ${a.green("\u2713")}`:e==="dont_know"?` ${a.red("\u2717")}`:"",qo=e=>e==="know"?a.green("\u2713 I know this"):e==="dont_know"?a.red("\u2717 I don't know this"):a.dim("no feedback");function So(e,o){let t=new Map;for(let s of e.groups)for(let a of s.topics)t.set(a,s.name);let i=[...e.knowledge].sort((s,a)=>a.confidence-s.confidence).map(s=>{let a=g$1(s.confidence);return [s.topic,t.get(s.topic)??"Other",b$3(a,`${s.confidence}/10`),b$3(a,f(s.confidence))]});return d$2(o,[{header:"Topic"},{header:"Group"},{header:"Confidence",justify:"right"},{header:"Bar"}],i)}function Zo(){let e=o(o=>$(o));d(So(e,"Knowledge Map"));}function Qo(e){let o$1=o(r$1=>r(r$1,{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(a.dim("No lessons found."));return}let t=o$1.some(r=>r.project||r.branch||r.commit_hash),i=[{header:""},{header:"Date"},{header:"Topic"},{header:"Title"},{header:"Level",justify:"center"},{header:"Categories"}];t&&i.push({header:"Project"},{header:"Branch"},{header:"Commit"});let s=o$1.some(r=>r.imported);s&&i.push({header:"Shared by"});let a$1=o$1.map(r=>{let l=[r.starred?a.yellow("\u2605"):a.dim("\xB7"),r.timestamp.slice(0,10),a.cyan(r.topic_id),r.title+Xo(r.feedback),Co(r.level),r.categories.join(", ")];return t&&l.push(r.project??"",r.branch?a.magenta(r.branch):"",r.commit_hash?a.cyan(r.commit_hash.slice(0,7)):""),s&&l.push(r.imported?r.shared_by??a.dim("anonymous"):""),l});d(d$2("Lessons",i,a$1));}function en(e){let o$1=o(i=>x(i,e));o$1===null&&(d(a.red(`Lesson '${e}' not found.`)),process.exit(1)),d(e$1(a.bold(o$1.title))),d(`${a.dim("ID:")} ${o$1.id}`),d(`${a.dim("Date:")} ${o$1.timestamp.slice(0,19).replace("T"," ")}`),d(`${a.dim("Topic:")} ${o$1.topic_id}`),d(`${a.dim("Categories:")} ${o$1.categories.join(", ")}`),d(`${a.dim("Level:")} ${Co(o$1.level)}`);let t=o$1.starred?a.yellow("\u2605 starred"):a.dim("\u2606 not starred");if(d(`${a.dim("Star:")} ${t} ${a.dim("Feedback:")} ${qo(o$1.feedback)}`),o$1.imported&&d(`${a.dim("Shared by:")} ${o$1.shared_by??a.dim("anonymous")}`),o$1.task_context&&d(`${a.dim("Context:")} ${o$1.task_context}`),o$1.project||o$1.repository||o$1.branch||o$1.commit_hash||o$1.folder){let i=[];o$1.project&&i.push(`project=${o$1.project}`),o$1.repository&&i.push(`repo=${o$1.repository}`),o$1.branch&&i.push(`branch=${a.magenta(o$1.branch)}`),o$1.commit_hash&&i.push(`commit=${a.cyan(o$1.commit_hash.slice(0,7))}`),o$1.folder&&i.push(`folder=${o$1.folder}`),d(`${a.dim("Git:")} ${i.join(" \xB7 ")}`);}d(e$1()),d(o$1.summary);}function vo(e,o$1){o(i=>x(i,e)===null?false:(t(i,e,o$1),true))||(d(a.red(`Lesson '${e}' not found.`)),process.exit(1)),d(o$1?`Lesson ${a.cyan(e)} \u2192 ${a.yellow("\u2605 starred")}`:`Lesson ${a.cyan(e)} \u2192 ${a.dim("\u2606 unstarred")}`);}function on(e){o(t=>s(t,e))||(d(a.red(`Lesson '${e}' not found.`)),process.exit(1)),d(`Lesson ${a.cyan(e)} deleted.`);}function nn(e,o$1){["know","dont_know","clear"].includes(o$1)||(d(a.red(`Invalid feedback '${o$1}'. Use: know | dont_know | clear`)),process.exit(1));let t=o$1==="clear"?null:o$1,i=o(r=>{let l=ba(r,e,t);if(l===null)return null;let m=r.prepare("SELECT confidence FROM knowledge WHERE topic = ?").get(l);return {topicId:l,newConf:m?m.confidence:5}});i===null&&(d(a.red(`Lesson '${e}' not found.`)),process.exit(1));let s;if(t==="know"||t==="dont_know"){let r=i.newConf+(t==="know"?-1:1);s=`${a.cyan(i.topicId)} confidence: ${r} \u2192 ${a.bold(String(i.newConf))}`;}else s="feedback cleared";let a$1=t==="know"?a.green("\u2713 I know this"):t==="dont_know"?a.red("\u2717 I don't know this"):a.dim("cleared");d(`Lesson ${a.cyan(e)} \u2192 ${a$1} (${s})`);}function tn(){let e=o(s=>G(s)),o$1=Math.floor(e.min_gap_minutes/60),t=e.min_gap_minutes%60,i=o$1?`${o$1}h ${t}m`:`${t}m`;d(d$2("Settings",[{header:"Key"},{header:"Value",justify:"right"}],[["max_per_day",String(e.max_per_day)],["min_gap_minutes",`${e.min_gap_minutes} (${i})`],["nudge_every",e.nudge_every===0?"0 (off)":String(e.nudge_every)],["nudge_scope",e.nudge_scope],["share_name",e.share_name??a.dim("(unset \u2192 git user.name)")]]));}function rn(){let{stats:e,rateLimit:o$1,settings:t}=o(m=>({stats:ca(m),rateLimit:_$1(m),settings:G(m)})),i=m=>Number(e[m]??0),s=o$1.allowed?a.green("Available now"):a.yellow(o$1.reason??"");d(d$2("Coaching Stats",[{header:"Metric"},{header:"Value",justify:"right"}],[["Total lessons",String(i("total_lessons"))],["Lessons today (24h)",`${i("lessons_today")} / ${t.max_per_day}`],["Lessons this week",String(i("lessons_this_week"))],["Next lesson",s]],false));let a$1=e.weakest_topics??[],r=e.strongest_topics??[];if(a$1.length||r.length){let m=[];for(let k=0;k<Math.max(a$1.length,r.length);k++){let p=a$1[k],u=r[k];m.push([p?`${a.red(p.topic)} ${a.dim(`(${p.confidence})`)}`:"",u?`${a.green(u.topic)} ${a.dim(`(${u.confidence})`)}`:""]);}d(d$2(void 0,[{header:"Weakest topics"},{header:"Strongest topics"}],m));}let l=$e();l&&d(`
|
|
23
|
-
${l}`);}function sn(e,o$1){let t=["max_per_day","min_gap_minutes","nudge_every","nudge_scope","share_name"];if(t.includes(e)||(d(a.red(`Unknown key '${e}'. Valid keys: ${t.join(", ")}`)),process.exit(1)),e==="nudge_scope"&&o$1!=="session"&&o$1!=="global"&&(d(a.red(`Invalid nudge_scope '${o$1}'. Use: session | global`)),process.exit(1)),e==="share_name"){o$1.trim().length>l&&(d(a.red(`share_name must be at most ${l} characters.`)),process.exit(1));let i=m(o$1);o(s=>H$1(s,e,i)),d(i?a.green(`Set share_name = ${i}`):a.green("Cleared share_name"));return}if(e==="nudge_every"){let i=Number.parseInt(o$1,10);(!Number.isInteger(i)||i<0)&&(d(a.red(`Invalid nudge_every '${o$1}'. Use a non-negative integer (0 = off).`)),process.exit(1));}o(i=>H$1(i,e,o$1)),d(a.green(`Set ${e} = ${o$1}`));}function an(e,o$1,t){let i=e.trim();i||(d(a.red("Topic name must not be empty.")),process.exit(1)),o(a=>{A$1(a,i,o$1),t&&t!=="Other"&&E(a,i,t);});let s=t&&t!=="Other"?` \u2192 ${a.cyan(t)}`:"";d(`${a.green("Added")} ${a.bold(i)} (confidence ${a.cyan(String(o$1))})${s}`);}function dn(e){let o$1=o(t=>B(t,e));d(o$1?`${a.green("Removed")} ${a.bold(e)} from knowledge map`:a.yellow(`Topic '${e}' not found.`));}function cn(e){let o$1=e.trim();(!o$1||o$1==="Other")&&(d(a.red("Invalid group name.")),process.exit(1)),o(t=>C$1(t,o$1)),d(`${a.green(`Group '${a.cyan(o$1)}' ready.`)} Assign topics with: devcoach group-assign <topic> "${o$1}"`);}function ln(e){let o$1=o(t=>D(t,e));d(o$1?`${a.green(`Removed group '${a.cyan(e)}'`)}`:a.yellow(`Group '${e}' not found.`));}function mn(e,o$1){o(i=>i.prepare("SELECT topic FROM knowledge WHERE topic = ?").get(e)===void 0?false:(o$1==="Other"?F(i,e):E(i,e,o$1),true))||(d(a.red(`Topic '${e}' not in knowledge map. Add it first.`)),process.exit(1)),d(o$1==="Other"?`${a.green("Moved")} ${a.bold(e)} \u2192 Other (ungrouped)`:`${a.green("Moved")} ${a.bold(e)} \u2192 ${a.cyan(o$1)}`);}function un(e){let{lessonsCount:o$1,knowledgeCount:t,data:i}=o(a=>({lessonsCount:v(a).length,knowledgeCount:z(a).length,data:O$1(a)}));writeFileSync(e,i);let s=existsSync(j$1)?" + notebook":"";d(`${a.green("Backup saved:")} ${e} (${a.cyan(String(o$1))} lessons, ${a.cyan(String(t))} topics${s})`);}function pn(e){existsSync(e)||(d(a.red(`File not found: ${e}`)),process.exit(1));let o$1=o(i=>P(i,readFileSync(e)));o$1.settings&&d(`${a.green("\u2713")} Settings restored`),o$1.topics&&d(`${a.green("\u2713")} Knowledge map restored (${a.cyan(String(o$1.topics))} topics)`);let t=[`${a.cyan(String(o$1.lessons))} imported`];o$1.skipped&&t.push(`${a.yellow(String(o$1.skipped))} duplicates skipped`),o$1.invalid&&t.push(`${a.red(String(o$1.invalid))} rejected (invalid)`),d(`${a.green("\u2713")} Lessons: ${t.join(", ")}`),o$1.learning_state&&d(`${a.green("\u2713")} Notebook restored`);}var Q=e=>{console.error(a.dim(e));};function gn(e,o$1){o$1.by!==void 0&&o$1.anonymous&&(d(a.red("Use either --by <name> or --anonymous, not both.")),process.exit(1)),!e&&!o$1.last&&(d(a.red("Give a lesson id, or --last for the most recent one.")),process.exit(2));let t=o(a=>{let r$1=o$1.last?r(a,{imported:false,page:1,per_page:1})[0]??null:x(a,e);if(!r$1)return null;let l=G(a),m$1=T({explicit:o$1.by??null,anonymous:o$1.anonymous,setting:l.share_name,gitUserName:a$1()}),k=false;return o$1.by?.trim()&&!l.share_name&&(H$1(a,"share_name",m(o$1.by)),k=true),{payload:S$1(r$1,{includeContext:!!o$1.withContext,sharedBy:m$1}),remembered:k}});t||(d(a.red(o$1.last?"No lessons to share yet.":`Lesson '${e}' not found.`)),process.exit(1));let{payload:i,remembered:s}=t;if(o$1.file!==void 0&&o$1.file!==false){let a$1=typeof o$1.file=="string"?o$1.file:Y$1(i);writeFileSync(a$1,Z$1(i)),d(`${a.green("Saved:")} ${a$1}`);}else o$1.link?d(X$1(i)):(d(W$1(i)),U(i).length>16e3&&Q("Long lesson \u2014 prefer --file for a friendlier hand-off."));s&&Q("(remembered as share_name \u2014 change it with: devcoach set share_name <name>)"),i.shared_by===null&&Q("Shared anonymously (set a name with: devcoach set share_name <name>)");}function fn(){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 i=execFileSync(o,t,{encoding:"utf8",timeout:3e3,stdio:["ignore","pipe","ignore"]});if(i.trim())return i}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 hn(e){return e===void 0?fn():e==="-"?text(process.stdin):existsSync(e)?readFileSync(e,"utf8"):c$2(e)&&!e.includes("#devcoach:lesson:")?d$3(e):e}async function kn(e){try{let o$1=await hn(e),t=o(a=>da(a,o$1));if(t.kind==="lessons"){let a$1=[`${a.cyan(String(t.inserted))} imported`];t.duplicated&&a$1.push(`${a.yellow(String(t.duplicated))} duplicates skipped`),t.invalid&&a$1.push(`${a.red(String(t.invalid))} rejected (invalid)`),d(`${a.green("\u2713")} Lessons: ${a$1.join(", ")}`);return}let i=t.lesson;i||(d(a.red("Could not store the lesson.")),process.exit(1));let s=i.shared_by?`shared by ${i.shared_by}`:"shared anonymously";t.duplicated?d(`${a.yellow("Already in your log")} as ${a.cyan(i.id)} (${s})`):d(`${a.green("\u2713 Imported")} ${a.bold(`"${i.title}"`)} (${s}) as ${a.cyan(i.id)} \u2014 topic ${a.cyan(i.topic_id)}`),t.topic_tracked===!1&&Q(`Topic '${i.topic_id}' is not in your knowledge map \u2014 track it with: devcoach knowledge-add ${i.topic_id}`);}catch(o){if(!(o instanceof R))throw o;d(a.red(o.message)),process.exit(1);}}async function bn(){let e=createInterface({input:process.stdin,output:process.stdout}),o$1=async(i,s="")=>{let a=s?` [${s}]`:"";return (await e.question(`${i}${a}: `)).trim()||s},t=async(i,s,a$1,r)=>{for(;;){let l=await o$1(i,String(s)),m=Number.parseInt(l,10);if(!Number.isNaN(m)&&m>=a$1&&m<=r)return m;d(a.red(`Must be ${a$1}\u2013${r}.`));}};try{d(e$1(a.bold("devcoach setup"))),d(`
|
|
24
|
-
${a.bold("Step 1")} \u2014 Restore from backup`);let i=await o$1("Path to existing backup zip (Enter to skip)","");if(i){existsSync(i)||(d(a.red(`File not found: ${i}`)),process.exit(1));let p=o(u=>P(u,readFileSync(i)));d(`${a.green("\u2713")} Restored: ${p.topics} topics, ${p.lessons} lessons${p.learning_state?", notebook":""}`),d(a.green("Setup complete!"));return}d(`
|
|
25
|
-
${a.bold("Step 2")} \u2014 Build your knowledge profile`);let s=(await o$1("Mode: [a]utomatic (detect from files) / [m]anual (type your stack)","a")).toLowerCase(),a$1={};if(s.startsWith("a")){let u=b$1().folder??process.cwd(),g=c$1(),y=b$2(a$2(u),g.detected_stack),b=Object.keys(y).sort((v,R)=>v.localeCompare(R));if(g.scanned_projects>0){d(`
|
|
26
|
-
${a.dim(`Scanned ${g.scanned_projects} Claude Code project(s) from your history:`)}`);for(let v of g.projects.slice(0,8))d(a.dim(` ${v.name} \u2014 ${v.topics.join(", ")||"no stack signals"}`));}if(b.length){d(`
|
|
27
|
-
${a.dim(`Detected (history + ${a.cyan(u)}):`)}`);for(let v of b){let R=y[v]??5,xe=await o$1(` ${a.cyan(v)} (Enter=keep, 0-10=override, s=skip)`,String(R));if(xe.toLowerCase()==="s")continue;let _e=Number.parseInt(xe,10);a$1[v]=Number.isNaN(_e)?R:Math.max(0,Math.min(10,_e));}}else d(a.dim("No technology files detected in current directory."));let P=await o$1(`
|
|
28
|
-
Add additional topics (comma-separated, or Enter to skip)`,"");for(let v of P.split(",").map(R=>R.trim()).filter(Boolean))a$1[v]=await t(` Confidence for ${a.cyan(v)}`,5,0,10);}else for(d(a.dim(`
|
|
29
|
-
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+/),g=u[0]??"",y=Number.parseInt(u[1]??"",10),b=Number.isNaN(y)?5:Math.max(0,Math.min(10,y));a$1[g]=b,d(` ${a.green("+")} ${a.cyan(g)} \u2192 ${b}`);}let r={};if(Object.keys(a$1).length&&(d(`
|
|
30
|
-
${a.bold("Step 3")} \u2014 Organise into groups`),(await o$1("Organise topics into groups? [y/N]","n")).toLowerCase().startsWith("y"))){let u=[];for(let g of Object.keys(a$1).sort((y,b)=>y.localeCompare(b))){let y=u.length?u.join(", "):"(none yet)",b=await o$1(` Group for ${a.cyan(g)} existing: ${a.dim(y)} (Enter=Other)`,"");if(b&&b!=="Other"){let P=r[b]??[];P.push(g),r[b]=P,u.includes(b)||u.push(b);}}}d(`
|
|
31
|
-
${a.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),k=o(p=>{p.exec("DELETE FROM knowledge; DELETE FROM knowledge_groups; DELETE FROM knowledge_group_names;");for(let[u,g]of Object.entries(a$1))A$1(p,u,g);for(let[u,g]of Object.entries(r))for(let y of g)E(p,y,u);return H$1(p,"max_per_day",String(l)),H$1(p,"min_gap_minutes",String(m)),$(p)});d(So(k,"Knowledge Profile")),d(`
|
|
32
|
-
${a.green("Setup complete!")} ${Object.keys(a$1).length} topics saved.`);}finally{e.close();}}function yn(){let e=[["mcp","Start the MCP server (stdio) for Claude Code / Claude Desktop"],["ui [--port N] [--open|--stop]","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(`
|
|
33
|
-
${a.bold(`devcoach ${a.dim(`v${Q$1}`)}`)}`);for(let[t,i]of e)d(` ${a.cyan(`devcoach ${t}`.padEnd(32))} ${a.dim(i)}`);d(`
|
|
34
|
-
${a.dim("Run")} ${a.bold("devcoach <command> --help")} ${a.dim("for per-command options.")}
|
|
35
|
-
`);let o=$e();o&&d(`${o}
|
|
36
|
-
`);}function S(e){return e??null}function $n(){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(()=>yn()),e$1.command("mcp").description("Start the MCP server (stdio transport)").action(async()=>{let{runStdio:o}=await import('./server-SM63J4EC.js');await o();}),e$1.command("profile").description("Show the knowledge map").action(Zo),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=>Qo({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=>en(o)),e$1.command("star").description("Mark a lesson as starred").argument("<id>","Lesson ID").action(o=>vo(o,true)),e$1.command("unstar").description("Remove the starred mark from a lesson").argument("<id>","Lesson ID").action(o=>vo(o,false)),e$1.command("delete").description("Permanently delete a lesson").argument("<id>","Lesson ID").action(o=>on(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)=>nn(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)=>gn(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=>kn(o)),e$1.command("settings").description("Show current settings").action(tn),e$1.command("stats").description("Coaching statistics and rate-limit status").action(rn),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)=>sn(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)=>an(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=>dn(o)),e$1.command("group-add").description("Register a new knowledge group").argument("<name>","Group name").action(o=>cn(o)),e$1.command("group-remove").description("Delete a knowledge group (topics move to Other)").argument("<name>","Group name").action(o=>ln(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)=>mn(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=>un(o)),e$1.command("restore").description("Restore from a backup zip file").argument("<file>","Path to backup zip").action(o=>pn(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=>bo({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=>$o({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(yo),e$1.command("ui").description("Launch the web dashboard (Ctrl+C stops it gracefully; --stop stops a running one)").option("--port <port>","Port","7860").option("-o, --open","Open the dashboard in your default browser").option("--stop","Stop the dashboard running on --port (e.g. one started by your agent)").action(async o=>{let t=Number.parseInt(o.port??"7860",10)||7860,{startUi:i,stopUi:s}=await import('./app-SVGKP5WG.js');if(o.stop){d(await s(t)?a.green(`\u2713 devcoach UI on port ${t} stopped`):a.yellow(`No devcoach UI is running on port ${t}`));return}i(t,{onReady:a=>{o.open&&Ce(a);},onListenError:a=>{console.error(a.message),o.open&&a.existingUrl&&Ce(a.existingUrl),process.exit(a.exitCode);}});}),e$1.command("setup").description("First-run wizard: import backup or build your knowledge profile").action(bn),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 Jn(){let e=$n();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{Jn as runCli};
|
package/dist/server-SM63J4EC.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
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-4PFP67XN.js';import {a,c as c$1,b,f,e,Q,o,N as N$1,g,p,J,aa,r,t,s,u as u$1,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-JEFYE33I.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 l=o=>({type:"text",text:o}),fe=o=>({content:[l(JSON.stringify(o))]}),c=o=>({isError:true,content:[l(o)]}),m=o=>({content:[l(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."},Ue="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.",Ge=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 u(o,p){return {contents:[{uri:o.href,mimeType:"application/json",text:JSON.stringify(p)}]}}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 p=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:p,notebook_ready:d,needs_onboarding:!(p&&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,p)=>typeof p.error=="string"?c(`${o} failed: ${p.error}`):m(p);function Fe(){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(a,i),J(a);}),{content:[l(`Lesson saved. ${ye}`),l(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:[l(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:[l(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:[l(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$1(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:[l(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:[l("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:[l("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:[l(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:[l("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:[l(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}},async e=>{let n=e.port;if(!(n>=1024&&n<=65535))return {content:[l(`error: port ${n} is out of valid range (1024-65535)`)]};let{pingUi:r}=await import('./app-SVGKP5WG.js');return await r(n)?{content:[l(`devcoach UI is already running at http://localhost:${n}`)]}:(spawn(process.execPath,[process.argv[1]??"","ui","--port",String(n)],{detached:true,stdio:"ignore"}).unref(),{content:[l(`devcoach UI starting at http://localhost:${n}`)]})}),o$1.registerTool("stop_ui",{title:"Stop UI",description:"Stop the devcoach web dashboard listening on port (whoever started it \u2014 open_ui or a terminal). Graceful: in-flight requests finish first. Reports stopped=false when nothing is running there. port must be 1024-65535.",inputSchema:z.object({port:z.number().int().default(7860).describe("Port (default 7860)")}),annotations:{title:"Stop UI",destructiveHint:false,idempotentHint:true,openWorldHint:true}},async e=>{let n=e.port;if(!(n>=1024&&n<=65535))return {content:[l(`error: port ${n} is out of valid range (1024-65535)`)]};let{stopUi:r}=await import('./app-SVGKP5WG.js'),i=await r(n);return {content:[l(i?`devcoach UI on port ${n} stopped`:`No devcoach UI is running on port ${n}`)],structuredContent:{stopped:i,port:n}}}),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
|
-
`),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:Ge,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 p$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:p$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:p$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:p$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:p$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:Ue})}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=>u(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 u(e,o(n=>G(n)))}catch(n){return u(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 u(e,o(n=>r(n,{period:"week",page:1,per_page:10})))}catch(n){return u(e,[{error:String(n)}])}}),o$1.registerResource("stats","devcoach://stats",d$3("Stats","Aggregate coaching statistics: counts and weakest/strongest topics."),e=>{try{return u(e,o(n=>ca(n)))}catch(n){return u(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 u(e,o(n=>ea(n)))}catch{return u(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),u(e,i)}catch(n){return u(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=>u(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 u(e,{git:n,usage_defaults:r})}catch(n){return u(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=>u(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?u(e,i):u(e,{error:`Lesson '${r}' not found`})}catch(r){return u(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
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
<!-- reference: ${n.name} -->
|
|
8
|
-
|
|
9
|
-
${n.content}`).join("");return {messages:[{role:"user",content:{type:"text",text:e$1()+e}}]}}),o$1}async function ot(){let o=Fe(),p=new StdioServerTransport;await o.connect(p);}export{Fe as createServer,ot as runStdio};
|