devcoach 2.0.2 → 2.1.0-next.503.g8594664
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -13
- package/assets/SKILL.md +22 -1
- package/assets/static/share.js +66 -0
- package/assets/static/vendor/purify.min.js +3 -0
- package/dist/{app-GO3HPOM6.js → app-KE4H5NNP.js} +198 -96
- package/dist/bin.js +1 -1
- package/dist/chunk-2LE7K3NO.js +15 -0
- package/dist/chunk-3RBMKXAA.js +2 -0
- package/dist/chunk-4KFSUF7S.js +75 -0
- package/dist/chunk-MRABMPXO.js +3 -0
- package/dist/commands-WO3BAZJM.js +33 -0
- package/dist/{hooks-4E5KRWGP.js → hooks-6I6M3PGN.js} +1 -1
- package/dist/server-JJASGVG5.js +9 -0
- package/package.json +1 -1
- package/dist/chunk-ECN4MNGM.js +0 -66
- package/dist/chunk-QGXVUN7G.js +0 -15
- package/dist/chunk-TGTNEQU4.js +0 -3
- package/dist/commands-QBSCNZVJ.js +0 -33
- package/dist/server-FARS47NV.js +0 -9
package/dist/bin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var t=process.argv[2]??"",r=new Set(["stop-hook","prompt-hook","gemini-stop-hook","gemini-prompt-hook","codex-stop-hook","codex-prompt-hook","onboard-hook","lesson-ready"]);try{if(r.has(t)){let{runHook:o}=await import('./hooks-
|
|
2
|
+
var t=process.argv[2]??"",r=new Set(["stop-hook","prompt-hook","gemini-stop-hook","gemini-prompt-hook","codex-stop-hook","codex-prompt-hook","onboard-hook","lesson-ready"]);try{if(r.has(t)){let{runHook:o}=await import('./hooks-6I6M3PGN.js');o(t);}else {let{runCli:o}=await import('./commands-WO3BAZJM.js');await o();}}catch(o){console.error(o),process.exit(1);}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {i,o,M,ga,h as h$1,n,fa}from'./chunk-4KFSUF7S.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {R,Q}from'./chunk-4KFSUF7S.js';import {execFileSync}from'child_process';import {basename}from'path';import U from'dns';import P from'http';import A from'https';import {isIP}from'net';function f(...e){try{return execFileSync("git",e,{encoding:"utf8",timeout:3e3,stdio:["ignore","pipe","ignore"]}).trim()||null}catch{return null}}var w={"github.com":"github","gitlab.com":"gitlab","bitbucket.org":"bitbucket"};function T(e){if(!e)return [null,null];let t=/^git@([^:]+):(.+?)(?:\.git)?$/.exec(e);if(t){let o=(t[1]??"").toLowerCase();return [t[2]??e,w[o]??"local"]}let n=/^https?:\/\/([^/]+)\/(.+?)(?:\.git)?$/.exec(e);if(n){let o=(n[1]??"").toLowerCase();return [n[2]??e,w[o]??"local"]}return [e,"local"]}function F(){return f("config","user.name")}function G(){let e=process.cwd(),t=f("rev-parse","--abbrev-ref","HEAD"),n=f("rev-parse","HEAD"),o=f("remote","get-url","origin"),[s,l]=T(o),u;return s?u=s.replace(/\/+$/,"").split("/").pop()??null:u=basename(e)||null,t==="HEAD"&&(t=null),{project:u,repository:s,branch:t,commit_hash:n,folder:e,repository_platform:l}}var y="That URL is too large to be a lesson.",m="Only public http(s) URLs can be imported.",k=new Set([301,302,303,307,308]);function E(e){return /^https?:\/\/\S+$/i.test(e.trim())}function x(e){let[t=0,n=0]=e.split(".").map(Number);return t===0||t===10||t===127||t===169&&n===254||t===172&&n>=16&&n<=31||t===192&&n===168||t===100&&n>=64&&n<=127||t>=224}function L(e){let t=e.replace(/^\[|\]$/g,"").replace(/%.*$/,"").toLowerCase();if(isIP(t)===4)return x(t);if(isIP(t)!==6)return true;let n=/^::ffff:(\d+\.\d+\.\d+\.\d+)$/.exec(t);if(n?.[1])return x(n[1]);if(t==="::"||t==="::1")return true;let o=t.split(":")[0]??"";return !!(/^f[cd]/.test(o)||/^fe[89ab]/.test(o))}async function $(e){return (await U.promises.lookup(e,{all:true})).map(n=>n.address)}async function C(e,t){let n=e.hostname.replace(/^\[|\]$/g,"").toLowerCase();if(n==="localhost"||n.endsWith(".localhost"))throw new R(m);if(isIP(n)){if(L(n))throw new R(m);return n}let o;try{o=await t(n);}catch{throw new R("The URL could not be reached \u2014 copy the lesson text instead.")}let s=o[0];if(!s||o.some(l=>L(l)))throw new R(m);return s}var v=(e,t,n)=>new Promise((o,s)=>{let l=isIP(t)===6?6:4,u=(r,a,h)=>{a.all?h(null,[{address:t,family:l}]):h(null,t,l);},p=(e.protocol==="https:"?A:P).request(e,{method:"GET",lookup:u,signal:n,headers:{accept:"text/plain, text/markdown, application/json;q=0.9, */*;q=0.5","user-agent":`devcoach/${Q}`}},r=>{let a=r.headers["content-length"];o({status:r.statusCode??0,location:r.headers.location??null,contentLength:a===void 0?null:Number(a),body:r,abort:()=>r.destroy()});});p.on("error",s),p.end();});async function O(e,t){if(e.contentLength!==null&&e.contentLength>t)throw e.abort(),new R(y);let n=[],o=0;for await(let s of e.body){if(o+=s.byteLength,o>t)throw e.abort(),new R(y);n.push(s);}return Buffer.concat(n).toString("utf8")}async function V(e,t={}){let n=t.timeoutMs??5e3,o=t.maxBytes??256*1024,s=t.maxRedirects??3,l=t.lookup??$,u=t.transport??v;if(!E(e))throw new R("Only http(s) URLs can be imported.");let g=new AbortController,p=setTimeout(()=>g.abort(),n);try{let r=new URL(e.trim());for(let a=0;;a++){let h=await C(r,l),c=await u(r,h,g.signal);if(k.has(c.status)){if(c.abort(),!c.location||a>=s)throw new R("The URL redirects too many times \u2014 copy the lesson text instead.");if(r=new URL(c.location,r),!/^https?:$/.test(r.protocol))throw new R(m);continue}if(c.status<200||c.status>=300)throw c.abort(),new R(`The URL answered ${c.status} \u2014 nothing to import there.`);return await O(c,o)}}catch(r){if(r instanceof R)throw r;let a=r?.name==="AbortError"?"timed out":"could not be reached";throw new R(`The URL ${a} \u2014 copy the lesson text instead.`)}finally{clearTimeout(p);}}export{F as a,G as b,E as c,V as d};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {z as z$1}from'zod';import {existsSync,readFileSync,mkdirSync,writeFileSync}from'fs';import {createRequire}from'module';import {homedir}from'os';import {join,dirname}from'path';import {strToU8,zipSync,unzipSync,deflateSync,strFromU8,Inflate}from'fflate';var C=z$1.enum(["junior","mid","senior"]),U=z$1.enum(["github","gitlab","bitbucket","local"]),ke=z$1.enum(["know","dont_know"]),jt=z$1.number().int().min(0).max(10);function F(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}function ve(e){if(e instanceof Date){if(Number.isNaN(e.getTime()))throw new TypeError("Invalid Date");return e}let t=e.trim();/[zZ]$|[+-]\d{2}:?\d{2}$/.test(t)||(t=t.includes("T")||t.includes(" ")?`${t.replace(" ","T")}Z`:`${t}T00:00:00Z`);let s=new Date(t);if(Number.isNaN(s.getTime()))throw new TypeError(`Cannot parse timestamp ${JSON.stringify(e)} \u2014 expected ISO 8601`);return s}function Ae(e){let t=ve(e),n=new Date;return t.getTime()>n.getTime()&&(t=n),F(t)}var Ce=z$1.union([z$1.string(),z$1.date()]).transform((e,t)=>{try{return Ae(e)}catch(n){return t.addIssue({code:"custom",message:n.message}),z$1.NEVER}}),_=z$1.string().nullish().transform(e=>e??null),Ue=z$1.object({id:z$1.string(),timestamp:Ce,topic_id:z$1.string(),categories:z$1.array(z$1.string()),title:z$1.string(),level:C,summary:z$1.string(),body:_,task_context:_,project:_,repository:_,branch:_,commit_hash:_,folder:_,repository_platform:U.nullish().transform(e=>e??null),starred:z$1.boolean().default(false),feedback:ke.nullish().transform(e=>e??null),imported:z$1.boolean().default(false),shared_by:_}),Fe=z$1.object({topic:z$1.string(),confidence:z$1.number().int()}),$e=z$1.object({name:z$1.string(),topics:z$1.array(z$1.string())});z$1.object({knowledge:z$1.array(Fe),groups:z$1.array($e)});var Me=z$1.enum(["system","dark","light"]),Pe=z$1.enum(["session","global"]);z$1.object({max_per_day:z$1.number().int().default(2),min_gap_minutes:z$1.number().int().default(240),ui_theme:Me.default("system"),nudge_every:z$1.number().int().min(0).default(10),nudge_scope:Pe.default("session"),share_name:z$1.string().nullable().default(null)});function T(e){return Ue.parse(e)}var {DatabaseSync:Ye}=createRequire(import.meta.url)("node:sqlite"),oe=process.env.DEVCOACH_DIR??join(homedir(),".devcoach"),B=join(oe,"coaching.db"),N=join(oe,"learning-state.md"),$="settings.json",M="lessons.json",P="knowledge.json",j="learning-state.md",qt={engineering:8,architecture:8,patterns:7,debugging:8,node:7,javascript:7,typescript:6,python:4,django:3,fastapi:4,docker:8,traefik:7,coolify:7,postgresql:6,redis:6,git:7,ci_cd:6,security:5,performance:6,testing:5,linux:7,networking:6,react:5,frontend:5},ze=80;function Je(e){return e.trim().slice(0,ze)}var qe={max_per_day:"2",min_gap_minutes:"240",ui_theme:"system",nudge_every:"10",nudge_scope:"session",share_name:""},Ve=50;function f(e,t,...n){return e.prepare(t).all(...n)}function h(e,t,...n){return e.prepare(t).get(...n)}function u(e,t,...n){return Number(e.prepare(t).run(...n).changes)}function Ze(e=B){e!==":memory:"&&mkdirSync(dirname(e),{recursive:true});let t=new Ye(e);return t.exec("PRAGMA busy_timeout = 3000"),t}var ee=3;function Qe(e=B){let t=Ze(e),n=t.prepare("PRAGMA user_version").get();return Number(n?.user_version??0)!==ee&&(et(t),t.exec(`PRAGMA user_version = ${ee}`)),t}function Vt(e,t){e.exec("BEGIN IMMEDIATE");try{let n=t();return e.exec("COMMIT"),n}catch(n){try{e.exec("ROLLBACK");}catch{}throw n}}function Zt(e,t=B){let n=Qe(t);try{return e(n)}finally{n.close();}}function et(e){e.exec(`
|
|
3
|
+
CREATE TABLE IF NOT EXISTS lessons (
|
|
4
|
+
id TEXT PRIMARY KEY,
|
|
5
|
+
timestamp TEXT NOT NULL,
|
|
6
|
+
topic_id TEXT NOT NULL,
|
|
7
|
+
categories TEXT NOT NULL,
|
|
8
|
+
title TEXT NOT NULL,
|
|
9
|
+
level TEXT NOT NULL,
|
|
10
|
+
summary TEXT NOT NULL,
|
|
11
|
+
body TEXT,
|
|
12
|
+
task_context TEXT,
|
|
13
|
+
project TEXT,
|
|
14
|
+
repository TEXT,
|
|
15
|
+
branch TEXT,
|
|
16
|
+
commit_hash TEXT,
|
|
17
|
+
folder TEXT,
|
|
18
|
+
feedback TEXT,
|
|
19
|
+
repository_platform TEXT,
|
|
20
|
+
starred INTEGER NOT NULL DEFAULT 0,
|
|
21
|
+
imported INTEGER NOT NULL DEFAULT 0,
|
|
22
|
+
shared_by TEXT
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
CREATE TABLE IF NOT EXISTS knowledge (
|
|
26
|
+
topic TEXT PRIMARY KEY,
|
|
27
|
+
confidence INTEGER NOT NULL DEFAULT 5,
|
|
28
|
+
updated_at TEXT NOT NULL
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
CREATE TABLE IF NOT EXISTS settings (
|
|
32
|
+
key TEXT PRIMARY KEY,
|
|
33
|
+
value TEXT NOT NULL
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
CREATE TABLE IF NOT EXISTS knowledge_group_names (
|
|
37
|
+
group_name TEXT PRIMARY KEY
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
CREATE TABLE IF NOT EXISTS knowledge_groups (
|
|
41
|
+
group_name TEXT NOT NULL,
|
|
42
|
+
topic TEXT NOT NULL,
|
|
43
|
+
PRIMARY KEY (group_name, topic)
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
-- Runtime-only: per-session interaction counter for lesson-cue pacing.
|
|
47
|
+
-- Never exported/imported (backup carries config, not this state).
|
|
48
|
+
CREATE TABLE IF NOT EXISTS nudge_state (
|
|
49
|
+
session_id TEXT PRIMARY KEY,
|
|
50
|
+
interactions INTEGER NOT NULL DEFAULT 0,
|
|
51
|
+
updated_at TEXT NOT NULL
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
-- Runtime-only, single row: cue lifecycle. pending=1 between an emitted cue and
|
|
55
|
+
-- its resolution (log_lesson or skip_lesson), arming a shorter retry threshold.
|
|
56
|
+
CREATE TABLE IF NOT EXISTS cue_state (
|
|
57
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
58
|
+
pending INTEGER NOT NULL DEFAULT 0,
|
|
59
|
+
last_cue_at TEXT,
|
|
60
|
+
last_skip_reason TEXT
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
CREATE INDEX IF NOT EXISTS idx_lessons_timestamp ON lessons (timestamp);
|
|
64
|
+
CREATE INDEX IF NOT EXISTS idx_lessons_starred_ts ON lessons (starred, timestamp);
|
|
65
|
+
CREATE INDEX IF NOT EXISTS idx_lessons_feedback ON lessons (feedback);
|
|
66
|
+
CREATE INDEX IF NOT EXISTS idx_lessons_topic_id ON lessons (topic_id);
|
|
67
|
+
`),tt(e),nt(e);}function tt(e){for(let t of ["ALTER TABLE lessons ADD COLUMN body TEXT","ALTER TABLE lessons ADD COLUMN imported INTEGER NOT NULL DEFAULT 0","ALTER TABLE lessons ADD COLUMN shared_by TEXT"])try{e.exec(t);}catch{}}function nt(e){for(let[t,n]of Object.entries(qe))u(e,"INSERT OR IGNORE INTO settings (key, value) VALUES (?, ?)",t,n);}var re="(id, timestamp, topic_id, categories, title, level, summary, body, task_context, project, repository, branch, commit_hash, folder, repository_platform, starred, feedback, imported, shared_by)",ie="(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";function ae(e){return [e.id,e.timestamp,e.topic_id,JSON.stringify(e.categories),e.title,e.level,e.summary,e.body,e.task_context,e.project,e.repository,e.branch,e.commit_hash,e.folder,e.repository_platform,e.starred?1:0,e.feedback,e.imported?1:0,e.shared_by]}function Qt(e,t){u(e,`INSERT OR REPLACE INTO lessons ${re} VALUES ${ie}`,...ae(t));}function G(e,t){return u(e,`INSERT OR IGNORE INTO lessons ${re} VALUES ${ie}`,...ae(t))>0}var st=[["project","project"],["repository","repository"],["branch","branch"],["commit","commit_hash"]];function ot(e,t){if(e.date_from==null&&e.date_to==null){let n=mt(e.period??null);n!=null&&t("timestamp >= ?",n);return}if(e.date_from!=null&&t("timestamp >= ?",e.date_from),e.date_to!=null){let n=e.date_to.includes("T")||e.date_to.includes(" ");t("timestamp <= ?",n?e.date_to:`${e.date_to}T23:59:59`);}}function ce(e){let t=[],n=[],s=(r,...a)=>{t.push(r),n.push(...a);};ot(e,s),e.category!=null&&s("categories LIKE ?",`%"${e.category}"%`),e.level!=null&&s("level = ?",e.level);for(let[r,a]of st){let i=e[r];i!=null&&s(`${a} LIKE ?`,`%${i}%`);}if(e.starred!=null&&s("starred = ?",e.starred?1:0),e.imported!=null&&s("imported = ?",e.imported?1:0),e.search!=null){let r=`%${e.search}%`;s("(title LIKE ? OR topic_id LIKE ? OR summary LIKE ? OR body LIKE ?)",r,r,r,r);}return e.feedback==="none"?s("feedback IS NULL"):e.feedback!=null&&s("feedback = ?",e.feedback),{where:t.length?`WHERE ${t.join(" AND ")}`:"",params:n}}function K(e,t={}){let{where:n,params:s}=ce(t),o=h(e,`SELECT COUNT(*) AS n FROM lessons ${n}`,...s);return Number(o?.n??0)}var rt=new Set(["timestamp","level","topic_id","title","feedback"]),it=new Set(["project","repository","branch","commit_hash","repository_platform"]);function en(e,t={}){let{where:n,params:s}=ce(t),o=t.sort&&rt.has(t.sort)?t.sort:"timestamp",r=(t.order??"desc").toLowerCase()==="asc"?"ASC":"DESC",a=`SELECT * FROM lessons ${n} ORDER BY ${o} ${r}`,i=[...s];if(t.page!=null){let l=t.per_page??25;a+=" LIMIT ? OFFSET ?",i.push(l,(t.page-1)*l);}return f(e,a,...i).map(Z)}function tn(e,t){return u(e,"DELETE FROM lessons WHERE id = ?",t)>0}function nn(e,t,n){return u(e,"UPDATE lessons SET starred = ? WHERE id = ?",n?1:0,t)>0}function le(e,t,n){u(e,"UPDATE lessons SET feedback = ? WHERE id = ?",n||null,t);let s=h(e,"SELECT topic_id FROM lessons WHERE id = ?",t);return s?s.topic_id:null}function at(e){return f(e,"SELECT * FROM lessons ORDER BY timestamp DESC").map(Z)}function H(e,t){let n=0,s=0,o=0;for(let r of t){let a;try{a=T(r);}catch{o+=1;continue}G(e,a)?n+=1:s+=1;}return {inserted:n,duplicated:s,invalid:o}}function sn(e,t){if(!it.has(t))throw new Error(`Column not allowed: ${JSON.stringify(t)}`);return f(e,`SELECT DISTINCT ${t} FROM lessons WHERE ${t} IS NOT NULL ORDER BY ${t}`).map(s=>s[t])}function ue(e,t){let n=h(e,"SELECT * FROM lessons WHERE id = ?",t);return n?Z(n):null}function on(e){return f(e,"SELECT DISTINCT value FROM lessons, json_each(lessons.categories) ORDER BY value").map(n=>n.value)}function pe(e){return f(e,"SELECT DISTINCT topic_id FROM lessons").map(t=>t.topic_id)}function D(e,t){let n=h(e,"SELECT COUNT(*) AS n FROM lessons WHERE timestamp >= ? AND imported = 0",t);return Number(n?.n??0)}function de(e){let t=h(e,"SELECT timestamp FROM lessons WHERE imported = 0 ORDER BY timestamp DESC LIMIT 1");return t?t.timestamp:null}function I(e){let t={};for(let n of f(e,"SELECT topic, confidence FROM knowledge"))t[n.topic]=Number(n.confidence);return t}function W(e){return f(e,"SELECT topic, confidence FROM knowledge ORDER BY topic").map(t=>({topic:t.topic,confidence:Number(t.confidence)}))}function Y(e){let t=f(e,"SELECT group_name FROM knowledge_group_names ORDER BY group_name").map(s=>s.group_name),n=new Map;for(let s of f(e,"SELECT group_name, topic FROM knowledge_groups ORDER BY group_name, topic")){let o=s.group_name,r=n.get(o)??[];r.push(s.topic),n.set(o,r);}return t.map(s=>({name:s,topics:n.get(s)??[]}))}function x(e,t,n){let s=Math.max(0,Math.min(10,n)),o=new Date().toISOString();u(e,`INSERT INTO knowledge (topic, confidence, updated_at) VALUES (?, ?, ?)
|
|
68
|
+
ON CONFLICT(topic) DO UPDATE SET confidence = excluded.confidence, updated_at = excluded.updated_at`,t,s,o);}function rn(e,t){let n=u(e,"DELETE FROM knowledge WHERE topic = ?",t);return u(e,"DELETE FROM knowledge_groups WHERE topic = ?",t),n>0}function te(e,t){let n=t.trim();if(!n)throw new Error("Group name must not be empty");return u(e,"INSERT OR IGNORE INTO knowledge_group_names (group_name) VALUES (?)",n)>0}function an(e,t){return u(e,"DELETE FROM knowledge_groups WHERE group_name = ?",t),u(e,"DELETE FROM knowledge_group_names WHERE group_name = ?",t)>0}function ct(e,t,n){u(e,"INSERT OR IGNORE INTO knowledge_group_names (group_name) VALUES (?)",n),u(e,"DELETE FROM knowledge_groups WHERE topic = ?",t),u(e,"INSERT OR IGNORE INTO knowledge_groups (group_name, topic) VALUES (?, ?)",n,t);}function cn(e,t){u(e,"DELETE FROM knowledge_groups WHERE topic = ?",t);}function b(e){let t={};for(let g of f(e,"SELECT key, value FROM settings"))t[g.key]=g.value;let n=t.min_gap_minutes,s=t.min_hours_between,o;n!==void 0?o=Number.parseInt(n,10):s!==void 0?o=Number.parseInt(s,10)*60:o=240;let r=t.max_per_day,a=t.ui_theme??"system",i=a==="dark"||a==="light"||a==="system"?a:"system",l=t.nudge_every,m=l!==void 0?Number.parseInt(l,10):10,S=t.nudge_scope==="global"?"global":"session";return {max_per_day:r!==void 0?Number.parseInt(r,10):2,min_gap_minutes:o,ui_theme:i,nudge_every:Number.isFinite(m)&&m>=0?m:10,nudge_scope:S,share_name:t.share_name?.trim()||null}}function y(e,t,n){u(e,"INSERT INTO settings (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",t,n);}function me(e,t,n){let s=h(e,"INSERT INTO nudge_state (session_id, interactions, updated_at) VALUES (?, 1, ?) ON CONFLICT(session_id) DO UPDATE SET interactions = interactions + 1, updated_at = excluded.updated_at RETURNING interactions",t,new Date().toISOString()),o=Number(s?.interactions??0);return o===1&&u(e,"DELETE FROM nudge_state WHERE session_id NOT IN (SELECT session_id FROM nudge_state ORDER BY updated_at DESC LIMIT ?)",Ve),n==="global"?z(e,t,n):o}function ln(e){return f(e,"SELECT session_id, interactions, updated_at FROM nudge_state ORDER BY updated_at DESC").map(t=>({session_id:String(t.session_id),interactions:Number(t.interactions),updated_at:String(t.updated_at)}))}function z(e,t,n){let s=n==="global"?h(e,"SELECT COALESCE(SUM(interactions), 0) AS n FROM nudge_state"):h(e,"SELECT interactions AS n FROM nudge_state WHERE session_id = ?",t);return Number(s?.n??0)}function un(e){u(e,"DELETE FROM nudge_state"),u(e,"UPDATE cue_state SET pending = 0 WHERE id = 1");}var J=3;function q(e){let t=h(e,"SELECT pending, last_cue_at, last_skip_reason FROM cue_state WHERE id = 1");return {pending:Number(t?.pending??0)===1,last_cue_at:t?.last_cue_at??null,last_skip_reason:t?.last_skip_reason??null}}function ge(e){u(e,"INSERT INTO cue_state (id, pending, last_cue_at) VALUES (1, 1, ?) ON CONFLICT(id) DO UPDATE SET pending = 1, last_cue_at = excluded.last_cue_at",new Date().toISOString()),u(e,"DELETE FROM nudge_state");}function pn(e,t){u(e,"INSERT INTO cue_state (id, pending, last_skip_reason) VALUES (1, 0, ?) ON CONFLICT(id) DO UPDATE SET pending = 0, last_skip_reason = excluded.last_skip_reason",t??null),u(e,"DELETE FROM nudge_state");}function V(e){let t=h(e,"SELECT COUNT(*) AS n FROM knowledge");return {knowledge_ready:Number(t?.n??0)>0}}function dn(e){let t={};for(let n of ["project","repository","branch","repository_platform"]){let s=h(e,`SELECT ${n} AS v, COUNT(*) AS c FROM lessons WHERE ${n} IS NOT NULL AND imported = 0 GROUP BY ${n} ORDER BY c DESC LIMIT 1`);t[n]=s?s.v:null;}return t}function mn(e){let t=b(e),n=at(e),s=W(e),o=Y(e),r=new Map;for(let l of o)for(let m of l.topics)r.set(m,l.name);let a={groups:o.map(l=>l.name),topics:s.map(l=>({topic:l.topic,confidence:l.confidence,group:r.get(l.topic)??null}))},i={[$]:strToU8(JSON.stringify(t,null,2)),[M]:strToU8(JSON.stringify(n,null,2)),[P]:strToU8(JSON.stringify(a,null,2))};return existsSync(N)&&(i[j]=strToU8(readFileSync(N,"utf8"))),zipSync(i)}function lt(e,t,n){if(!($ in t))return;let s=JSON.parse(strFromU8(t[$]));"max_per_day"in s&&y(e,"max_per_day",String(s.max_per_day)),"min_gap_minutes"in s&&y(e,"min_gap_minutes",String(s.min_gap_minutes)),(s.ui_theme==="system"||s.ui_theme==="dark"||s.ui_theme==="light")&&y(e,"ui_theme",s.ui_theme),"nudge_every"in s&&y(e,"nudge_every",String(s.nudge_every)),(s.nudge_scope==="session"||s.nudge_scope==="global")&&y(e,"nudge_scope",s.nudge_scope),typeof s.share_name=="string"&&y(e,"share_name",Je(s.share_name)),n.settings=1;}function ut(e,t,n){if(!(P in t))return;let s=JSON.parse(strFromU8(t[P]));if(!(s&&typeof s=="object"&&Array.isArray(s.topics))){for(let[r,a]of Object.entries(s))x(e,r,a);n.topics=Object.keys(s).length;return}let o=0;for(let r of s.groups??[])te(e,r)&&(o+=1);for(let r of s.topics){x(e,r.topic,r.confidence);let a=r.group;a&&a!=="Other"&&(te(e,a)&&(o+=1),ct(e,r.topic,a));}n.topics=s.topics.length,n.groups=o;}function pt(e,t,n){if(!(M in t))return;let s=JSON.parse(strFromU8(t[M])),{inserted:o,duplicated:r,invalid:a}=H(e,s);n.lessons=o,n.skipped=r,n.invalid=a;}function dt(e,t){j in e&&(mkdirSync(dirname(N),{recursive:true}),writeFileSync(N,strFromU8(e[j]),"utf8"),t.learning_state=1);}function gn(e,t){let n={settings:0,topics:0,groups:0,lessons:0,skipped:0,invalid:0,learning_state:0},s=unzipSync(t);return lt(e,s,n),ut(e,s,n),pt(e,s,n),dt(s,n),n}function mt(e){let t=new Date,n;if(e==="today")n=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0));else if(e==="week")n=new Date(t.getTime()-7*864e5);else if(e==="month")n=new Date(t.getTime()-30*864e5);else if(e==="year")n=new Date(t.getTime()-365*864e5);else return null;return n.toISOString()}function Z(e){let t=[];try{let n=JSON.parse(e.categories);Array.isArray(n)&&(t=n);}catch{t=[];}return T({...e,categories:t,starred:!!e.starred,imported:!!e.imported})}var fe={version:"2.1.0-next.503.g8594664"};var he=fe.version;function _e(e){let t=[...e].length,n=Math.max(34-t-2,2),s=Math.floor(n/2);return `### ${"\u2500".repeat(s)} ${e} ${"\u2500".repeat(n-s)}`}function Ee(e){let t=e.level.charAt(0).toUpperCase()+e.level.slice(1),n=e.categories.join(" \xB7 ");return [_e("\u{1F393} devcoach"),`**${e.title}** \xB7 ${n} \xB7 ${t}`,"",e.body?.trim()||e.summary,"",_e(`${e.topic_id} \xB7 ${e.level}`)].join(`
|
|
69
|
+
`)}var A="devcoach.lesson",R=1,yt=`devcoach:lesson:${R}:`,St="https://ultimaphoenix.github.io/dev-coach/lesson",Tt=".devcoach.md",bt=256*1024,d=class extends Error{},L=z$1.string().nullish(),Lt=["task_context","project","branch","commit_hash"],Rt=new Set(["github","gitlab","bitbucket"]),Se=z$1.object({format:z$1.literal(A),version:z$1.literal(R),lesson:z$1.object({title:z$1.string().min(1),summary:z$1.string(),body:z$1.string().nullable(),topic_id:z$1.string().min(1),categories:z$1.array(z$1.string()),level:C,task_context:L,project:L,repository:L,branch:L,commit_hash:L,repository_platform:U.nullish()}),origin:z$1.object({id:z$1.string().min(1),timestamp:z$1.string()}),shared_by:z$1.string().nullable(),shared_at:z$1.string(),app_version:z$1.string()});function wn(e,t){let n={title:e.title,summary:e.summary,body:e.body,topic_id:e.topic_id,categories:e.categories,level:e.level};if(t.includeContext){for(let s of Lt)e[s]!=null&&(n[s]=e[s]);e.repository_platform&&Rt.has(e.repository_platform)&&(e.repository!=null&&(n.repository=e.repository),n.repository_platform=e.repository_platform);}return {format:A,version:R,lesson:n,origin:{id:e.id,timestamp:e.timestamp},shared_by:t.sharedBy,shared_at:F(t.now??new Date),app_version:he}}function Nn(e){return e.anonymous?null:e.explicit!=null?e.explicit.trim()||null:e.setting?.trim()||e.gitUserName?.trim()||null}function Te(e){let t=deflateSync(strToU8(JSON.stringify(e)),{level:9});return yt+Buffer.from(t).toString("base64url")}var be=/devcoach:lesson:(\d+):([A-Za-z0-9_-]+)/,wt=64e3,Q=512,v=class extends Error{};function Nt(e,t){let n=[],s=0,o=new Inflate(i=>{if(s+=i.length,s>t)throw new v("too large");n.push(i);});for(let i=0;i<e.length;i+=Q)o.push(e.subarray(i,i+Q),i+Q>=e.length);let r=new Uint8Array(s),a=0;for(let i of n)r.set(i,a),a+=i.length;return r}function xt(e){let t=new RegExp(`^${be.source}$`).exec(e.trim());if(!t)throw new d("That is not a devcoach lesson code.");if(Number(t[1])!==R)throw new d(`This lesson was shared by a newer devcoach (format ${t[1]}) \u2014 upgrade to import it.`);let n=t[2]??"";if(n.length>wt)throw new d("This lesson code is too large to be a lesson.");let s;try{let o=Nt(new Uint8Array(Buffer.from(n,"base64url")),bt);s=strFromU8(o);}catch(o){throw o instanceof v?new d("This lesson code is too large to be a lesson."):new d("This lesson code is damaged or incomplete \u2014 copy it again.")}return Le(s)}function Le(e){let t;try{t=JSON.parse(e);}catch{throw new d("This lesson code is damaged or incomplete \u2014 copy it again.")}let n=Se.safeParse(t);if(!n.success)throw new d("This is not a valid devcoach lesson.");return n.data}function xn(e,t=Te(e)){let n=e.shared_by?`Shared by ${e.shared_by} with devcoach`:"Shared with devcoach";return [Ee(e.lesson),"",`${n} \u2014 paste it to your agent or run: devcoach import`,t].join(`
|
|
70
|
+
`)}function On(e,t=Te(e)){return `${St}#${t}`}function Ot(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"lesson"}function Dn(e){return `${Ot(e.origin.id)}${Tt}`}var Dt=/^[A-Za-z0-9_.+:@/-]+$/,k=e=>Dt.test(e)?e:JSON.stringify(e),It=e=>`[${e.map(k).join(", ")}]`;function In(e){let t=e.lesson,n=["---",`format: ${A}`,`version: ${R}`,`title: ${JSON.stringify(t.title)}`,`topic_id: ${k(t.topic_id)}`,`level: ${t.level}`,`categories: ${It(t.categories)}`,`summary: ${JSON.stringify(t.summary)}`,`origin_id: ${k(e.origin.id)}`,`origin_timestamp: ${e.origin.timestamp}`,`shared_by: ${e.shared_by==null?"null":JSON.stringify(e.shared_by)}`,`shared_at: ${e.shared_at}`,`app_version: ${k(e.app_version)}`];for(let s of ["task_context","project","repository","branch","commit_hash","repository_platform"]){let o=t[s];o!=null&&n.push(`${s}: ${JSON.stringify(o)}`);}return n.push("---","",t.body??t.summary,""),n.join(`
|
|
71
|
+
`)}function kt(e){let t=[],n="",s=false;for(let o=0;o<e.length;o++){let r=e[o]??"";s?(n+=r,r==="\\"?n+=e[++o]??"":r==='"'&&(s=false)):r==='"'?(s=true,n+=r):r===","?(t.push(n),n=""):n+=r;}return t.push(n),t}function Re(e){let t=e.trim();if(t==="null"||t==="")return null;if(t.startsWith('"'))return JSON.parse(t);if(t.startsWith("[")&&t.endsWith("]")){let n=t.slice(1,-1).trim();return n?kt(n).map(s=>Re(s)):[]}return t}function vt(e){let t=e.replace(/\r\n?/g,`
|
|
72
|
+
`).split(`
|
|
73
|
+
`);if(t[0]?.trim()!=="---")throw new d("Missing frontmatter (--- \u2026 ---).");let n=t.findIndex((i,l)=>l>0&&i.trim()==="---");if(n===-1)throw new d("Frontmatter never closes (missing ---).");let s={};for(let i of t.slice(1,n)){if(!i.trim()||i.trimStart().startsWith("#"))continue;let l=i.indexOf(":");if(l===-1)throw new d(`Cannot read frontmatter line: ${i.trim()}`);try{s[i.slice(0,l).trim()]=Re(i.slice(l+1));}catch{throw new d(`Cannot read frontmatter line: ${i.trim()}`)}}let o=t.slice(n+1).join(`
|
|
74
|
+
`).trim(),r={format:s.format,version:typeof s.version=="string"?Number(s.version):s.version,lesson:{title:s.title,summary:s.summary,body:o||null,topic_id:s.topic_id,categories:s.categories,level:s.level,task_context:s.task_context??void 0,project:s.project??void 0,repository:s.repository??void 0,branch:s.branch??void 0,commit_hash:s.commit_hash??void 0,repository_platform:s.repository_platform??void 0},origin:{id:s.origin_id,timestamp:s.origin_timestamp},shared_by:s.shared_by??null,shared_at:s.shared_at,app_version:s.app_version},a=Se.safeParse(r);if(!a.success)throw new d("This file is not a valid devcoach lesson.");return a.data}function we(e){let t=e.trim();if(!t)throw new d("Nothing to import \u2014 paste a lesson code, link or file.");if(t.startsWith("[")){let o=ye(t);if(Array.isArray(o))return {kind:"lessons",records:o}}else if(t.startsWith("{")){let o=ye(t);if(o&&typeof o=="object")return o.format===A?{kind:"shared",source:"json",payload:Le(t)}:{kind:"lessons",records:[o]}}else if(t.startsWith("---"))return {kind:"shared",source:"markdown",payload:vt(t)};let n=[...t.matchAll(new RegExp(be.source,"g"))];if(n.length===0)throw new d("Not a devcoach lesson: expected a devcoach:lesson code, a share link, a .devcoach.md file or a lessons JSON export.");let s;for(let o of n.reverse()){let r=[o[0]],a=At(t.slice(o.index??0));a!==o[0]&&r.push(a);for(let i of r)try{return {kind:"shared",source:"code",payload:xt(i)}}catch(l){s=l;}}throw s}function At(e){let t=e.split(`
|
|
75
|
+
`).map(s=>s.trim()),n=t[0]??"";for(let s of t.slice(1)){if(!/^[A-Za-z0-9_-]+$/.test(s))break;n+=s;}return n}function ye(e){try{return JSON.parse(e)}catch{throw new d("This looks like JSON but does not parse \u2014 copy it again.")}}function Ne(e,t,n=new Date){let s=e.lesson;return T({id:t,timestamp:n,topic_id:s.topic_id,categories:s.categories,title:s.title,level:s.level,summary:s.summary,body:s.body,task_context:s.task_context??null,project:s.project??null,repository:s.repository??null,branch:s.branch??null,commit_hash:s.commit_hash??null,folder:null,repository_platform:s.repository_platform??null,starred:false,feedback:null,imported:true,shared_by:e.shared_by})}var Ct=50;function xe(e,t=Ct){let n=e.origin.id,s=[n];for(let o=1;s.length<t;o++)s.push(o===1?`${n}-shared`:`${n}-shared-${o}`);return s}function Oe(e,t){return e.imported&&e.title===t.lesson.title&&e.topic_id===t.lesson.topic_id&&(e.shared_by??null)===(t.shared_by??null)}function De(e){try{let t=b(e),n=new Date,s=new Date(n.getTime()-24*36e5).toISOString(),o=D(e,s);if(o>=t.max_per_day)return {allowed:!1,reason:`Daily limit reached (${o}/${t.max_per_day} lessons in the last 24h)`};let r=de(e);if(r!=null){let a=new Date(r),i=(n.getTime()-a.getTime())/6e4;if(i<t.min_gap_minutes){let l=t.min_gap_minutes-i,m=Math.floor(t.min_gap_minutes/60),S=t.min_gap_minutes%60,g=Math.trunc(l),E=Math.floor(g/60),Ie=g%60;return {allowed:!1,reason:`Too soon: last lesson ${i<0?`in ${Math.round(-i)}m (future timestamp)`:`${Math.round(i)}m ago`}, minimum interval is ${m}h ${S}m (${E}h ${Ie}m remaining)`}}}return {allowed:!0}}catch(t){return {allowed:true,reason:`Rate limit check failed: ${t}`}}}function Cn(e){try{return {knowledge:W(e),groups:Y(e)}}catch{return {knowledge:[],groups:[]}}}function Ut(e,t,n){let s=I(e)[t]??5,o=Math.max(0,Math.min(10,s+n));return x(e,t,o),o}function Un(e,t,n){let s=le(e,t,n);return s&&(n==="know"||n==="dont_know")&&Ut(e,s,n==="know"?1:-1),s}function Ft(e){try{let t=new Date,n=K(e),s=new Date(t.getTime()-24*36e5).toISOString(),o=new Date(t.getTime()-7*864e5).toISOString(),r=D(e,s),a=D(e,o),i=I(e),l=Object.entries(i).sort((g,E)=>g[1]-E[1]),m=l.slice(0,5).map(([g,E])=>({topic:g,confidence:E})),S=l.slice(-5).reverse().map(([g,E])=>({topic:g,confidence:E}));return {total_lessons:n,lessons_today:r,lessons_this_week:a,imported_lessons:K(e,{imported:!0}),weakest_topics:m,strongest_topics:S}}catch(t){return {error:String(t)}}}function $t(e,t){let n=Object.hasOwn(I(e),t.lesson.topic_id);for(let s of xe(t)){let o=ue(e,s);if(o){if(Oe(o,t))return {kind:"shared",inserted:0,duplicated:1,invalid:0,lesson:o,topic_tracked:n};continue}let r=Ne(t,s);if(G(e,r))return {kind:"shared",inserted:1,duplicated:0,invalid:0,lesson:r,topic_tracked:n}}return {kind:"shared",inserted:0,duplicated:0,invalid:1,lesson:null,topic_tracked:n}}function Fn(e,t){let n=we(t);return n.kind==="lessons"?{kind:"lessons",...H(e,n.records),lesson:null,topic_tracked:null}:$t(e,n.payload)}function $n(e){try{return pe(e)}catch{return []}}function Mn(e,t,n){let s=i=>({cue:false,reason:i,nextLessonNumber:0});if(n.planMode)return s("plan mode (not counted)");if(!V(e).knowledge_ready)return s("onboarding not complete");let o=b(e),r="pacing disabled (nudge_every=0)";if(o.nudge_every>0){let i=me(e,t??"__nosession__",o.nudge_scope),{pending:l}=q(e),m=l?Math.min(J,o.nudge_every):o.nudge_every;if(r=`${i}/${m}${l?" (retry window)":""}`,i<m)return s(`paced (${r})`)}let a=De(e);return a.allowed?(ge(e),{cue:true,reason:`cue (${r})`,nextLessonNumber:Number(Ft(e).total_lessons??0)+1}):s(`rate limited: ${a.reason??"denied"}`)}function Pn(e,t){try{let n=[],s=!0;if(!V(e).knowledge_ready)return {wouldCue:!1,reasons:["onboarding not complete \u2014 no knowledge topics yet"]};let o=b(e);if(o.nudge_every>0){let a=z(e,t??"__nosession__",o.nudge_scope)+1,{pending:i}=q(e),l=i?Math.min(J,o.nudge_every):o.nudge_every;a<l?(s=!1,n.push(`pacing: next stop would be ${a}/${l}${i?" (retry window)":""}`)):n.push(`pacing: next stop reaches the threshold (${a}/${l})`);}else n.push("pacing disabled (nudge_every=0) \u2014 every eligible stop cues");let r=De(e);return r.allowed?n.push("rate limit: allowed"):(s=!1,n.push(`rate limited: ${r.reason??"denied"}`)),{wouldCue:s,reasons:n}}catch(n){return {wouldCue:false,reasons:[`check failed: ${n}`]}}}export{Cn as $,x as A,rn as B,te as C,an as D,ct as E,cn as F,b as G,y as H,ln as I,un as J,q as K,pn as L,V as M,dn as N,mn as O,gn as P,he as Q,d as R,wn as S,Nn as T,Te as U,xt as V,xn as W,On as X,Dn as Y,In as Z,De as _,C as a,Ut as aa,U as b,Un as ba,ke as c,Ft as ca,jt as d,Fn as da,Me as e,$n as ea,Pe as f,Mn as fa,T as g,Pn as ga,oe as h,B as i,N as j,qt as k,ze as l,Je as m,Vt as n,Zt as o,Qt as p,K as q,en as r,tn as s,nn as t,le as u,at as v,sn as w,ue as x,on as y,W as z};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {readFileSync,readdirSync,statSync,existsSync,realpathSync}from'fs';import {dirname,basename,join}from'path';import {homedir,tmpdir}from'os';import {fileURLToPath}from'url';var W=[["package.json","javascript",6],["tsconfig*.json","typescript",6],["requirements*.txt","python",6],["pyproject.toml","python",6],["setup.py","python",6],["go.mod","go",6],["Cargo.toml","rust",6],["pom.xml","java",6],["build.gradle","java",6],["build.gradle.kts","java",6],["*.csproj","csharp",6],["Gemfile","ruby",6],["composer.json","php",6],["Dockerfile","docker",7],["Dockerfile.*","docker",7],["docker-compose.yml","docker_compose",7],["docker-compose.yaml","docker_compose",7],["docker-compose.*.yml","docker_compose",7],[".github/workflows/*.yml","github_actions",6],[".github/workflows/*.yaml","github_actions",6],[".gitlab-ci.yml","gitlab_ci",6],["Jenkinsfile","ci_cd",6],["*.tf","terraform",6],["*.sql","sql",5],[".git","git",7],["kubernetes/*.yaml","kubernetes",6],["kubernetes/*.yml","kubernetes",6],["k8s/*.yaml","kubernetes",6],["*.bicep","azure",6],["serverless.yml","aws",6],["serverless.yaml","aws",6],["template.yaml","aws",5],["angular.json","angular",6],["svelte.config.*","svelte",6],["nuxt.config.*","vue",6],["vite.config.*","javascript",6],["*.xcodeproj","swift",6],["*.xcworkspace","swift",6],["Package.swift","swift",6]],F={react:"react","react-dom":"react",vue:"vue","@angular/core":"angular",svelte:"svelte",next:"nextjs",nuxt:"vue",fastify:"fastify",express:"express",koa:"express","@nestjs/core":"node_js"},q={django:"django",flask:"flask",fastapi:"fastapi",starlette:"fastapi",tornado:"python",aiohttp:"python",sqlalchemy:"postgresql",celery:"python"};function J(e){let t="";for(let s of e)s==="*"?t+="[^/]*":s==="?"?t+="[^/]":t+=s.replace(/[.+^${}()|[\]\\]/g,String.raw`\$&`);return new RegExp(`^${t}$`)}function H(e,t){let s=t.lastIndexOf("/"),r=s>=0?join(e,t.slice(0,s)):e,o=s>=0?t.slice(s+1):t,c;try{c=readdirSync(r);}catch{return false}let i=J(o);return c.some(l=>i.test(l))}function k(e){try{return existsSync(e)?readFileSync(e,"utf8"):null}catch{return null}}function X(e,t){let s=k(join(e,"package.json"));if(!s)return;let r;try{r=JSON.parse(s);}catch{return}let o=new Set([...Object.keys(r.dependencies??{}),...Object.keys(r.devDependencies??{})]);for(let[c,i]of Object.entries(F))o.has(c)&&t(i,6);}function K(e,t){let s=["requirements.txt","requirements-dev.txt","requirements/base.txt","pyproject.toml"];for(let r of s){let o=k(join(e,r))?.toLowerCase();if(o)for(let[c,i]of Object.entries(q))o.includes(c)&&t(i,6);}}function S(e){let t={},s=(r,o)=>{(t[r]??-1)<o&&(t[r]=o);};for(let[r,o,c]of W)H(e,r)&&s(o,c);return X(e,s),K(e,s),t}function m(...e){let t={};for(let s of e)for(let[r,o]of Object.entries(s))(t[r]??-1)<o&&(t[r]=o);return t}var z=15,V=2,Z=40,B=400,v=1200,Q=new Set(["node_modules","dist","build","out","coverage","vendor","venv","__pycache__","Pods","DerivedData","target","tmp"]),tt={".ts":"typescript",".tsx":"typescript",".js":"javascript",".jsx":"javascript",".mjs":"javascript",".py":"python",".swift":"swift",".java":"java",".kt":"java",".go":"go",".rs":"rust",".rb":"ruby",".php":"php",".cs":"csharp",".sql":"sql",".tf":"terraform"},w={detected_stack:{},projects:[],scanned_projects:0};function P(){let e=process.env.DEVCOACH_CLAUDE_DIR??process.env.CLAUDE_CONFIG_DIR,t=e??join(homedir(),".claude");return {configPath:e?join(t,".claude.json"):join(homedir(),".claude.json"),historyPath:join(t,"history.jsonl"),projectsDir:join(t,"projects")}}function j(e){try{return realpathSync(e)}catch{return e}}function O(e){let t=j(e);return t.startsWith(j(homedir()))?false:t.startsWith(j(tmpdir()))||t.startsWith("/private/")}function b(e){try{return statSync(e).isDirectory()}catch{return false}}function et(e,t){let s=[],r=[{dir:e,depth:0}],o=0;for(;r.length>0&&o<Z&&t.left>0;){let{dir:c,depth:i}=r.shift();if(o++,t.left--,s.push(S(c)),i>=V)continue;let l;try{l=readdirSync(c);}catch{continue}for(let u of l){if(u.startsWith(".")||Q.has(u))continue;let n=join(c,u);b(n)&&r.push({dir:n,depth:i+1});}}return m(...s)}function nt(e){let t={};if(!Array.isArray(e))return t;for(let s of e){if(typeof s!="string")continue;let r=s.lastIndexOf("."),o=r>=0?tt[s.slice(r).toLowerCase()]:void 0;o&&(t[o]=Math.max(t[o]??0,5));}return t}function A(e){let t=new Map,s;try{s=readFileSync(e,"utf8");}catch{return t}for(let r of s.split(`
|
|
3
|
+
`))if(r)try{let o=JSON.parse(r);if(typeof o.project!="string")continue;let c=typeof o.timestamp=="number"?o.timestamp:0,i=t.get(o.project)??{count:0,last:0};t.set(o.project,{count:i.count+1,last:Math.max(i.last,c)});}catch{}return t}function rt(e,t){let s=t.replace(/[^a-zA-Z0-9]/g,"-"),r=(()=>{try{return readFileSync(join(e,s,"memory","MEMORY.md"),"utf8").trim()}catch{return null}})();return r?r.length>v?`${r.slice(0,v)}\u2026`:r:null}function ht(){try{let{configPath:e,historyPath:t,projectsDir:s}=P(),r;try{r=JSON.parse(readFileSync(e,"utf8"))?.projects??{};}catch{return w}let o=A(t),c=Object.keys(r).filter(n=>!O(n)&&b(n)).sort((n,a)=>(o.get(a)?.last??0)-(o.get(n)?.last??0)).slice(0,z),i={left:B},l=[];for(let n of c){let a=m(et(n,i),nt(r[n]?.exampleFiles)),y=rt(s,n);if(Object.keys(a).length===0&&y===null)continue;let d=o.get(n);l.push({stack:a,signal:{name:basename(n),path:n,topics:Object.keys(a).sort((M,I)=>M.localeCompare(I)),prompt_count:d?.count??0,last_activity:d?.last?new Date(d.last).toISOString():null,memory:y}});}let u=m(...l.map(n=>n.stack));for(let[n,a]of Object.entries(u))l.filter(d=>d.stack[n]!==void 0).length>=3&&a<8&&(u[n]=a+1);return {detected_stack:u,projects:l.map(n=>n.signal).sort((n,a)=>a.prompt_count-n.prompt_count).slice(0,20),scanned_projects:c.length}}catch{return w}}var st=8,ot=50,R=(e,t)=>({window_months:e,cutoff:t,candidate_count:0,over_soft_limit:false,candidates:[]});function jt(e){let t=Number.isFinite(e)&&e>0?e:3,s=Date.now()-t*30*864e5,r=new Date(s).toISOString();try{let{configPath:o,historyPath:c}=P(),i;try{i=JSON.parse(readFileSync(o,"utf8"))?.projects??{};}catch{return R(t,r)}let l=A(c),u=Object.keys(i).filter(n=>!O(n)&&b(n)).map(n=>({path:n,seen:l.get(n)})).filter(n=>(n.seen?.last??0)>=s).sort((n,a)=>(a.seen?.last??0)-(n.seen?.last??0));return {window_months:t,cutoff:r,candidate_count:u.length,over_soft_limit:u.length>st,candidates:u.slice(0,ot).map(n=>({name:basename(n.path),path:n.path,last_activity:n.seen?.last?new Date(n.seen.last).toISOString():null,prompt_count:n.seen?.count??0}))}}catch{return R(t,r)}}var D=dirname(fileURLToPath(import.meta.url));function C(){for(let e of ["../assets","../../assets"])if(existsSync(join(D,e,"SKILL.md")))return join(D,e);return null}var vt=()=>{let e=C();return e===null?"devcoach: coaching instructions unavailable (SKILL.md not found in package).":readFileSync(join(e,"SKILL.md"),"utf8")};function wt(){let e=C();if(e===null)return [];try{return readdirSync(join(e,"references")).filter(t=>t.endsWith(".md")).sort().map(t=>({name:t,content:readFileSync(join(e,"references",t),"utf8")}))}catch{return []}}export{S as a,m as b,ht as c,jt as d,vt as e,wt as f};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {e,g,b,d}from'./chunk-2LE7K3NO.js';export{c as buildLessonCue,d as cmdLessonReady,b as cmdOnboardHook,g as cmdPromptHook,e as cmdStopHook,a as parseHookPayload}from'./chunk-2LE7K3NO.js';import {c,b as b$2,a as a$2,e as e$1,f}from'./chunk-MRABMPXO.js';import {a as a$1,b as b$1,c as c$1,d as d$1}from'./chunk-3RBMKXAA.js';import {Q,o,$,r,x as x$1,t,s,ba,G,T as T$1,H,m as m$1,S as S$1,Y,Z,X,W,U,da,R as R$1,_,ca,l,A,E as E$1,B,C,D,F,O as O$1,z as z$1,v as v$1,j as j$1,P,i,M,I,K as K$1,ga}from'./chunk-4KFSUF7S.js';import {spawnSync,execFileSync}from'child_process';import {writeFileSync,existsSync,readFileSync,mkdirSync,accessSync,constants}from'fs';import {createInterface}from'readline/promises';import {text}from'stream/consumers';import {Command}from'commander';import {homedir,platform}from'os';import {join,dirname}from'path';import {styleText}from'util';var vo=!!process.stdout.isTTY&&!process.env.NO_COLOR,x=(e,o)=>vo?styleText(e,o):o,n={green:e=>x("green",e),red:e=>x("red",e),yellow:e=>x("yellow",e),cyan:e=>x("cyan",e),magenta:e=>x("magenta",e),dim:e=>x("dim",e),bold:e=>x("bold",e)};function te(e,o){return e==="green"?n.green(o):e==="yellow"?n.yellow(o):n.red(o)}var Co=/\[[0-9;]*m/g,So=e=>e.replace(Co,""),z=e=>[...So(e)].length;function ro(e,o,t){let r=Math.max(0,o-z(e));if(t==="right")return " ".repeat(r)+e;if(t==="center"){let i=Math.floor(r/2);return " ".repeat(i)+e+" ".repeat(r-i)}return e+" ".repeat(r)}function O(e,o,t,r=true){let i=o.map((g,p)=>Math.max(r?z(g.header):0,...t.map(c=>z(c[p]??"")))),d=(g,p,c)=>g+i.map(f=>"\u2500".repeat(f+2)).join(p)+c,s=g=>`\u2502${g.map((p,c)=>` ${ro(p??"",i[c]??0,o[c]?.justify??"left")} `).join("\u2502")}\u2502`,u=i.reduce((g,p)=>g+p+3,1),l=[];e&&l.push(ro(n.bold(e),u,"center")),l.push(d("\u256D","\u252C","\u256E")),r&&l.push(s(o.map(g=>n.bold(g.header))),d("\u251C","\u253C","\u2524"));for(let g of t)l.push(s(g));return l.push(d("\u2570","\u2534","\u256F")),l.join(`
|
|
3
|
+
`)}function K(e=""){if(!e)return "\u2500".repeat(60);let t=` ${e} `,r=Math.max(2,60-z(t)),i=Math.floor(r/2);return "\u2500".repeat(i)+t+"\u2500".repeat(r-i)}var io=e=>{let o=Math.max(0,Math.min(10,Math.round(e)));return "\u2588".repeat(o)+"\u2591".repeat(10-o)},so=e=>e>=7?"green":e>=4?"yellow":"red";var m=(e="")=>{console.log(e);};function Oo(){let e=platform();if(e==="darwin")return join(homedir(),"Library","Application Support","Claude","claude_desktop_config.json");if(e==="win32"){let t=process.env.APPDATA??join(homedir(),"AppData","Roaming");return join(t,"Claude","claude_desktop_config.json")}let o=process.env.XDG_CONFIG_HOME??join(homedir(),".config");return join(o,"Claude","claude_desktop_config.json")}var j=join(homedir(),".claude","settings.json"),ce=join(homedir(),".claude","skills","devcoach"),le=join(homedir(),".gemini"),T=join(le,"settings.json"),jo=join(le,"extensions","devcoach","gemini-extension.json"),me=join(homedir(),".codex"),E=join(me,"hooks.json"),se=join(me,"config.toml"),N=join(homedir(),".agents","skills","devcoach");function lo(e){for(let o of (process.env.PATH??"").split(":"))if(o)try{return accessSync(join(o,e),constants.X_OK),join(o,e)}catch{}return null}var ue=e=>lo(e)!==null;function mo(){return ue("devcoach")?{command:"devcoach",args:["mcp"]}:{command:"npx",args:["-y","devcoach","mcp"]}}function pe(){let e=lo("devcoach");return e?e.includes("fnm_multishells")?"devcoach":e:"npx -y devcoach"}function ao(e,o,t){if(!ue(e))return "";t&&spawnSync(e,t,{encoding:"utf8"});let r=spawnSync(e,o,{encoding:"utf8"});return r.status===0?`${n.green("\u2713")} Registered via \`${e} mcp add\``:`${r.stderr??""}${r.stdout??""}`.toLowerCase().includes("already")?`${n.yellow("Already registered")} in ${e} (use --force to overwrite)`:`${n.red(`${e} mcp add failed:`)} ${(r.stderr||r.stdout||"").trim()}`}function To(e,o){if(!ue("claude"))return "";o&&spawnSync("claude",["mcp","remove","--scope",e,"devcoach"],{encoding:"utf8"});let t=mo(),r=spawnSync("claude",["mcp","add","--scope",e,"devcoach",t.command,"--",...t.args],{encoding:"utf8"});return r.status===0?`${n.green("\u2713")} Registered via \`claude mcp add\` (scope: ${e})`:`${r.stderr??""}${r.stdout??""}`.toLowerCase().includes("already")?`${n.yellow("Already registered")} in Claude Code (use --force to overwrite)`:`${n.red("claude mcp add failed:")} ${(r.stderr||r.stdout||"").trim()}`}function S(e){if(!existsSync(e))return {ok:true,data:{}};try{return {ok:!0,data:JSON.parse(readFileSync(e,"utf8"))??{}}}catch{return {ok:false,error:`${n.red("\u2717")} ${e} is not valid JSON \u2014 fix it and re-run (left unchanged)`}}}function re(e,o,t){let r=S(e);if(!r.ok)return r.error;let i=r.data;i.mcpServers??={};let d=i.mcpServers;return d.devcoach&&!t?`${n.yellow("Already registered")} in ${e} (use --force to overwrite)`:(d.devcoach=o,mkdirSync(dirname(e),{recursive:true}),writeFileSync(e,`${JSON.stringify(i,null,2)}
|
|
4
|
+
`),`${n.green("\u2713")} Installed into ${e}`)}function Ho(){let e=pe();return {Stop:{hooks:[{type:"command",command:`${e} stop-hook`,timeout:60}]},UserPromptSubmit:{hooks:[{type:"command",command:`${e} prompt-hook`,timeout:30}]}}}function Eo(){let e=pe();return {AfterAgent:{hooks:[{type:"command",command:`${e} gemini-stop-hook`,timeout:6e4}]},BeforeAgent:{hooks:[{type:"command",command:`${e} gemini-prompt-hook`,timeout:3e4}]}}}function No(){let e=pe();return {Stop:{hooks:[{type:"command",command:`${e} codex-stop-hook`,timeout:60}]},UserPromptSubmit:{hooks:[{type:"command",command:`${e} codex-prompt-hook`,timeout:30}]}}}function uo(e){return Object.entries(e.enabledPlugins??{}).some(([o,t])=>t&&o.startsWith("devcoach@"))}function ge(){return existsSync(jo)}function fe(e){return /dev-?coach/i.test(e)&&/\b(?:stop-hook|prompt-hook|onboard-hook|lesson-ready)\b/.test(e)}function he(e,o){let t=S(e);if(!t.ok)return t.error;let r=t.data;r.hooks??={};let i=r.hooks,d=false;for(let[s,u]of Object.entries(o)){i[s]??=[];let l=i[s],g=l.map((c,f)=>[c,f]).filter(([c])=>(c.hooks??[]).some(f=>fe(f.command??""))).map(([,c])=>c),[p]=g;if(!(g.length===1&&p!==void 0&&JSON.stringify(l[p])===JSON.stringify(u))){for(let c of g.toReversed())l.splice(c,1);l.push(u),d=true;}}return d?(mkdirSync(dirname(e),{recursive:true}),writeFileSync(e,`${JSON.stringify(r,null,2)}
|
|
5
|
+
`),`${n.green("\u2713")} Hooks installed into ${e} (${Object.keys(o).join(" + ")})`):`${n.yellow("Already installed")} in ${e} (current layout)`}function Ro(){let e=S(j);return e.ok?uo(e.data)?`${n.yellow("Skipped")} \u2014 the devcoach plugin already provides the hooks (installing both would double-count interactions)`:he(j,Ho()):e.error}function Ao(){return ge()?`${n.yellow("Skipped")} \u2014 the devcoach Gemini extension already provides the hooks (installing both would double-count interactions)`:he(T,Eo())}function R(e){if(!existsSync(join(e,"SKILL.md")))return "missing";try{if(readFileSync(join(e,".devcoach-version"),"utf8").trim()===Q)return "current"}catch{}return "outdated"}function ae(e,o){if(!o&&R(e)==="current")return `${n.yellow("Already installed")} in ${e} (current version)`;mkdirSync(e,{recursive:true}),writeFileSync(join(e,"SKILL.md"),e$1());let t=f();if(t.length){let r=join(e,"references");mkdirSync(r,{recursive:true});for(let i of t)writeFileSync(join(r,i.name),i.content);}return writeFileSync(join(e,".devcoach-version"),`${Q}
|
|
6
|
+
`),`${n.green("\u2713")} Installed into ${e}`}function Do(e){return ge()?`${n.yellow("Skipped")} \u2014 bundled with the devcoach Gemini extension`:ae(N,e)}function ie(e,o){let t=S(e);return t.ok&&(t.data.hooks?.[o]??[]).some(r=>(r.hooks??[]).some(i=>fe(i.command??"")))}function ke(){let e=[{name:"Claude Code",dir:ce,cmd:"devcoach install",hooked:()=>ie(j,"Stop")},{name:"Gemini/Codex",dir:N,cmd:"devcoach install --gemini (or --codex)",hooked:()=>ie(T,"AfterAgent")||ie(E,"Stop")}];for(let o of e){let t=R(o.dir);if(t==="outdated")return `${n.yellow("\u2192")} The devcoach ${o.name} skill is out of date \u2014 run ${n.bold(o.cmd)} to refresh it.`;if(t==="missing"&&o.hooked())return `${n.yellow("\u2192")} The devcoach ${o.name} skill is not installed \u2014 run ${n.bold(o.cmd)} to add it.`}return ""}function po(e){let o=e.claudeCode||e.claudeDesktop||e.gemini||e.codex,t=e.claudeCode||!o,r=e.claudeDesktop||!o,i=mo(),d=false;if(m(n.bold("Setting up devcoach")+n.dim(` (${i.command} ${i.args.join(" ")})`)),m(),t){m(n.bold("Claude Code"));let s=To("user",e.force);if(!s){let u=join(homedir(),".claude.json");s=re(u,{type:"stdio",env:{},...i},e.force),d=true;}m(` MCP server\u2026 ${s}`),e.skipHook||m(` Hooks\u2026 ${Ro()}`),m(` Skill\u2026 ${ae(ce,e.force)}`),m();}if(r&&(m(n.bold("Claude Desktop")),m(` MCP server\u2026 ${re(Oo(),i,e.force)}`),d=true,m()),e.gemini){m(n.bold("Gemini CLI (beta)"));let s=ao("gemini",["mcp","add","-s","user","devcoach",i.command,...i.args],e.force?["mcp","remove","-s","user","devcoach"]:null);s||(s=re(T,i,e.force)),m(` MCP server\u2026 ${s}`),e.skipHook||m(` Hooks\u2026 ${Ao()}`),m(` Skill\u2026 ${Do(e.force)}`),m();}if(e.codex){m(n.bold("Codex CLI (beta)"));let s=ao("codex",["mcp","add","devcoach","--",i.command,...i.args],e.force?["mcp","remove","devcoach"]:null);s||(s=`${n.yellow("Manual step")} \u2014 codex CLI not found. Add to ${se}:
|
|
7
|
+
[mcp_servers.devcoach]
|
|
8
|
+
command = "${i.command}"
|
|
9
|
+
args = [${i.args.map(u=>`"${u}"`).join(", ")}]`),m(` MCP server\u2026 ${s}`),e.skipHook||m(` Hooks\u2026 ${he(E,No())}`),m(` Skill\u2026 ${ae(N,e.force)}`),m(` ${n.yellow("\u2192")} Codex asks once to trust new hooks \u2014 approve devcoach on the next run.`),m();}d&&m(`${n.yellow("\u2192")} Restart Claude Desktop to pick up the new server.
|
|
10
|
+
`),m(n.dim(`Tip: run devcoach backup to export your profile, lessons and settings.
|
|
11
|
+
run devcoach restore <file> to import a backup on a new machine.
|
|
12
|
+
After upgrading devcoach (npm, Homebrew), re-run devcoach install to refresh the skill.`));}function be(e){let o=[];for(let[t,r]of Object.entries(e.hooks??{}))for(let i of r??[])for(let d of i.hooks??[])fe(d.command??"")&&o.push({event:t,cmd:d});return o}function ye(e,o,t){for(let{cmd:r}of o){let i=r.command.split(" ")[0]??"";i.startsWith("/")&&!existsSync(i)&&e.bad(`hook command not found: ${i} \u2014 re-run ${n.bold(t)}`),r.command.startsWith("npx ")&&e.warn("hook runs via npx \u2014 needs the npx cache (or network) on every stop"),r.timeout==null&&e.warn(`hook entry has no timeout (${r.command})`);}}function Po(e){m(n.bold(`
|
|
13
|
+
Gemini CLI wiring (beta)`));let o=S(T),t=ge();if(!o.ok){e.bad(`${T} is not valid JSON \u2014 hooks cannot run`);return}let r=be(o.data);t&&r.length?e.bad("devcoach hooks are registered TWICE (extension + settings.json) \u2014 interactions are double-counted. Uninstall the extension or remove the settings.json entries."):t?e.ok("hooks provided by the devcoach Gemini extension"):r.length?(r.some(d=>d.event==="AfterAgent")?e.ok("AfterAgent stop hook wired"):e.warn(`no AfterAgent stop hook \u2014 run ${n.bold("devcoach install --gemini")}`),r.some(d=>d.event==="BeforeAgent")?e.ok("BeforeAgent priming hook wired"):e.warn(`no BeforeAgent priming hook \u2014 run ${n.bold("devcoach install --gemini")} (lessons land more reliably)`),ye(e,r,"devcoach install --gemini")):e.warn(`no devcoach hooks in ${T} \u2014 run ${n.bold("devcoach install --gemini")}`);let i=R(N);t?e.ok("skill bundled with the devcoach Gemini extension"):i==="current"?e.ok("skill installed (~/.agents/skills, current version)"):i==="outdated"?e.warn(`skill is out of date \u2014 run ${n.bold("devcoach install --gemini")}`):e.warn(`skill not installed \u2014 run ${n.bold("devcoach install --gemini")}`),o.data.mcpServers?.devcoach?e.ok("MCP server registered (settings.json)"):e.warn(`MCP server not found in settings.json \u2014 it may be registered elsewhere (check with ${n.bold("gemini mcp list")})`);}function Go(e){m(n.bold(`
|
|
14
|
+
Codex CLI wiring (beta)`));let o=S(E);if(!o.ok){e.bad(`${E} is not valid JSON \u2014 hooks cannot run`);return}let t=be(o.data);t.length?(t.some(d=>d.event==="Stop")?e.ok("Stop hook wired"):e.warn(`no Stop hook \u2014 run ${n.bold("devcoach install --codex")}`),t.some(d=>d.event==="UserPromptSubmit")?e.ok("UserPromptSubmit priming hook wired"):e.warn(`no UserPromptSubmit priming hook \u2014 run ${n.bold("devcoach install --codex")} (lessons land more reliably)`),ye(e,t,"devcoach install --codex"),e.warn("Codex runs hooks only after you trust them once \u2014 check the prompt on the next run")):e.warn(`no devcoach hooks in ${E} \u2014 run ${n.bold("devcoach install --codex")}`);let r=R(N);r==="current"?e.ok("skill installed (~/.agents/skills, current version)"):r==="outdated"?e.warn(`skill is out of date \u2014 run ${n.bold("devcoach install --codex")}`):e.warn(`skill not installed \u2014 run ${n.bold("devcoach install --codex")}`);let i=existsSync(se)?readFileSync(se,"utf8"):"";/\[mcp_servers\.devcoach\]/.test(i)?e.ok("MCP server registered (config.toml)"):e.warn(`MCP server not found in config.toml \u2014 it may be registered elsewhere (check with ${n.bold("codex mcp list")})`);}function go(){let e={ok:s=>m(` ${n.green("\u2713")} ${s}`),warn:s=>m(` ${n.yellow("\u2192")} ${s}`),bad:s=>m(` ${n.red("\u2717")} ${s}`)},{ok:o$1,warn:t,bad:r}=e;m(`
|
|
15
|
+
${n.bold("devcoach doctor")} ${n.dim(`v${Q}`)}
|
|
16
|
+
`),m(n.bold("Environment")),Number.parseInt(process.versions.node.split(".")[0]??"0",10)>=24?o$1(`Node ${process.versions.node} (\u2265 24)`):r(`Node ${process.versions.node} \u2014 devcoach needs Node \u2265 24 (embedded node:sqlite)`),m(n.bold(`
|
|
17
|
+
Claude Code wiring`));let d=S(j);if(!d.ok)r(`${j} is not valid JSON \u2014 hooks cannot run`);else {let s=uo(d.data),u=be(d.data);if(s&&u.length)r("devcoach hooks are registered TWICE (plugin + settings.json) \u2014 interactions are double-counted. Disable the plugin or remove the settings.json entries.");else if(s)o$1("hooks provided by the devcoach plugin");else if(!u.length)r(`no devcoach hooks in ${j} \u2014 run ${n.bold("devcoach install")}`);else {let p=u.filter(({cmd:f})=>f.command.includes("onboard-hook")||f.command.includes("lesson-ready")),c=u.filter(f=>f.event==="Stop").length;p.length?t(`legacy two-entry Stop layout \u2014 run ${n.bold("devcoach install")} to merge into one stop-hook entry (fewer spawns per stop)`):c>1?t(`${c} devcoach Stop entries \u2014 interactions are counted ${c}\xD7 per stop; run ${n.bold("devcoach install")} to keep only the current one`):o$1(`Stop hook wired (${c} entry)`),u.some(f=>f.event==="UserPromptSubmit")?o$1("UserPromptSubmit priming hook wired"):t(`no UserPromptSubmit priming hook \u2014 run ${n.bold("devcoach install")} to add it (lessons land more reliably)`),ye(e,u,"devcoach install");}let l=R(ce);l==="current"?o$1("Claude Code skill installed (current version)"):s?o$1("Claude Code skill bundled with the plugin"):t(l==="outdated"?`Claude Code skill is out of date \u2014 run ${n.bold("devcoach install")}`:`Claude Code skill not installed \u2014 run ${n.bold("devcoach install")}`);let g=S(join(homedir(),".claude.json"));g.ok&&g.data.mcpServers?.devcoach?o$1("MCP server registered (user scope)"):t(`MCP server not found in ~/.claude.json \u2014 it may be registered elsewhere (check with ${n.bold("claude mcp get devcoach")})`);}if(existsSync(le)&&Po(e),existsSync(me)&&Go(e),m(n.bold(`
|
|
18
|
+
Database & pacing`)),!existsSync(i)){t(`no database yet (${i}) \u2014 onboarding runs on the first technical task`),m();return}try{o(s=>{o$1(`database opens (${i})`),M(s).knowledge_ready?o$1("onboarding complete"):t("onboarding not complete \u2014 the next stop cues it");let u=G(s);m(` settings: max_per_day=${u.max_per_day} \xB7 min_gap_minutes=${u.min_gap_minutes} \xB7 nudge_every=${u.nudge_every} \xB7 nudge_scope=${u.nudge_scope}`);let l=I(s),g=l.reduce((y,b)=>y+b.interactions,0);m(` pacing: ${l.length} session(s) counted, ${g} interaction(s) total`+(l[0]?` \u2014 latest ${l[0].session_id.slice(0,8)}\u2026 at ${l[0].interactions}`:""));let p=K$1(s);p.pending?t(`a cue is pending since ${p.last_cue_at} (retry threshold armed)`):p.last_skip_reason&&m(` last skip: "${p.last_skip_reason}"`);let c=_(s);c.allowed?o$1("rate limit: allowed"):t(`rate limit: ${c.reason}`),m(n.bold(`
|
|
19
|
+
Verdict`));let f=ga(s,l[0]?.session_id??null);f.wouldCue?o$1("the next eligible stop WOULD cue a lesson"):t("the next eligible stop would NOT cue a lesson:");for(let y of f.reasons)m(` \xB7 ${y}`);});}catch(s){r(`database check failed: ${s}`);}m();}var a=(e="")=>{console.log(e);},ko=e=>e==="junior"?n.green(e):e==="mid"?n.yellow(e):e==="senior"?n.red(e):e,Ko=e=>e==="know"?` ${n.green("\u2713")}`:e==="dont_know"?` ${n.red("\u2717")}`:"",Wo=e=>e==="know"?n.green("\u2713 I know this"):e==="dont_know"?n.red("\u2717 I don't know this"):n.dim("no feedback");function bo(e,o){let t=new Map;for(let i of e.groups)for(let d of i.topics)t.set(d,i.name);let r=[...e.knowledge].sort((i,d)=>d.confidence-i.confidence).map(i=>{let d=so(i.confidence);return [i.topic,t.get(i.topic)??"Other",te(d,`${i.confidence}/10`),te(d,io(i.confidence))]});return O(o,[{header:"Topic"},{header:"Group"},{header:"Confidence",justify:"right"},{header:"Bar"}],r)}function Jo(){let e=o(o=>$(o));a(bo(e,"Knowledge Map"));}function Vo(e){let o$1=o(s=>r(s,{period:e.period==="all"?null:e.period,category:e.category,level:e.level,project:e.project,repository:e.repository,branch:e.branch,commit:e.commit,starred:e.starred?true:null,imported:e.imported?true:null,feedback:e.feedback,date_from:e.dateFrom,date_to:e.dateTo,sort:e.sort,order:e.order}));if(o$1.length===0){a(n.dim("No lessons found."));return}let t=o$1.some(s=>s.project||s.branch||s.commit_hash),r$1=[{header:""},{header:"Date"},{header:"Topic"},{header:"Title"},{header:"Level",justify:"center"},{header:"Categories"}];t&&r$1.push({header:"Project"},{header:"Branch"},{header:"Commit"});let i=o$1.some(s=>s.imported);i&&r$1.push({header:"Shared by"});let d=o$1.map(s=>{let u=[s.starred?n.yellow("\u2605"):n.dim("\xB7"),s.timestamp.slice(0,10),n.cyan(s.topic_id),s.title+Ko(s.feedback),ko(s.level),s.categories.join(", ")];return t&&u.push(s.project??"",s.branch?n.magenta(s.branch):"",s.commit_hash?n.cyan(s.commit_hash.slice(0,7)):""),i&&u.push(s.imported?s.shared_by??n.dim("anonymous"):""),u});a(O("Lessons",r$1,d));}function Yo(e){let o$1=o(r=>x$1(r,e));o$1===null&&(a(n.red(`Lesson '${e}' not found.`)),process.exit(1)),a(K(n.bold(o$1.title))),a(`${n.dim("ID:")} ${o$1.id}`),a(`${n.dim("Date:")} ${o$1.timestamp.slice(0,19).replace("T"," ")}`),a(`${n.dim("Topic:")} ${o$1.topic_id}`),a(`${n.dim("Categories:")} ${o$1.categories.join(", ")}`),a(`${n.dim("Level:")} ${ko(o$1.level)}`);let t=o$1.starred?n.yellow("\u2605 starred"):n.dim("\u2606 not starred");if(a(`${n.dim("Star:")} ${t} ${n.dim("Feedback:")} ${Wo(o$1.feedback)}`),o$1.imported&&a(`${n.dim("Shared by:")} ${o$1.shared_by??n.dim("anonymous")}`),o$1.task_context&&a(`${n.dim("Context:")} ${o$1.task_context}`),o$1.project||o$1.repository||o$1.branch||o$1.commit_hash||o$1.folder){let r=[];o$1.project&&r.push(`project=${o$1.project}`),o$1.repository&&r.push(`repo=${o$1.repository}`),o$1.branch&&r.push(`branch=${n.magenta(o$1.branch)}`),o$1.commit_hash&&r.push(`commit=${n.cyan(o$1.commit_hash.slice(0,7))}`),o$1.folder&&r.push(`folder=${o$1.folder}`),a(`${n.dim("Git:")} ${r.join(" \xB7 ")}`);}a(K()),a(o$1.summary);}function fo(e,o$1){o(r=>x$1(r,e)===null?false:(t(r,e,o$1),true))||(a(n.red(`Lesson '${e}' not found.`)),process.exit(1)),a(o$1?`Lesson ${n.cyan(e)} \u2192 ${n.yellow("\u2605 starred")}`:`Lesson ${n.cyan(e)} \u2192 ${n.dim("\u2606 unstarred")}`);}function Xo(e){o(t=>s(t,e))||(a(n.red(`Lesson '${e}' not found.`)),process.exit(1)),a(`Lesson ${n.cyan(e)} deleted.`);}function Zo(e,o$1){["know","dont_know","clear"].includes(o$1)||(a(n.red(`Invalid feedback '${o$1}'. Use: know | dont_know | clear`)),process.exit(1));let t=o$1==="clear"?null:o$1,r=o(s=>{let u=ba(s,e,t);if(u===null)return null;let l=s.prepare("SELECT confidence FROM knowledge WHERE topic = ?").get(u);return {topicId:u,newConf:l?l.confidence:5}});r===null&&(a(n.red(`Lesson '${e}' not found.`)),process.exit(1));let i;if(t==="know"||t==="dont_know"){let s=r.newConf+(t==="know"?-1:1);i=`${n.cyan(r.topicId)} confidence: ${s} \u2192 ${n.bold(String(r.newConf))}`;}else i="feedback cleared";let d=t==="know"?n.green("\u2713 I know this"):t==="dont_know"?n.red("\u2717 I don't know this"):n.dim("cleared");a(`Lesson ${n.cyan(e)} \u2192 ${d} (${i})`);}function qo(){let e=o(i=>G(i)),o$1=Math.floor(e.min_gap_minutes/60),t=e.min_gap_minutes%60,r=o$1?`${o$1}h ${t}m`:`${t}m`;a(O("Settings",[{header:"Key"},{header:"Value",justify:"right"}],[["max_per_day",String(e.max_per_day)],["min_gap_minutes",`${e.min_gap_minutes} (${r})`],["nudge_every",e.nudge_every===0?"0 (off)":String(e.nudge_every)],["nudge_scope",e.nudge_scope],["share_name",e.share_name??n.dim("(unset \u2192 git user.name)")]]));}function Qo(){let{stats:e,rateLimit:o$1,settings:t}=o(l=>({stats:ca(l),rateLimit:_(l),settings:G(l)})),r=l=>Number(e[l]??0),i=o$1.allowed?n.green("Available now"):n.yellow(o$1.reason??"");a(O("Coaching Stats",[{header:"Metric"},{header:"Value",justify:"right"}],[["Total lessons",String(r("total_lessons"))],["Lessons today (24h)",`${r("lessons_today")} / ${t.max_per_day}`],["Lessons this week",String(r("lessons_this_week"))],["Next lesson",i]],false));let d=e.weakest_topics??[],s=e.strongest_topics??[];if(d.length||s.length){let l=[];for(let g=0;g<Math.max(d.length,s.length);g++){let p=d[g],c=s[g];l.push([p?`${n.red(p.topic)} ${n.dim(`(${p.confidence})`)}`:"",c?`${n.green(c.topic)} ${n.dim(`(${c.confidence})`)}`:""]);}a(O(void 0,[{header:"Weakest topics"},{header:"Strongest topics"}],l));}let u=ke();u&&a(`
|
|
20
|
+
${u}`);}function en(e,o$1){let t=["max_per_day","min_gap_minutes","nudge_every","nudge_scope","share_name"];if(t.includes(e)||(a(n.red(`Unknown key '${e}'. Valid keys: ${t.join(", ")}`)),process.exit(1)),e==="nudge_scope"&&o$1!=="session"&&o$1!=="global"&&(a(n.red(`Invalid nudge_scope '${o$1}'. Use: session | global`)),process.exit(1)),e==="share_name"){o$1.trim().length>l&&(a(n.red(`share_name must be at most ${l} characters.`)),process.exit(1));let r=m$1(o$1);o(i=>H(i,e,r)),a(r?n.green(`Set share_name = ${r}`):n.green("Cleared share_name"));return}if(e==="nudge_every"){let r=Number.parseInt(o$1,10);(!Number.isInteger(r)||r<0)&&(a(n.red(`Invalid nudge_every '${o$1}'. Use a non-negative integer (0 = off).`)),process.exit(1));}o(r=>H(r,e,o$1)),a(n.green(`Set ${e} = ${o$1}`));}function on(e,o$1,t){let r=e.trim();r||(a(n.red("Topic name must not be empty.")),process.exit(1)),o(d=>{A(d,r,o$1),t&&t!=="Other"&&E$1(d,r,t);});let i=t&&t!=="Other"?` \u2192 ${n.cyan(t)}`:"";a(`${n.green("Added")} ${n.bold(r)} (confidence ${n.cyan(String(o$1))})${i}`);}function nn(e){let o$1=o(t=>B(t,e));a(o$1?`${n.green("Removed")} ${n.bold(e)} from knowledge map`:n.yellow(`Topic '${e}' not found.`));}function tn(e){let o$1=e.trim();(!o$1||o$1==="Other")&&(a(n.red("Invalid group name.")),process.exit(1)),o(t=>C(t,o$1)),a(`${n.green(`Group '${n.cyan(o$1)}' ready.`)} Assign topics with: devcoach group-assign <topic> "${o$1}"`);}function rn(e){let o$1=o(t=>D(t,e));a(o$1?`${n.green(`Removed group '${n.cyan(e)}'`)}`:n.yellow(`Group '${e}' not found.`));}function sn(e,o$1){o(r=>r.prepare("SELECT topic FROM knowledge WHERE topic = ?").get(e)===void 0?false:(o$1==="Other"?F(r,e):E$1(r,e,o$1),true))||(a(n.red(`Topic '${e}' not in knowledge map. Add it first.`)),process.exit(1)),a(o$1==="Other"?`${n.green("Moved")} ${n.bold(e)} \u2192 Other (ungrouped)`:`${n.green("Moved")} ${n.bold(e)} \u2192 ${n.cyan(o$1)}`);}function an(e){let{lessonsCount:o$1,knowledgeCount:t,data:r}=o(d=>({lessonsCount:v$1(d).length,knowledgeCount:z$1(d).length,data:O$1(d)}));writeFileSync(e,r);let i=existsSync(j$1)?" + notebook":"";a(`${n.green("Backup saved:")} ${e} (${n.cyan(String(o$1))} lessons, ${n.cyan(String(t))} topics${i})`);}function dn(e){existsSync(e)||(a(n.red(`File not found: ${e}`)),process.exit(1));let o$1=o(r=>P(r,readFileSync(e)));o$1.settings&&a(`${n.green("\u2713")} Settings restored`),o$1.topics&&a(`${n.green("\u2713")} Knowledge map restored (${n.cyan(String(o$1.topics))} topics)`);let t=[`${n.cyan(String(o$1.lessons))} imported`];o$1.skipped&&t.push(`${n.yellow(String(o$1.skipped))} duplicates skipped`),o$1.invalid&&t.push(`${n.red(String(o$1.invalid))} rejected (invalid)`),a(`${n.green("\u2713")} Lessons: ${t.join(", ")}`),o$1.learning_state&&a(`${n.green("\u2713")} Notebook restored`);}var V=e=>{console.error(n.dim(e));};function cn(e,o$1){o$1.by!==void 0&&o$1.anonymous&&(a(n.red("Use either --by <name> or --anonymous, not both.")),process.exit(1)),!e&&!o$1.last&&(a(n.red("Give a lesson id, or --last for the most recent one.")),process.exit(2));let t=o(d=>{let s=o$1.last?r(d,{imported:false,page:1,per_page:1})[0]??null:x$1(d,e);if(!s)return null;let u=G(d),l=T$1({explicit:o$1.by??null,anonymous:o$1.anonymous,setting:u.share_name,gitUserName:a$1()}),g=false;return o$1.by?.trim()&&!u.share_name&&(H(d,"share_name",m$1(o$1.by)),g=true),{payload:S$1(s,{includeContext:!!o$1.withContext,sharedBy:l}),remembered:g}});t||(a(n.red(o$1.last?"No lessons to share yet.":`Lesson '${e}' not found.`)),process.exit(1));let{payload:r$1,remembered:i}=t;if(o$1.file!==void 0&&o$1.file!==false){let d=typeof o$1.file=="string"?o$1.file:Y(r$1);writeFileSync(d,Z(r$1)),a(`${n.green("Saved:")} ${d}`);}else o$1.link?a(X(r$1)):(a(W(r$1)),U(r$1).length>16e3&&V("Long lesson \u2014 prefer --file for a friendlier hand-off."));i&&V("(remembered as share_name \u2014 change it with: devcoach set share_name <name>)"),r$1.shared_by===null&&V("Shared anonymously (set a name with: devcoach set share_name <name>)");}function ln(){let e=process.platform==="darwin"?[["pbpaste",[]]]:process.platform==="win32"?[["powershell",["-NoProfile","-Command","Get-Clipboard"]]]:[["wl-paste",["--no-newline"]],["xclip",["-selection","clipboard","-o"]],["xsel",["--clipboard","--output"]]];for(let[o,t]of e)try{let r=execFileSync(o,t,{encoding:"utf8",timeout:3e3,stdio:["ignore","pipe","ignore"]});if(r.trim())return r}catch{}throw new R$1("Clipboard is empty or unavailable \u2014 pass the code, a link or a file, or pipe it: devcoach import -")}async function mn(e){return e===void 0?ln():e==="-"?text(process.stdin):existsSync(e)?readFileSync(e,"utf8"):c$1(e)&&!e.includes("#devcoach:lesson:")?d$1(e):e}async function un(e){try{let o$1=await mn(e),t=o(d=>da(d,o$1));if(t.kind==="lessons"){let d=[`${n.cyan(String(t.inserted))} imported`];t.duplicated&&d.push(`${n.yellow(String(t.duplicated))} duplicates skipped`),t.invalid&&d.push(`${n.red(String(t.invalid))} rejected (invalid)`),a(`${n.green("\u2713")} Lessons: ${d.join(", ")}`);return}let r=t.lesson;r||(a(n.red("Could not store the lesson.")),process.exit(1));let i=r.shared_by?`shared by ${r.shared_by}`:"shared anonymously";t.duplicated?a(`${n.yellow("Already in your log")} as ${n.cyan(r.id)} (${i})`):a(`${n.green("\u2713 Imported")} ${n.bold(`"${r.title}"`)} (${i}) as ${n.cyan(r.id)} \u2014 topic ${n.cyan(r.topic_id)}`),t.topic_tracked===!1&&V(`Topic '${r.topic_id}' is not in your knowledge map \u2014 track it with: devcoach knowledge-add ${r.topic_id}`);}catch(o){if(!(o instanceof R$1))throw o;a(n.red(o.message)),process.exit(1);}}async function pn(){let e=createInterface({input:process.stdin,output:process.stdout}),o$1=async(r,i="")=>{let d=i?` [${i}]`:"";return (await e.question(`${r}${d}: `)).trim()||i},t=async(r,i,d,s)=>{for(;;){let u=await o$1(r,String(i)),l=Number.parseInt(u,10);if(!Number.isNaN(l)&&l>=d&&l<=s)return l;a(n.red(`Must be ${d}\u2013${s}.`));}};try{a(K(n.bold("devcoach setup"))),a(`
|
|
21
|
+
${n.bold("Step 1")} \u2014 Restore from backup`);let r=await o$1("Path to existing backup zip (Enter to skip)","");if(r){existsSync(r)||(a(n.red(`File not found: ${r}`)),process.exit(1));let p=o(c=>P(c,readFileSync(r)));a(`${n.green("\u2713")} Restored: ${p.topics} topics, ${p.lessons} lessons${p.learning_state?", notebook":""}`),a(n.green("Setup complete!"));return}a(`
|
|
22
|
+
${n.bold("Step 2")} \u2014 Build your knowledge profile`);let i=(await o$1("Mode: [a]utomatic (detect from files) / [m]anual (type your stack)","a")).toLowerCase(),d={};if(i.startsWith("a")){let c$1=b$1().folder??process.cwd(),f=c(),y=b$2(a$2(c$1),f.detected_stack),b=Object.keys(y).sort(($,L)=>$.localeCompare(L));if(f.scanned_projects>0){a(`
|
|
23
|
+
${n.dim(`Scanned ${f.scanned_projects} Claude Code project(s) from your history:`)}`);for(let $ of f.projects.slice(0,8))a(n.dim(` ${$.name} \u2014 ${$.topics.join(", ")||"no stack signals"}`));}if(b.length){a(`
|
|
24
|
+
${n.dim(`Detected (history + ${n.cyan(c$1)}):`)}`);for(let $ of b){let L=y[$]??5,we=await o$1(` ${n.cyan($)} (Enter=keep, 0-10=override, s=skip)`,String(L));if(we.toLowerCase()==="s")continue;let ve=Number.parseInt(we,10);d[$]=Number.isNaN(ve)?L:Math.max(0,Math.min(10,ve));}}else a(n.dim("No technology files detected in current directory."));let A=await o$1(`
|
|
25
|
+
Add additional topics (comma-separated, or Enter to skip)`,"");for(let $ of A.split(",").map(L=>L.trim()).filter(Boolean))d[$]=await t(` Confidence for ${n.cyan($)}`,5,0,10);}else for(a(n.dim(`
|
|
26
|
+
Enter topics: 'topic_id confidence' (e.g. python 7). Blank line when done.`));;){let p=(await o$1("Topic (Enter when done)","")).trim();if(!p)break;let c=p.split(/\s+/),f=c[0]??"",y=Number.parseInt(c[1]??"",10),b=Number.isNaN(y)?5:Math.max(0,Math.min(10,y));d[f]=b,a(` ${n.green("+")} ${n.cyan(f)} \u2192 ${b}`);}let s={};if(Object.keys(d).length&&(a(`
|
|
27
|
+
${n.bold("Step 3")} \u2014 Organise into groups`),(await o$1("Organise topics into groups? [y/N]","n")).toLowerCase().startsWith("y"))){let c=[];for(let f of Object.keys(d).sort((y,b)=>y.localeCompare(b))){let y=c.length?c.join(", "):"(none yet)",b=await o$1(` Group for ${n.cyan(f)} existing: ${n.dim(y)} (Enter=Other)`,"");if(b&&b!=="Other"){let A=s[b]??[];A.push(f),s[b]=A,c.includes(b)||c.push(b);}}}a(`
|
|
28
|
+
${n.bold("Step 4")} \u2014 Rate-limit settings`);let u=await t("Max lessons per day",2,1,20),l=await t("Min gap between lessons (minutes)",240,0,1440),g=o(p=>{p.exec("DELETE FROM knowledge; DELETE FROM knowledge_groups; DELETE FROM knowledge_group_names;");for(let[c,f]of Object.entries(d))A(p,c,f);for(let[c,f]of Object.entries(s))for(let y of f)E$1(p,y,c);return H(p,"max_per_day",String(u)),H(p,"min_gap_minutes",String(l)),$(p)});a(bo(g,"Knowledge Profile")),a(`
|
|
29
|
+
${n.green("Setup complete!")} ${Object.keys(d).length} topics saved.`);}finally{e.close();}}function gn(){let e=[["mcp","Start the MCP server (stdio) for Claude Code / Claude Desktop"],["ui [--port N]","Launch the web dashboard (default port: 7860)"],["setup","First-run wizard: import backup or build your knowledge profile"],["install","Register MCP server + hooks + skill (Claude default; --gemini/--codex beta)"],["onboard-hook","Claude Code Stop hook: cue onboarding when no profile exists"],["lesson-ready","Claude Code Stop hook: cue a lesson when one is due"],["doctor","Diagnose the agent wiring \u2014 explains why a lesson would(n't) fire"],["profile","Show the knowledge map"],["stats","Coaching statistics and rate-limit status"],["settings / set","Show / update settings (max_per_day | min_gap_minutes)"],["lessons / lesson","List past lessons / show one in detail"],["star / unstar / delete","Manage a lesson"],["feedback <id>","Record know / dont_know feedback"],["share / import","Hand a lesson to a teammate / add a shared lesson to your log"],["knowledge-add / -remove","Add / remove a topic"],["group-add / -remove / -assign","Manage knowledge groups"],["backup / restore","Export / import a full backup zip"]];a(`
|
|
30
|
+
${n.bold(`devcoach ${n.dim(`v${Q}`)}`)}`);for(let[t,r]of e)a(` ${n.cyan(`devcoach ${t}`.padEnd(32))} ${n.dim(r)}`);a(`
|
|
31
|
+
${n.dim("Run")} ${n.bold("devcoach <command> --help")} ${n.dim("for per-command options.")}
|
|
32
|
+
`);let o=ke();o&&a(`${o}
|
|
33
|
+
`);}function v(e){return e??null}function fn(){let e$1=new Command;return e$1.exitOverride(),e$1.name("devcoach").description("devcoach \u2014 progressive technical coaching").version(`devcoach ${Q}`,"-v, --version","output the version number").allowExcessArguments(false).showHelpAfterError("(add --help for usage)").action(()=>gn()),e$1.command("mcp").description("Start the MCP server (stdio transport)").action(async()=>{let{runStdio:o}=await import('./server-JJASGVG5.js');await o();}),e$1.command("profile").description("Show the knowledge map").action(Jo),e$1.command("lessons").description("List past lessons").option("--period <period>","today | week | month | year | all","all").option("--category <category>","Filter by category tag").option("--project <project>","Filter by project (fuzzy)").option("--repository <repository>","Filter by repository (fuzzy)").option("--branch <branch>","Filter by branch (fuzzy)").option("--commit <commit>","Filter by commit hash prefix (fuzzy)").option("--starred","Show only starred lessons").option("--imported","Show only lessons shared with you").option("--feedback <feedback>","know | dont_know | none").option("--level <level>","junior | mid | senior").option("--date-from <date>","Show lessons on or after this date (YYYY-MM-DD[THH:MM])").option("--date-to <date>","Show lessons on or before this date (YYYY-MM-DD[THH:MM])").option("--sort <column>","timestamp | level | topic_id | title | feedback","timestamp").option("--order <order>","asc | desc","desc").action(o=>Vo({period:o.period??"all",category:v(o.category),project:v(o.project),repository:v(o.repository),branch:v(o.branch),commit:v(o.commit),starred:!!o.starred,imported:!!o.imported,feedback:v(o.feedback),level:v(o.level),dateFrom:v(o.dateFrom),dateTo:v(o.dateTo),sort:o.sort??"timestamp",order:o.order??"desc"})),e$1.command("lesson").description("Show a single lesson in detail").argument("<id>","Lesson ID").action(o=>Yo(o)),e$1.command("star").description("Mark a lesson as starred").argument("<id>","Lesson ID").action(o=>fo(o,true)),e$1.command("unstar").description("Remove the starred mark from a lesson").argument("<id>","Lesson ID").action(o=>fo(o,false)),e$1.command("delete").description("Permanently delete a lesson").argument("<id>","Lesson ID").action(o=>Xo(o)),e$1.command("feedback").description("Record know/dont_know feedback for a lesson").argument("<id>","Lesson ID").argument("<value>","know | dont_know | clear").action((o,t)=>Zo(o,t)),e$1.command("share").description("Share a lesson: copyable text (default), --link, or a .devcoach.md file").argument("[id]","Lesson ID (or use --last)").option("--last","Share the most recent lesson").option("--link","Print the share link only").option("--file [path]","Write a .devcoach.md file (default: <lesson-id>.devcoach.md)").option("--with-context","Include project/branch/commit/task context (off by default)").option("--by <name>","Sender name (remembered as share_name when unset)").option("--anonymous","Share without a sender name").action((o,t)=>cn(o,t)),e$1.command("import").description("Import a shared lesson: a devcoach:lesson code, a share link, a URL, a .devcoach.md or lessons .json file, - for stdin \u2014 or the clipboard when omitted").argument("[source]","Code, link, URL, file path, or - (stdin); omit to read the clipboard").action(o=>un(o)),e$1.command("settings").description("Show current settings").action(qo),e$1.command("stats").description("Coaching statistics and rate-limit status").action(Qo),e$1.command("set").description("Update a setting (max_per_day | min_gap_minutes | nudge_every | nudge_scope | share_name)").argument("<key>","Setting key").argument("<value>","New value").action((o,t)=>en(o,t)),e$1.command("knowledge-add").description("Add or update a topic in the knowledge map").argument("<topic>","Topic ID").option("--confidence <n>","Initial confidence 0-10","5").option("--group <group>","Assign to a named group").action((o,t)=>on(o,Math.max(0,Math.min(10,Number.parseInt(t.confidence??"5",10)||5)),v(t.group))),e$1.command("knowledge-remove").description("Remove a topic from the knowledge map").argument("<topic>","Topic ID").action(o=>nn(o)),e$1.command("group-add").description("Register a new knowledge group").argument("<name>","Group name").action(o=>tn(o)),e$1.command("group-remove").description("Delete a knowledge group (topics move to Other)").argument("<name>","Group name").action(o=>rn(o)),e$1.command("group-assign").description("Move a topic to a group").argument("<topic>","Topic ID").argument("<group>","Group name (use 'Other' to ungroup)").action((o,t)=>sn(o,t)),e$1.command("backup").description("Export a full backup (settings + knowledge + lessons) as zip").argument("[file]","Output zip path","devcoach-backup.zip").action(o=>an(o)),e$1.command("restore").description("Restore from a backup zip file").argument("<file>","Path to backup zip").action(o=>dn(o)),e$1.command("install").description("Register the MCP server + hooks + skill in Claude Code / Claude Desktop (default), Gemini CLI (--gemini, beta), or Codex CLI (--codex, beta)").option("--claude-code","Target Claude Code only").option("--claude-desktop","Target Claude Desktop only").option("--gemini","Target Google Gemini CLI (beta)").option("--codex","Target OpenAI Codex CLI (beta)").option("--force","Overwrite existing devcoach entry").option("--skip-hook","Register MCP server only \u2014 skip the hooks").action(o=>po({claudeCode:!!o.claudeCode,claudeDesktop:!!o.claudeDesktop,gemini:!!o.gemini,codex:!!o.codex,force:!!o.force,skipHook:!!o.skipHook})),e$1.command("doctor").description("Diagnose the devcoach \u21C4 agent wiring and the lesson pacing state").action(go),e$1.command("ui").description("Launch the web dashboard").option("--port <port>","Port","7860").action(async o=>{let{startUi:t}=await import('./app-KE4H5NNP.js');t(Number.parseInt(o.port??"7860",10)||7860);}),e$1.command("setup").description("First-run wizard: import backup or build your knowledge profile").action(pn),e$1.command("stop-hook",{hidden:true}).description("Claude Code Stop hook: onboarding check + lesson cue in one spawn").action(()=>e()),e$1.command("prompt-hook",{hidden:true}).description("Claude Code UserPromptSubmit hook: prime the model when a lesson is due").action(()=>g()),e$1.command("gemini-stop-hook",{hidden:true}).description("Gemini CLI AfterAgent hook: onboarding check + lesson cue in one spawn").action(()=>e(void 0,"gemini")),e$1.command("gemini-prompt-hook",{hidden:true}).description("Gemini CLI BeforeAgent hook: prime the model when a lesson is due").action(()=>g(void 0,"gemini")),e$1.command("codex-stop-hook",{hidden:true}).description("Codex CLI Stop hook: onboarding check + lesson cue in one spawn").action(()=>e(void 0,"codex")),e$1.command("codex-prompt-hook",{hidden:true}).description("Codex CLI UserPromptSubmit hook: prime the model when a lesson is due").action(()=>g(void 0,"codex")),e$1.command("onboard-hook",{hidden:true}).description("Claude Code Stop hook: cue onboarding (legacy two-entry layout)").action(()=>b()),e$1.command("lesson-ready",{hidden:true}).description("Claude Code Stop hook: signal a lesson is due (legacy two-entry layout)").action(()=>d()),e$1}async function Gn(){let e=fn();try{await e.parseAsync(process.argv);}catch(o){let t=o.code??"";if(!t.startsWith("commander."))throw o;if(t==="commander.helpDisplayed"||t==="commander.help"||t==="commander.version")return;process.exit(2);}}export{Gn as runCli};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export{c as buildLessonCue,f as buildPromptPrime,d as cmdLessonReady,b as cmdOnboardHook,g as cmdPromptHook,e as cmdStopHook,a as parseHookPayload,h as runHook}from'./chunk-
|
|
2
|
+
export{c as buildLessonCue,f as buildPromptPrime,d as cmdLessonReady,b as cmdOnboardHook,g as cmdPromptHook,e as cmdStopHook,a as parseHookPayload,h as runHook}from'./chunk-2LE7K3NO.js';import'./chunk-4KFSUF7S.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
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-3RBMKXAA.js';import {a,c as c$1,b,f,e,Q,o,N as N$1,g,p as p$1,J,aa,r,t,s,u,L,d,A,E,B,C,D,l as l$1,m as m$1,$,j,x,T,G,S,Y,Z,X,W,U,da,R,ca,ea,q,_,H,M,k}from'./chunk-4KFSUF7S.js';import {spawn}from'child_process';import {mkdirSync,existsSync,statSync,writeFileSync,readFileSync}from'fs';import {dirname}from'path';import {McpServer,ResourceTemplate}from'@modelcontextprotocol/server';import {StdioServerTransport}from'@modelcontextprotocol/server/stdio';import {z}from'zod';var p=o=>({type:"text",text:o}),fe=o=>({content:[p(JSON.stringify(o))]}),c=o=>({isError:true,content:[p(o)]}),m=o=>({content:[p(JSON.stringify(o))],structuredContent:o}),Re=z.object({id:z.string(),timestamp:z.string(),topic_id:z.string(),categories:z.array(z.string()),title:z.string(),level:a,summary:z.string(),body:z.string().nullable(),task_context:z.string().nullable(),project:z.string().nullable(),repository:z.string().nullable(),branch:z.string().nullable(),commit_hash:z.string().nullable(),folder:z.string().nullable(),repository_platform:b.nullable(),starred:z.boolean(),feedback:c$1.nullable(),imported:z.boolean(),shared_by:z.string().nullable()}),Ne=Re.extend({reply_check:z.string()}),ye="Saved \u2014 but saving does NOT display anything. The user sees ONLY plain text you write in your reply; the title/body inside this tool call's ARGUMENTS are invisible to them, and having composed them does not count as having shown the card. Did you already write the full card (both ### band headings + title line + body + tip) as plain reply text, outside any tool call? If yes: output nothing. If no: write the card now, as the final text of your reply. Never write it twice.",_e=z.object({knowledge:z.array(z.object({topic:z.string(),confidence:z.number().int()})),groups:z.array(z.object({name:z.string(),topics:z.array(z.string())}))}),Oe=z.object({max_per_day:z.number().int(),min_gap_minutes:z.number().int(),ui_theme:e,nudge_every:z.number().int(),nudge_scope:f,share_name:z.string().nullable()}),Pe=z.object({transport:z.enum(["text","link","file"]),code:z.string(),text:z.string().nullable(),link:z.string().nullable(),markdown:z.string().nullable(),filename:z.string().nullable(),shared_by:z.string().nullable(),include_context:z.boolean(),reply_check:z.string()}),Ie=z.object({kind:z.enum(["shared","lessons"]),inserted:z.number().int(),duplicated:z.number().int(),invalid:z.number().int(),lesson:Re.nullable(),topic_tracked:z.boolean().nullable(),reply_check:z.string()}),$e={text:"Reply with `text` verbatim as the final message: the card as markdown, then the last line (devcoach:lesson:1:\u2026) inside a fenced code block, character for character \u2014 never paraphrase, wrap, truncate or split it.",link:"Reply with `link` on its own line, unchanged.",file:"Write `markdown` to `filename` (in the workspace unless the user named a path) with your file tool, then confirm the path in one line; do not print the markdown."},Ge="Confirm in one line: the title, who shared it, and that it joined the coaching log (feedback works as usual; it does not count against the daily limit). If topic_tracked is false, offer to track the topic with add_topic \u2014 only on confirmation.",Fe=z.object({window_months:z.number().int(),cutoff:z.string(),candidate_count:z.number().int(),over_soft_limit:z.boolean(),candidates:z.array(z.object({name:z.string(),path:z.string(),last_activity:z.string().nullable(),prompt_count:z.number().int()}))});function l(o,u){return {contents:[{uri:o.href,mimeType:"application/json",text:JSON.stringify(u)}]}}function we(){try{return {...o(o=>$(o))}}catch(o){return {error:String(o)}}}function ke(){try{let o$1="";try{existsSync(j)&&(o$1=readFileSync(j,"utf8"));}catch{}return {...o(d=>{let e=M(d).knowledge_ready,n=o$1.length>0,r=_(d),i={allowed:r.allowed,total_lessons:q(d)};return r.reason!=null&&(i.reason=r.reason),{onboarding:{knowledge_ready:e,notebook_ready:n,needs_onboarding:!(e&&n)},rate_limit:i,taught_topics:ea(d),profile:$(d)}}),notebook:o$1,notebook_path:j}}catch(o){return {error:String(o)}}}function ve(){try{let u=o(i=>M(i)).knowledge_ready,d=existsSync(j)&&statSync(j).size>0,e=b$1(),n=c$3(),r=b$2(a$2(e.folder??process.cwd()),n.detected_stack);return {knowledge_ready:u,notebook_ready:d,needs_onboarding:!(u&&d),detected_stack:r,detected_projects:n.projects,scanned_projects:n.scanned_projects,default_topics:k,context_ready:e.branch!==null,notebook_path:j}}catch(o){return {error:String(o)}}}var N=(o,u)=>typeof u.error=="string"?c(`${o} failed: ${u.error}`):m(u);function Ue(){let o$1=new McpServer({name:"devcoach",version:Q},{instructions:"Progressive technical coaching server. Use the devcoach_instructions prompt for full coaching behaviour guidelines. Read coaching state with the get_briefing / get_onboarding / get_profile tools; the devcoach:// resources expose the same data for clients that browse resources. share_lesson hands a lesson to another person (text, link or file); import_lesson stores one they were given."});o$1.registerTool("log_lesson",{title:"Log Lesson",description:"Save a delivered lesson to the coaching log. Git metadata (project, repository, branch, commit_hash, folder, repository_platform) is auto-detected from the workspace when omitted. timestamp is always stamped server-side with the current time \u2014 there is no argument for it. Returns the saved Lesson with all resolved fields.",inputSchema:z.object({id:z.string().describe("Unique lesson id (uuid or random string)"),topic_id:z.string().describe("Primary topic id, e.g. 'python'"),categories:z.array(z.string()).describe("Category tags, e.g. ['python','performance']"),title:z.string().describe("Short lesson title"),level:a.describe("Difficulty level: junior | mid | senior"),summary:z.string().describe("1-3 sentence summary shown in the lesson card"),body:z.string().min(1).describe("Clean lesson markdown: the prose + \u{1F4A1} Senior tip only \u2014 NO card bands, NO '>' blockquote, and do not repeat title/category/level (those are their own fields). Required, non-empty."),task_context:z.string().nullish().describe("What the user was doing when taught"),project:z.string().nullish().describe("Project name (auto-detected from git if omitted)"),repository:z.string().nullish().describe("org/repo or path (auto-detected if omitted)"),branch:z.string().nullish().describe("git branch (auto-detected if omitted)"),commit_hash:z.string().nullish().describe("git commit hash (auto-detected if omitted)"),folder:z.string().nullish().describe("workspace folder (auto-detected if omitted)"),repository_platform:b.nullish().describe("github | gitlab | bitbucket | local (auto-detected if omitted)")}),outputSchema:Ne,annotations:{title:"Log Lesson",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async e=>{try{let n=b$1(),r={};try{r=o(a=>N$1(a));}catch{r={};}let i=g({id:e.id,timestamp:new Date,topic_id:e.topic_id,categories:e.categories,title:e.title,level:e.level,summary:e.summary,body:e.body,task_context:e.task_context??null,project:e.project??n.project??r.project??null,repository:e.repository??n.repository??r.repository??null,branch:e.branch??n.branch??r.branch??null,commit_hash:e.commit_hash??n.commit_hash??null,folder:e.folder??n.folder??null,repository_platform:e.repository_platform??n.repository_platform??r.repository_platform??null});return o(a=>{p$1(a,i),J(a);}),{content:[p(`Lesson saved. ${ye}`),p(JSON.stringify(i))],structuredContent:{...i,reply_check:ye}}}catch(n){return c(`log_lesson failed: ${n}`)}}),o$1.registerTool("update_knowledge",{title:"Update Knowledge",description:"Adjust the confidence score for a topic by delta (e.g. +1 or -1). Returns the new confidence (0-10). Creates the topic at confidence 5 if it does not exist.",inputSchema:z.object({topic:z.string().describe("Topic id, e.g. 'python'"),delta:z.number().int().describe("Signed change to apply, e.g. +1 or -1")}),annotations:{title:"Update Knowledge",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async e=>{try{let n=o(r=>aa(r,e.topic,e.delta));return {content:[p(String(n))]}}catch(n){return c(`update_knowledge failed for '${e.topic}': ${n}`)}}),o$1.registerTool("get_lessons",{title:"Get Lessons",description:"Query the coaching lesson history. All filters combine. period defaults to all; date_from/date_to override period; limit caps results newest-first (0 = all).",inputSchema:z.object({period:z.enum(["today","week","month","year","all"]).nullish().describe("Time window"),category:z.string().nullish().describe("Filter by a category tag, e.g. 'python'"),level:z.enum(["junior","mid","senior"]).nullish().describe("Filter by difficulty level"),project:z.string().nullish().describe("Fuzzy match on git project"),repository:z.string().nullish().describe("Fuzzy match on git repository"),branch:z.string().nullish().describe("Fuzzy match on git branch"),commit:z.string().nullish().describe("Fuzzy match on commit hash"),starred:z.boolean().nullish().describe("True to return only starred lessons"),imported:z.boolean().nullish().describe("True = only lessons shared with you, false = only your own"),feedback:z.enum(["know","dont_know","none"]).nullish().describe("Filter by feedback ('none' = no response)"),search:z.string().nullish().describe("Full-text search over title, topic_id, summary, body"),date_from:z.string().nullish().describe("ISO date/datetime lower bound"),date_to:z.string().nullish().describe("ISO date/datetime upper bound (date-only = end-of-day)"),limit:z.number().int().default(10).describe("Max lessons, newest first. Pass 0 for all.")}),annotations:{title:"Get Lessons",readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false}},e=>{try{let n=o(r$1=>r(r$1,{period:e.period,category:e.category,level:e.level,project:e.project,repository:e.repository,branch:e.branch,commit:e.commit,starred:e.starred,imported:e.imported,feedback:e.feedback,search:e.search,date_from:e.date_from,date_to:e.date_to,page:e.limit>0?1:null,per_page:e.limit}));return fe(n)}catch{return fe([])}}),o$1.registerTool("star_lesson",{title:"Star Lesson",description:"Set the starred (favourite) flag on a lesson. Returns true if found and updated. Idempotent.",inputSchema:z.object({lesson_id:z.string().describe("Lesson id"),starred:z.boolean().describe("true to favourite, false to unmark")}),annotations:{title:"Star Lesson",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async e=>{try{let n=o(r=>t(r,e.lesson_id,e.starred));return {content:[p(String(n))]}}catch(n){return c(`star_lesson failed for '${e.lesson_id}': ${n}`)}}),o$1.registerTool("delete_lesson",{title:"Delete Lesson",description:"Permanently delete a lesson by id. Returns true if found and deleted.",inputSchema:z.object({lesson_id:z.string().describe("Lesson id to delete")}),annotations:{title:"Delete Lesson",destructiveHint:true,idempotentHint:true,openWorldHint:false}},async e=>{try{let n=o(r=>s(r,e.lesson_id));return {content:[p(String(n))]}}catch(n){return c(`delete_lesson failed for '${e.lesson_id}': ${n}`)}}),o$1.registerTool("submit_feedback",{title:"Submit Feedback",description:"Record comprehension feedback for a lesson and adjust knowledge confidence. know = +1, dont_know = -1, clear = remove feedback (no confidence change). Idempotent \u2014 the same feedback twice adjusts confidence only once.",inputSchema:z.object({lesson_id:z.string().describe("Lesson id"),feedback:z.enum(["know","dont_know","clear"]).describe("know | dont_know | clear")}),annotations:{title:"Submit Feedback",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async e=>{try{let n=e.feedback==="clear"?null:e.feedback,r=o(i=>{let a=i.prepare("SELECT feedback, topic_id FROM lessons WHERE id = ?").get(e.lesson_id);return a?(a.feedback===n||(u(i,e.lesson_id,n),(n==="know"||n==="dont_know")&&a.topic_id&&aa(i,a.topic_id,n==="know"?1:-1)),!0):!1});return {content:[p(String(r))]}}catch(n){return c(`submit_feedback failed for '${e.lesson_id}': ${n}`)}}),o$1.registerTool("skip_lesson",{title:"Skip Lesson",description:"Decline a lesson cue: call this when the coaching hook asked for a lesson but the completed work does not warrant one (pure questions, chat, nothing technical). Re-arms the pacing counter so the cue is not repeated immediately. Never call it after delivering a lesson \u2014 log_lesson already resolves the cue.",inputSchema:z.object({reason:z.string().min(1).describe("One line: why no lesson was warranted (shown in `devcoach doctor`)")}),annotations:{title:"Skip Lesson",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async e=>{try{return o(n=>L(n,e.reason)),{content:[p("Cue skipped \u2014 pacing re-armed. Output nothing to the user.")]}}catch(n){return c(`skip_lesson failed: ${n}`)}}),o$1.registerTool("add_topic",{title:"Add Topic",description:"Add a topic to the knowledge map, or update its confidence if it exists. Optionally assign to a group (auto-created). Prefer a single-word topic id. Idempotent.",inputSchema:z.object({topic:z.string().describe("Topic id \u2014 prefer a single word, max 3 words"),confidence:d.default(5).describe("Initial confidence 0-10 (default 5)"),group:z.string().nullish().describe("Optional group name; 'Other' if omitted")}),annotations:{title:"Add Topic",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async e=>{try{return o(n=>{A(n,e.topic,e.confidence),e.group&&e.group!=="Other"&&E(n,e.topic,e.group);}),{content:[p("true")]}}catch(n){return c(`add_topic failed for '${e.topic}': ${n}`)}}),o$1.registerTool("remove_topic",{title:"Remove Topic",description:"Remove a topic from the knowledge map entirely. Returns true if it existed.",inputSchema:z.object({topic:z.string().describe("Topic id to remove")}),annotations:{title:"Remove Topic",destructiveHint:true,idempotentHint:true,openWorldHint:false}},async e=>{try{let n=o(r=>B(r,e.topic));return {content:[p(String(n))]}}catch(n){return c(`remove_topic failed for '${e.topic}': ${n}`)}}),o$1.registerTool("add_group",{title:"Add Group",description:"Create a new (initially empty) knowledge group. Idempotent \u2014 returns true either way.",inputSchema:z.object({name:z.string().describe("Group name, e.g. 'Machine Learning'")}),annotations:{title:"Add Group",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async e=>{try{return o(n=>C(n,e.name.trim())),{content:[p("true")]}}catch(n){return c(`add_group failed for '${e.name}': ${n}`)}}),o$1.registerTool("remove_group",{title:"Remove Group",description:"Delete a knowledge group. Its topics move to Other. Returns true if it existed.",inputSchema:z.object({name:z.string().describe("Group name to delete")}),annotations:{title:"Remove Group",destructiveHint:true,idempotentHint:true,openWorldHint:false}},async e=>{try{let n=o(r=>D(r,e.name));return {content:[p(String(n))]}}catch(n){return c(`remove_group failed for '${e.name}': ${n}`)}}),o$1.registerTool("update_settings",{title:"Update Settings",description:"Update a coaching setting. max_per_day: integer 1-20. min_gap_minutes: integer 0-1440 (0 = no cooldown). nudge_every: integer 0-1000 interactions between lesson cues (0 = cue every turn). nudge_scope: 'session' | 'global'. share_name: the sender name proposed when sharing a lesson (max 80 chars, empty clears). Returns the full updated Settings.",inputSchema:z.object({key:z.enum(["max_per_day","min_gap_minutes","nudge_every","nudge_scope","share_name"]).describe("Setting key"),value:z.string().describe("New value (integer string; 'session'|'global' for nudge_scope; free text for share_name)")}),outputSchema:Oe,annotations:{title:"Update Settings",destructiveHint:false,idempotentHint:true,openWorldHint:false}},e=>{let n=i=>m(o(a=>(H(a,e.key,i),G(a))));if(e.key==="share_name")return e.value.trim().length>l$1?c(`share_name must be at most ${l$1} characters`):n(m$1(e.value));if(e.key==="nudge_scope")return e.value!=="session"&&e.value!=="global"?c("nudge_scope must be 'session' or 'global'"):n(e.value);let r=Number.parseInt(e.value,10);return Number.isNaN(r)?c(`Value must be an integer, got '${e.value}'`):e.key==="max_per_day"&&!(r>=1&&r<=20)?c("max_per_day must be between 1 and 20"):e.key==="min_gap_minutes"&&!(r>=0&&r<=1440)?c("min_gap_minutes must be between 0 and 1440"):e.key==="nudge_every"&&!(r>=0&&r<=1e3)?c("nudge_every must be between 0 and 1000"):n(String(r))}),o$1.registerTool("open_ui",{title:"Open UI",description:"Launch the devcoach web dashboard in the background. port must be 1024-65535.",inputSchema:z.object({port:z.number().int().default(7860).describe("Port (default 7860)")}),annotations:{title:"Open UI",destructiveHint:false,idempotentHint:false,openWorldHint:true}},e=>{let n=e.port;return n>=1024&&n<=65535?(spawn(process.execPath,[process.argv[1]??"","ui","--port",String(n)],{detached:true,stdio:"ignore"}).unref(),{content:[p(`devcoach UI starting at http://localhost:${n}`)]}):{content:[p(`error: port ${n} is out of valid range (1024-65535)`)]}}),o$1.registerTool("complete_onboarding",{title:"Complete Onboarding",description:"Save the user's initial knowledge profile and mark onboarding complete. Wipes any default-seeded profile. topics: {topic_id: confidence_0_to_10}. groups: {group_name: [topic_id,...]} (topics not in any group go to 'Other'). Ensures learning-state.md exists and is non-empty (a placeholder if needed) \u2014 there is no notebook argument here. Write the real personalized notebook yourself right after, directly to the path in devcoach://onboarding's notebook_path field. Returns the updated Profile.",inputSchema:z.object({topics:z.record(z.string(),d).describe("{topic_id: confidence 0-10}"),groups:z.record(z.string(),z.array(z.string())).optional().describe("{group_name: [topic_id, ...]}")}),outputSchema:_e,annotations:{title:"Complete Onboarding",destructiveHint:true,idempotentHint:false,openWorldHint:false}},async e=>{try{let n=o(r=>{r.exec("DELETE FROM knowledge; DELETE FROM knowledge_groups; DELETE FROM knowledge_group_names;");for(let[i,a]of Object.entries(e.topics))A(r,i,Math.max(0,Math.min(10,a)));if(e.groups)for(let[i,a]of Object.entries(e.groups))for(let O of a)O in e.topics&&E(r,O,i);return $(r)});return mkdirSync(dirname(j),{recursive:!0}),(!existsSync(j)||statSync(j).size===0)&&writeFileSync(j,`# devcoach \u2014 Coaching Notebook
|
|
3
|
+
`),m(n)}catch(n){return c(`complete_onboarding failed: ${n}`)}}),o$1.registerTool("preview_deep_scan",{title:"Preview Deep Scan",description:"Cheap, metadata-only pre-check for 'Automatic (Deep)' onboarding. Counts and lists Claude Code projects whose last recorded activity falls within a rolling window (months back from now) \u2014 a real date window, not a fixed top-N. Reads no prompt/conversation text, only project paths and activity timestamps. Call this BEFORE spawning the deep-read subagent: over_soft_limit true means there are enough candidates that the user should be asked whether to narrow the window, proceed anyway, or pick specific projects.",inputSchema:z.object({months:z.number().int().min(1).max(24).default(3).describe("Rolling window size in months, counting back from now")}),outputSchema:Fe,annotations:{title:"Preview Deep Scan",readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false}},e=>{try{return m({...d$1(e.months)})}catch(n){return c(`preview_deep_scan failed: ${n}`)}});let u$1=e=>({title:e,readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false});o$1.registerTool("get_briefing",{title:"Lesson Briefing",description:"Everything needed before delivering a lesson, in ONE call: onboarding status, rate limit, taught topics, knowledge profile, the coaching notebook text and its notebook_path. Same data as the devcoach://briefing resource \u2014 call the tool, it needs no server name.",inputSchema:z.object({}),annotations:u$1("Lesson Briefing")},()=>N("get_briefing",ke())),o$1.registerTool("get_onboarding",{title:"Onboarding Status & Detected Stack",description:"Onboarding status (knowledge_ready, notebook_ready, needs_onboarding), the stack detected across the full Claude Code history with per-project provenance, the default topics and the notebook_path. Same data as the devcoach://onboarding resource.",inputSchema:z.object({}),annotations:u$1("Onboarding Status & Detected Stack")},()=>N("get_onboarding",ve())),o$1.registerTool("get_profile",{title:"Knowledge Profile",description:"Current knowledge map: topics with confidence 0\u201310 and their groups. Same data as the devcoach://profile resource.",inputSchema:z.object({}),outputSchema:_e,annotations:u$1("Knowledge Profile")},()=>N("get_profile",we())),o$1.registerTool("share_lesson",{title:"Share Lesson",description:"Hand a lesson to another person. transport 'text' (default) returns the card plus a one-line code to paste anywhere; 'link' a server-less URL that previews the lesson and imports it into their dashboard; 'file' the contents of a .devcoach.md file. Only title, summary, body, topic, categories and level travel unless include_context is true; local paths never do. Pick the lesson with get_lessons first.",inputSchema:z.object({lesson_id:z.string().describe("Lesson id (from get_lessons)"),transport:z.enum(["text","link","file"]).default("text").describe("text = card + code to paste; link = share URL; file = .devcoach.md contents"),include_context:z.boolean().default(false).describe("Include project/branch/commit/task context (off by default \u2014 privacy). Local paths are never included."),shared_by:z.string().nullish().describe("Sender name. Omit \u2192 the share_name setting, then git user.name. Empty string \u2192 anonymous.")}),outputSchema:Pe,annotations:u$1("Share Lesson")},e=>{try{let n=o(r=>{let i=x(r,e.lesson_id);if(!i)return null;let a=T({explicit:e.shared_by??null,setting:G(r).share_name,gitUserName:a$1()});return S(i,{includeContext:e.include_context,sharedBy:a})});return n?m({transport:e.transport,code:U(n),text:e.transport==="text"?W(n):null,link:e.transport==="link"?X(n):null,markdown:e.transport==="file"?Z(n):null,filename:e.transport==="file"?Y(n):null,shared_by:n.shared_by,include_context:e.include_context,reply_check:$e[e.transport]}):c(`share_lesson: lesson '${e.lesson_id}' not found \u2014 call get_lessons to pick one`)}catch(n){return c(`share_lesson failed: ${n}`)}}),o$1.registerTool("import_lesson",{title:"Import Lesson",description:"Store a lesson someone shared. Pass whatever the user handed you, verbatim: the devcoach:lesson:1:\u2026 code, the whole copied card, the share link, a URL to the lesson text, the contents of a .devcoach.md file, or a lessons JSON export. The lesson joins the coaching log as their own (feedback works as usual) but never counts against the daily limit; re-importing the same share is reported as a duplicate, not an error.",inputSchema:z.object({payload:z.string().min(1).describe("The code, link, URL, card text, file text or JSON \u2014 verbatim")}),outputSchema:Ie,annotations:{title:"Import Lesson",destructiveHint:false,idempotentHint:true,openWorldHint:true}},async e=>{try{let n=c$2(e.payload)&&!e.payload.includes("#devcoach:lesson:")?await d$2(e.payload):e.payload,r=o(i=>da(i,n));return m({...r,reply_check:Ge})}catch(n){return n instanceof R?c(`import_lesson: ${n.message}`):c(`import_lesson failed: ${n}`)}});let d$3=(e,n)=>({title:e,description:n,mimeType:"application/json"});return o$1.registerResource("profile","devcoach://profile",d$3("Knowledge Profile","Current knowledge map \u2014 topics, confidence scores, and groups."),e=>l(e,we())),o$1.registerResource("notebook","devcoach://notebook",{title:"Coaching Notebook",description:"The coaching notebook (learning-state.md): observations, recurring patterns, recommended focus, and open hypotheses about the user. Read it to decide what to teach.",mimeType:"text/markdown"},e=>{let n="";try{existsSync(j)&&(n=readFileSync(j,"utf8"));}catch{}return {contents:[{uri:e.href,mimeType:"text/markdown",text:n}]}}),o$1.registerResource("settings","devcoach://settings",d$3("Settings","Current coaching settings (rate limits, UI theme)."),e=>{try{return l(e,o(n=>G(n)))}catch(n){return l(e,{error:String(n)})}}),o$1.registerResource("recent-lessons","devcoach://lessons/recent",d$3("Recent Lessons","Last 10 lessons from the current week."),e=>{try{return l(e,o(n=>r(n,{period:"week",page:1,per_page:10})))}catch(n){return l(e,[{error:String(n)}])}}),o$1.registerResource("stats","devcoach://stats",d$3("Stats","Aggregate coaching statistics: counts and weakest/strongest topics."),e=>{try{return l(e,o(n=>ca(n)))}catch(n){return l(e,{error:String(n)})}}),o$1.registerResource("taught-topics","devcoach://taught-topics",d$3("Taught Topics","All topic_ids already taught \u2014 read before selecting a new lesson topic."),e=>{try{return l(e,o(n=>ea(n)))}catch{return l(e,[])}}),o$1.registerResource("rate-limit","devcoach://rate-limit",d$3("Rate Limit","Current rate-limit status and running lesson total."),e=>{try{let{r:n,total:r}=o(a=>({r:_(a),total:q(a)})),i={allowed:n.allowed,total_lessons:r};return n.reason!=null&&(i.reason=n.reason),l(e,i)}catch(n){return l(e,{allowed:false,reason:`Rate limit check unavailable: ${n}`})}}),o$1.registerResource("briefing","devcoach://briefing",d$3("Lesson Briefing","Everything needed before delivering a lesson in ONE read: onboarding status, rate limit, taught topics, knowledge profile, and the coaching notebook."),e=>l(e,ke())),o$1.registerResource("context","devcoach://context",d$3("Workspace Context","Auto-detected git context and most-used lesson metadata defaults."),e=>{try{let n=b$1(),r=o(i=>N$1(i));return l(e,{git:n,usage_defaults:r})}catch(n){return l(e,{error:String(n)})}}),o$1.registerResource("onboarding","devcoach://onboarding",d$3("Onboarding","Onboarding status, the stack detected across the full Claude Code history (with per-project provenance), and project topic defaults."),e=>l(e,ve())),o$1.registerResource("lesson",new ResourceTemplate("devcoach://lessons/{lesson_id}",{list:void 0}),d$3("Lesson","A single lesson by id."),(e,n)=>{try{let r=String(n.lesson_id),i=o(a=>x(a,r));return i?l(e,i):l(e,{error:`Lesson '${r}' not found`})}catch(r){return l(e,{error:String(r)})}}),o$1.registerPrompt("devcoach_instructions",{title:"devcoach coaching instructions",description:"Full coaching instructions for the devcoach skill (SKILL.md plus its reference files)."},()=>{let e=f$1().map(n=>`
|
|
4
|
+
|
|
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=Ue(),u=new StdioServerTransport;await o.connect(u);}export{Ue as createServer,ot as runStdio};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devcoach",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.1.0-next.503.g8594664",
|
|
4
4
|
"mcpName": "io.github.UltimaPhoenix/devcoach",
|
|
5
5
|
"description": "Stay sharp while your AI does the work — learn from every task with in-context coaching, all local, all free",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
package/dist/chunk-ECN4MNGM.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {z as z$1}from'zod';import {existsSync,readFileSync,mkdirSync,writeFileSync}from'fs';import {createRequire}from'module';import {homedir}from'os';import {join,dirname}from'path';import {strToU8,zipSync,unzipSync,strFromU8}from'fflate';var se=z$1.enum(["junior","mid","senior"]),oe=z$1.enum(["github","gitlab","bitbucket","local"]),re=z$1.enum(["know","dont_know"]),He=z$1.number().int().min(0).max(10);function ie(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}function ae(e){if(e instanceof Date){if(Number.isNaN(e.getTime()))throw new TypeError("Invalid Date");return e}let t=e.trim();/[zZ]$|[+-]\d{2}:?\d{2}$/.test(t)||(t=t.includes("T")||t.includes(" ")?`${t.replace(" ","T")}Z`:`${t}T00:00:00Z`);let s=new Date(t);if(Number.isNaN(s.getTime()))throw new TypeError(`Cannot parse timestamp ${JSON.stringify(e)} \u2014 expected ISO 8601`);return s}function ce(e){let t=ae(e),n=new Date;return t.getTime()>n.getTime()&&(t=n),ie(t)}var ue=z$1.union([z$1.string(),z$1.date()]).transform((e,t)=>{try{return ce(e)}catch(n){return t.addIssue({code:"custom",message:n.message}),z$1.NEVER}}),T=z$1.string().nullish().transform(e=>e??null),le=z$1.object({id:z$1.string(),timestamp:ue,topic_id:z$1.string(),categories:z$1.array(z$1.string()),title:z$1.string(),level:se,summary:z$1.string(),body:T,task_context:T,project:T,repository:T,branch:T,commit_hash:T,folder:T,repository_platform:oe.nullish().transform(e=>e??null),starred:z$1.boolean().default(false),feedback:re.nullish().transform(e=>e??null)}),pe=z$1.object({topic:z$1.string(),confidence:z$1.number().int()}),ge=z$1.object({name:z$1.string(),topics:z$1.array(z$1.string())});z$1.object({knowledge:z$1.array(pe),groups:z$1.array(ge)});var de=z$1.enum(["system","dark","light"]),me=z$1.enum(["session","global"]);z$1.object({max_per_day:z$1.number().int().default(2),min_gap_minutes:z$1.number().int().default(240),ui_theme:de.default("system"),nudge_every:z$1.number().int().min(0).default(10),nudge_scope:me.default("session")});function D(e){return le.parse(e)}var {DatabaseSync:Ne}=createRequire(import.meta.url)("node:sqlite"),j=process.env.DEVCOACH_DIR??join(homedir(),".devcoach"),C=join(j,"coaching.db"),R=join(j,"learning-state.md"),b="settings.json",h="lessons.json",w="knowledge.json",x="learning-state.md",nt={engineering:8,architecture:8,patterns:7,debugging:8,node:7,javascript:7,typescript:6,python:4,django:3,fastapi:4,docker:8,traefik:7,coolify:7,postgresql:6,redis:6,git:7,ci_cd:6,security:5,performance:6,testing:5,linux:7,networking:6,react:5,frontend:5},Le={max_per_day:"2",min_gap_minutes:"240",ui_theme:"system",nudge_every:"10",nudge_scope:"session"},Oe=50;function d(e,t,...n){return e.prepare(t).all(...n)}function m(e,t,...n){return e.prepare(t).get(...n)}function l(e,t,...n){return Number(e.prepare(t).run(...n).changes)}function De(e=C){e!==":memory:"&&mkdirSync(dirname(e),{recursive:true});let t=new Ne(e);return t.exec("PRAGMA busy_timeout = 3000"),t}var X=2;function be(e=C){let t=De(e),n=t.prepare("PRAGMA user_version").get();return Number(n?.user_version??0)!==X&&(he(t),t.exec(`PRAGMA user_version = ${X}`)),t}function st(e,t){e.exec("BEGIN IMMEDIATE");try{let n=t();return e.exec("COMMIT"),n}catch(n){try{e.exec("ROLLBACK");}catch{}throw n}}function ot(e,t=C){let n=be(t);try{return e(n)}finally{n.close();}}function he(e){e.exec(`
|
|
3
|
-
CREATE TABLE IF NOT EXISTS lessons (
|
|
4
|
-
id TEXT PRIMARY KEY,
|
|
5
|
-
timestamp TEXT NOT NULL,
|
|
6
|
-
topic_id TEXT NOT NULL,
|
|
7
|
-
categories TEXT NOT NULL,
|
|
8
|
-
title TEXT NOT NULL,
|
|
9
|
-
level TEXT NOT NULL,
|
|
10
|
-
summary TEXT NOT NULL,
|
|
11
|
-
body TEXT,
|
|
12
|
-
task_context TEXT,
|
|
13
|
-
project TEXT,
|
|
14
|
-
repository TEXT,
|
|
15
|
-
branch TEXT,
|
|
16
|
-
commit_hash TEXT,
|
|
17
|
-
folder TEXT,
|
|
18
|
-
feedback TEXT,
|
|
19
|
-
repository_platform TEXT,
|
|
20
|
-
starred INTEGER NOT NULL DEFAULT 0
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
CREATE TABLE IF NOT EXISTS knowledge (
|
|
24
|
-
topic TEXT PRIMARY KEY,
|
|
25
|
-
confidence INTEGER NOT NULL DEFAULT 5,
|
|
26
|
-
updated_at TEXT NOT NULL
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
CREATE TABLE IF NOT EXISTS settings (
|
|
30
|
-
key TEXT PRIMARY KEY,
|
|
31
|
-
value TEXT NOT NULL
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
CREATE TABLE IF NOT EXISTS knowledge_group_names (
|
|
35
|
-
group_name TEXT PRIMARY KEY
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
CREATE TABLE IF NOT EXISTS knowledge_groups (
|
|
39
|
-
group_name TEXT NOT NULL,
|
|
40
|
-
topic TEXT NOT NULL,
|
|
41
|
-
PRIMARY KEY (group_name, topic)
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
-- Runtime-only: per-session interaction counter for lesson-cue pacing.
|
|
45
|
-
-- Never exported/imported (backup carries config, not this state).
|
|
46
|
-
CREATE TABLE IF NOT EXISTS nudge_state (
|
|
47
|
-
session_id TEXT PRIMARY KEY,
|
|
48
|
-
interactions INTEGER NOT NULL DEFAULT 0,
|
|
49
|
-
updated_at TEXT NOT NULL
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
-- Runtime-only, single row: cue lifecycle. pending=1 between an emitted cue and
|
|
53
|
-
-- its resolution (log_lesson or skip_lesson), arming a shorter retry threshold.
|
|
54
|
-
CREATE TABLE IF NOT EXISTS cue_state (
|
|
55
|
-
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
56
|
-
pending INTEGER NOT NULL DEFAULT 0,
|
|
57
|
-
last_cue_at TEXT,
|
|
58
|
-
last_skip_reason TEXT
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
CREATE INDEX IF NOT EXISTS idx_lessons_timestamp ON lessons (timestamp);
|
|
62
|
-
CREATE INDEX IF NOT EXISTS idx_lessons_starred_ts ON lessons (starred, timestamp);
|
|
63
|
-
CREATE INDEX IF NOT EXISTS idx_lessons_feedback ON lessons (feedback);
|
|
64
|
-
CREATE INDEX IF NOT EXISTS idx_lessons_topic_id ON lessons (topic_id);
|
|
65
|
-
`),we(e),xe(e);}function we(e){try{e.exec("ALTER TABLE lessons ADD COLUMN body TEXT");}catch{}}function xe(e){for(let[t,n]of Object.entries(Le))l(e,"INSERT OR IGNORE INTO settings (key, value) VALUES (?, ?)",t,n);}var B="(id, timestamp, topic_id, categories, title, level, summary, body, task_context, project, repository, branch, commit_hash, folder, repository_platform, starred, feedback)",H="(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";function W(e){return [e.id,e.timestamp,e.topic_id,JSON.stringify(e.categories),e.title,e.level,e.summary,e.body,e.task_context,e.project,e.repository,e.branch,e.commit_hash,e.folder,e.repository_platform,e.starred?1:0,e.feedback]}function rt(e,t){l(e,`INSERT OR REPLACE INTO lessons ${B} VALUES ${H}`,...W(t));}var Ie=[["project","project"],["repository","repository"],["branch","branch"],["commit","commit_hash"]];function Ce(e,t){if(e.date_from==null&&e.date_to==null){let n=Ke(e.period??null);n!=null&&t("timestamp >= ?",n);return}if(e.date_from!=null&&t("timestamp >= ?",e.date_from),e.date_to!=null){let n=e.date_to.includes("T")||e.date_to.includes(" ");t("timestamp <= ?",n?e.date_to:`${e.date_to}T23:59:59`);}}function z(e){let t=[],n=[],s=(r,...i)=>{t.push(r),n.push(...i);};Ce(e,s),e.category!=null&&s("categories LIKE ?",`%"${e.category}"%`),e.level!=null&&s("level = ?",e.level);for(let[r,i]of Ie){let c=e[r];c!=null&&s(`${i} LIKE ?`,`%${c}%`);}if(e.starred!=null&&s("starred = ?",e.starred?1:0),e.search!=null){let r=`%${e.search}%`;s("(title LIKE ? OR topic_id LIKE ? OR summary LIKE ? OR body LIKE ?)",r,r,r,r);}return e.feedback==="none"?s("feedback IS NULL"):e.feedback!=null&&s("feedback = ?",e.feedback),{where:t.length?`WHERE ${t.join(" AND ")}`:"",params:n}}function q(e,t={}){let{where:n,params:s}=z(t),o=m(e,`SELECT COUNT(*) AS n FROM lessons ${n}`,...s);return Number(o?.n??0)}var ke=new Set(["timestamp","level","topic_id","title","feedback"]),Ae=new Set(["project","repository","branch","commit_hash","repository_platform"]);function it(e,t={}){let{where:n,params:s}=z(t),o=t.sort&&ke.has(t.sort)?t.sort:"timestamp",r=(t.order??"desc").toLowerCase()==="asc"?"ASC":"DESC",i=`SELECT * FROM lessons ${n} ORDER BY ${o} ${r}`,c=[...s];if(t.page!=null){let u=t.per_page??25;i+=" LIMIT ? OFFSET ?",c.push(u,(t.page-1)*u);}return d(e,i,...c).map(P)}function at(e,t){return l(e,"DELETE FROM lessons WHERE id = ?",t)>0}function ct(e,t,n){return l(e,"UPDATE lessons SET starred = ? WHERE id = ?",n?1:0,t)>0}function V(e,t,n){l(e,"UPDATE lessons SET feedback = ? WHERE id = ?",n||null,t);let s=m(e,"SELECT topic_id FROM lessons WHERE id = ?",t);return s?s.topic_id:null}function Ue(e){return d(e,"SELECT * FROM lessons ORDER BY timestamp DESC").map(P)}function Fe(e,t){let n=0,s=0,o=0;for(let r of t){let i;try{i=D(r);}catch{o+=1;continue}l(e,`INSERT OR IGNORE INTO lessons ${B} VALUES ${H}`,...W(i))>0?n+=1:s+=1;}return {inserted:n,duplicated:s,invalid:o}}function ut(e,t){if(!Ae.has(t))throw new Error(`Column not allowed: ${JSON.stringify(t)}`);return d(e,`SELECT DISTINCT ${t} FROM lessons WHERE ${t} IS NOT NULL ORDER BY ${t}`).map(s=>s[t])}function lt(e,t){let n=m(e,"SELECT * FROM lessons WHERE id = ?",t);return n?P(n):null}function pt(e){return d(e,"SELECT DISTINCT value FROM lessons, json_each(lessons.categories) ORDER BY value").map(n=>n.value)}function Z(e){return d(e,"SELECT DISTINCT topic_id FROM lessons").map(t=>t.topic_id)}function O(e,t){let n=m(e,"SELECT COUNT(*) AS n FROM lessons WHERE timestamp >= ?",t);return Number(n?.n??0)}function J(e){let t=m(e,"SELECT timestamp FROM lessons ORDER BY timestamp DESC LIMIT 1");return t?t.timestamp:null}function k(e){let t={};for(let n of d(e,"SELECT topic, confidence FROM knowledge"))t[n.topic]=Number(n.confidence);return t}function A(e){return d(e,"SELECT topic, confidence FROM knowledge ORDER BY topic").map(t=>({topic:t.topic,confidence:Number(t.confidence)}))}function U(e){let t=d(e,"SELECT group_name FROM knowledge_group_names ORDER BY group_name").map(s=>s.group_name),n=new Map;for(let s of d(e,"SELECT group_name, topic FROM knowledge_groups ORDER BY group_name, topic")){let o=s.group_name,r=n.get(o)??[];r.push(s.topic),n.set(o,r);}return t.map(s=>({name:s,topics:n.get(s)??[]}))}function N(e,t,n){let s=Math.max(0,Math.min(10,n)),o=new Date().toISOString();l(e,`INSERT INTO knowledge (topic, confidence, updated_at) VALUES (?, ?, ?)
|
|
66
|
-
ON CONFLICT(topic) DO UPDATE SET confidence = excluded.confidence, updated_at = excluded.updated_at`,t,s,o);}function gt(e,t){let n=l(e,"DELETE FROM knowledge WHERE topic = ?",t);return l(e,"DELETE FROM knowledge_groups WHERE topic = ?",t),n>0}function K(e,t){let n=t.trim();if(!n)throw new Error("Group name must not be empty");return l(e,"INSERT OR IGNORE INTO knowledge_group_names (group_name) VALUES (?)",n)>0}function dt(e,t){return l(e,"DELETE FROM knowledge_groups WHERE group_name = ?",t),l(e,"DELETE FROM knowledge_group_names WHERE group_name = ?",t)>0}function Me(e,t,n){l(e,"INSERT OR IGNORE INTO knowledge_group_names (group_name) VALUES (?)",n),l(e,"DELETE FROM knowledge_groups WHERE topic = ?",t),l(e,"INSERT OR IGNORE INTO knowledge_groups (group_name, topic) VALUES (?, ?)",n,t);}function mt(e,t){l(e,"DELETE FROM knowledge_groups WHERE topic = ?",t);}function f(e){let t={};for(let g of d(e,"SELECT key, value FROM settings"))t[g.key]=g.value;let n=t.min_gap_minutes,s=t.min_hours_between,o;n!==void 0?o=Number.parseInt(n,10):s!==void 0?o=Number.parseInt(s,10)*60:o=240;let r=t.max_per_day,i=t.ui_theme??"system",c=i==="dark"||i==="light"||i==="system"?i:"system",u=t.nudge_every,p=u!==void 0?Number.parseInt(u,10):10,_=t.nudge_scope==="global"?"global":"session";return {max_per_day:r!==void 0?Number.parseInt(r,10):2,min_gap_minutes:o,ui_theme:c,nudge_every:Number.isFinite(p)&&p>=0?p:10,nudge_scope:_}}function S(e,t,n){l(e,"INSERT INTO settings (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",t,n);}function Q(e,t,n){let s=m(e,"INSERT INTO nudge_state (session_id, interactions, updated_at) VALUES (?, 1, ?) ON CONFLICT(session_id) DO UPDATE SET interactions = interactions + 1, updated_at = excluded.updated_at RETURNING interactions",t,new Date().toISOString()),o=Number(s?.interactions??0);return o===1&&l(e,"DELETE FROM nudge_state WHERE session_id NOT IN (SELECT session_id FROM nudge_state ORDER BY updated_at DESC LIMIT ?)",Oe),n==="global"?F(e,t,n):o}function Et(e){return d(e,"SELECT session_id, interactions, updated_at FROM nudge_state ORDER BY updated_at DESC").map(t=>({session_id:String(t.session_id),interactions:Number(t.interactions),updated_at:String(t.updated_at)}))}function F(e,t,n){let s=n==="global"?m(e,"SELECT COALESCE(SUM(interactions), 0) AS n FROM nudge_state"):m(e,"SELECT interactions AS n FROM nudge_state WHERE session_id = ?",t);return Number(s?.n??0)}function Tt(e){l(e,"DELETE FROM nudge_state"),l(e,"UPDATE cue_state SET pending = 0 WHERE id = 1");}var M=3;function v(e){let t=m(e,"SELECT pending, last_cue_at, last_skip_reason FROM cue_state WHERE id = 1");return {pending:Number(t?.pending??0)===1,last_cue_at:t?.last_cue_at??null,last_skip_reason:t?.last_skip_reason??null}}function ee(e){l(e,"INSERT INTO cue_state (id, pending, last_cue_at) VALUES (1, 1, ?) ON CONFLICT(id) DO UPDATE SET pending = 1, last_cue_at = excluded.last_cue_at",new Date().toISOString()),l(e,"DELETE FROM nudge_state");}function _t(e,t){l(e,"INSERT INTO cue_state (id, pending, last_skip_reason) VALUES (1, 0, ?) ON CONFLICT(id) DO UPDATE SET pending = 0, last_skip_reason = excluded.last_skip_reason",t??null),l(e,"DELETE FROM nudge_state");}function $(e){let t=m(e,"SELECT COUNT(*) AS n FROM knowledge");return {knowledge_ready:Number(t?.n??0)>0}}function St(e){let t={};for(let n of ["project","repository","branch","repository_platform"]){let s=m(e,`SELECT ${n} AS v, COUNT(*) AS c FROM lessons WHERE ${n} IS NOT NULL GROUP BY ${n} ORDER BY c DESC LIMIT 1`);t[n]=s?s.v:null;}return t}function ft(e){let t=f(e),n=Ue(e),s=A(e),o=U(e),r=new Map;for(let u of o)for(let p of u.topics)r.set(p,u.name);let i={groups:o.map(u=>u.name),topics:s.map(u=>({topic:u.topic,confidence:u.confidence,group:r.get(u.topic)??null}))},c={[b]:strToU8(JSON.stringify(t,null,2)),[h]:strToU8(JSON.stringify(n,null,2)),[w]:strToU8(JSON.stringify(i,null,2))};return existsSync(R)&&(c[x]=strToU8(readFileSync(R,"utf8"))),zipSync(c)}function ve(e,t,n){if(!(b in t))return;let s=JSON.parse(strFromU8(t[b]));"max_per_day"in s&&S(e,"max_per_day",String(s.max_per_day)),"min_gap_minutes"in s&&S(e,"min_gap_minutes",String(s.min_gap_minutes)),(s.ui_theme==="system"||s.ui_theme==="dark"||s.ui_theme==="light")&&S(e,"ui_theme",s.ui_theme),"nudge_every"in s&&S(e,"nudge_every",String(s.nudge_every)),(s.nudge_scope==="session"||s.nudge_scope==="global")&&S(e,"nudge_scope",s.nudge_scope),n.settings=1;}function $e(e,t,n){if(!(w in t))return;let s=JSON.parse(strFromU8(t[w]));if(!(s&&typeof s=="object"&&Array.isArray(s.topics))){for(let[r,i]of Object.entries(s))N(e,r,i);n.topics=Object.keys(s).length;return}let o=0;for(let r of s.groups??[])K(e,r)&&(o+=1);for(let r of s.topics){N(e,r.topic,r.confidence);let i=r.group;i&&i!=="Other"&&(K(e,i)&&(o+=1),Me(e,r.topic,i));}n.topics=s.topics.length,n.groups=o;}function Pe(e,t,n){if(!(h in t))return;let s=JSON.parse(strFromU8(t[h])),{inserted:o,duplicated:r,invalid:i}=Fe(e,s);n.lessons=o,n.skipped=r,n.invalid=i;}function Xe(e,t){x in e&&(mkdirSync(dirname(R),{recursive:true}),writeFileSync(R,strFromU8(e[x]),"utf8"),t.learning_state=1);}function yt(e,t){let n={settings:0,topics:0,groups:0,lessons:0,skipped:0,invalid:0,learning_state:0},s=unzipSync(t);return ve(e,s,n),$e(e,s,n),Pe(e,s,n),Xe(s,n),n}function Ke(e){let t=new Date,n;if(e==="today")n=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0));else if(e==="week")n=new Date(t.getTime()-7*864e5);else if(e==="month")n=new Date(t.getTime()-30*864e5);else if(e==="year")n=new Date(t.getTime()-365*864e5);else return null;return n.toISOString()}function P(e){let t=[];try{let n=JSON.parse(e.categories);Array.isArray(n)&&(t=n);}catch{t=[];}return D({...e,categories:t,starred:!!e.starred})}function te(e){try{let t=f(e),n=new Date,s=new Date(n.getTime()-24*36e5).toISOString(),o=O(e,s);if(o>=t.max_per_day)return {allowed:!1,reason:`Daily limit reached (${o}/${t.max_per_day} lessons in the last 24h)`};let r=J(e);if(r!=null){let i=new Date(r),c=(n.getTime()-i.getTime())/6e4;if(c<t.min_gap_minutes){let u=t.min_gap_minutes-c,p=Math.floor(t.min_gap_minutes/60),_=t.min_gap_minutes%60,g=Math.trunc(u),E=Math.floor(g/60),ne=g%60;return {allowed:!1,reason:`Too soon: last lesson ${c<0?`in ${Math.round(-c)}m (future timestamp)`:`${Math.round(c)}m ago`}, minimum interval is ${p}h ${_}m (${E}h ${ne}m remaining)`}}}return {allowed:!0}}catch(t){return {allowed:true,reason:`Rate limit check failed: ${t}`}}}function Lt(e){try{return {knowledge:A(e),groups:U(e)}}catch{return {knowledge:[],groups:[]}}}function Ge(e,t,n){let s=k(e)[t]??5,o=Math.max(0,Math.min(10,s+n));return N(e,t,o),o}function Ot(e,t,n){let s=V(e,t,n);return s&&(n==="know"||n==="dont_know")&&Ge(e,s,n==="know"?1:-1),s}function Ye(e){try{let t=new Date,n=q(e),s=new Date(t.getTime()-24*36e5).toISOString(),o=new Date(t.getTime()-7*864e5).toISOString(),r=O(e,s),i=O(e,o),c=k(e),u=Object.entries(c).sort((g,E)=>g[1]-E[1]),p=u.slice(0,5).map(([g,E])=>({topic:g,confidence:E})),_=u.slice(-5).reverse().map(([g,E])=>({topic:g,confidence:E}));return {total_lessons:n,lessons_today:r,lessons_this_week:i,weakest_topics:p,strongest_topics:_}}catch(t){return {error:String(t)}}}function Dt(e){try{return Z(e)}catch{return []}}function bt(e,t,n){let s=c=>({cue:false,reason:c,nextLessonNumber:0});if(n.planMode)return s("plan mode (not counted)");if(!$(e).knowledge_ready)return s("onboarding not complete");let o=f(e),r="pacing disabled (nudge_every=0)";if(o.nudge_every>0){let c=Q(e,t??"__nosession__",o.nudge_scope),{pending:u}=v(e),p=u?Math.min(M,o.nudge_every):o.nudge_every;if(r=`${c}/${p}${u?" (retry window)":""}`,c<p)return s(`paced (${r})`)}let i=te(e);return i.allowed?(ee(e),{cue:true,reason:`cue (${r})`,nextLessonNumber:Number(Ye(e).total_lessons??0)+1}):s(`rate limited: ${i.reason??"denied"}`)}function ht(e,t){try{let n=[],s=!0;if(!$(e).knowledge_ready)return {wouldCue:!1,reasons:["onboarding not complete \u2014 no knowledge topics yet"]};let o=f(e);if(o.nudge_every>0){let i=F(e,t??"__nosession__",o.nudge_scope)+1,{pending:c}=v(e),u=c?Math.min(M,o.nudge_every):o.nudge_every;i<u?(s=!1,n.push(`pacing: next stop would be ${i}/${u}${c?" (retry window)":""}`)):n.push(`pacing: next stop reaches the threshold (${i}/${u})`);}else n.push("pacing disabled (nudge_every=0) \u2014 every eligible stop cues");let r=te(e);return r.allowed?n.push("rate limit: allowed"):(s=!1,n.push(`rate limited: ${r.reason??"denied"}`)),{wouldCue:s,reasons:n}}catch(n){return {wouldCue:false,reasons:[`check failed: ${n}`]}}}export{gt as A,K as B,dt as C,Me as D,mt as E,f as F,S as G,Et as H,Tt as I,v as J,_t as K,$ as L,St as M,ft as N,yt as O,te as P,Lt as Q,Ge as R,Ot as S,Ye as T,Dt as U,bt as V,ht as W,se as a,oe as b,re as c,He as d,de as e,me as f,D as g,j as h,C as i,R as j,nt as k,st as l,ot as m,rt as n,q as o,it as p,at as q,ct as r,V as s,Ue as t,Fe as u,ut as v,lt as w,pt as x,A as y,N as z};
|
package/dist/chunk-QGXVUN7G.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {i,m as m$1,L,W,h as h$1,l as l$1,V}from'./chunk-ECN4MNGM.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;try{o=m$1(t=>L(t).knowledge_ready);}catch(t){s("onboard-hook",e.session_id,`error: ${t}`),process.exit(0);}o&&process.exit(0);}s("onboard-hook",e.session_id,"onboarding cue"),h("claude",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(!L(e).knowledge_ready)return !t.onboardCue||n?{kind:"silent",note:"onboarding not complete"}:{kind:"onboard",note:"onboarding cue (empty knowledge)"};let i=V(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,t){let n;try{n=m$1(i=>l$1(i,()=>I(i,o,t)));}catch(i){s(e,o.session_id,`error: ${i}`),process.exit(0);}switch(s(e,o.session_id,n.note),n.kind){case "onboard":h(t.client,f);break;case "cue":h(t.client,E(n.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="claude"){let t=o==="claude"?"prompt-hook":`${o}-prompt-hook`;e.permission_mode==="plan"&&process.exit(0),existsSync(i)||process.exit(0);let n;try{n=m$1(i=>W(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],additionalContext:R(o)}})}
|
|
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};
|