|
1 | 1 | // Academic Writer Hooks - lifecycle bundle |
2 | | -// Generated: 2026-05-29T07:45:34.152Z |
| 2 | +// Generated: 2026-06-03T06:46:46.844Z |
3 | 3 |
|
4 | 4 | import{execFile as _}from"node:child_process";import{existsSync as C}from"node:fs";import{join as v}from"node:path";function S(s){let e=s.project_dir??process.env.CLAUDE_PROJECT_DIR??".";return C(v(e,".academic-helper","profile.md"))?process.platform!=="darwin"?{continue:!0,suppressOutput:!0}:(_("osascript",["-e",'display notification "Task complete" with title "Academic Writer" sound name "Glass"'],{timeout:2e3},()=>{}),{continue:!0,suppressOutput:!0}):{continue:!0,suppressOutput:!0}}import{existsSync as m,readdirSync as E}from"node:fs";import{join as h}from"node:path";import{existsSync as A,readFileSync as H}from"node:fs";import{join as L}from"node:path";var $=".academic-helper/profile.md";function d(s){return L(s,$)}function F(s){try{let e={},r=s.match(/^---\n([\s\S]*?)\n---/);if(r){let i=r[1].split(` |
5 | | -`),o=0;for(;o<i.length;){let u=i[o],c=u.match(/^([\w-]+): (.+)$/);if(c){let[,l,f]=c,a=f.trim();a==="null"?e[l]=null:a==="[]"?e[l]=[]:e[l]=a,o++}else if(/^[\w-]+:\s*$/.test(u)){let l=u.split(":")[0],f=[];for(o++;o<i.length&&i[o].startsWith(" - ");)f.push(i[o].slice(4)),o++;e[l]=f}else o++}}let t=/^## ([^\n]+)\n+```json\n([\s\S]*?)\n```/gm,n;for(;(n=t.exec(s))!==null;){let i=n[1].trim().toLowerCase().replace(/\s+/g,"");try{let o=JSON.parse(n[2]);switch(i){case"tools":e.tools=o;break;case"stylefingerprint":e.styleFingerprint=o;break;case"sources":e.sources=o;break;case"articlestructure":e.articleStructure=o;break;case"outputformatpreferences":e.outputFormatPreferences=o;break}}catch{}}return e}catch{return null}}function k(s){let e=d(s);if(!A(e))return null;try{let r=H(e,"utf-8");return F(r)}catch{return null}}function R(s){let e=s.project_dir??process.env.CLAUDE_PROJECT_DIR??".",r=k(e);if(!r)return{continue:!0,suppressOutput:!0};let t=[];t.push(""),t.push("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"),t.push("\u2551 ACADEMIC WRITER \u2014 SESSION START \u2551"),t.push("\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563"),t.push(`\u2551 Field: ${(r.fieldOfStudy??"Not set").padEnd(38)}\u2551`),t.push(`\u2551 Language: ${(r.targetLanguage??"Not set").padEnd(36)}\u2551`),t.push(`\u2551 Citation: ${(r.citationStyle??"Not set").padEnd(36)}\u2551`),t.push(`\u2551 Fingerprint: ${(r.styleFingerprint?"Loaded":"Missing").padEnd(33)}\u2551`);let n=h(e,"articles"),i=0;if(m(n))try{i=E(n).filter(p=>p.endsWith(".docx")).length}catch{}t.push(`\u2551 Articles: ${String(i).padEnd(36)}\u2551`);let o=r.sources?.length??0;t.push(`\u2551 Sources indexed: ${String(o).padEnd(29)}\u2551`);let u=r.tools??{},c=[];for(let[a,p]of Object.entries(u))p&&typeof p=="object"&&"enabled"in p&&p.enabled&&c.push(a);t.push(`\u2551 Tools: ${(c.length>0?c.join(", "):"None").substring(0,38).padEnd(38)}\u2551`);let l=h(e,".academic-helper","research-brief.md");m(l)&&t.push("\u2551 Research brief: Available \u2551");let f=h(e,"past-articles");if(m(f))try{let a=E(f),p=r.analyzedArticles?.length??0,g=a.filter(y=>y.endsWith(".pdf")||y.endsWith(".docx")).length-p;g>0&&(t.push(`\u2551 New past articles: ${String(g).padEnd(27)}\u2551`),t.push("\u2551 \u2192 Run /academic-writer:voice to update style \u2551"))}catch{}return t.push("\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563"),t.push("\u2551 /academic-writer:write \u2014 Write new article \u2551"),t.push("\u2551 /academic-writer:ideate \u2014 Brainstorm ideas \u2551"),t.push("\u2551 /academic-writer:research \u2014 Investigate a topic \u2551"),t.push("\u2551 /academic-writer:health \u2014 Check integrations \u2551"),t.push("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"),{continue:!0,systemMessage:t.join(` |
6 | | -`)}}import{existsSync as I,appendFileSync as N}from"node:fs";import{join as O}from"node:path";function b(s){let e=s.project_dir??process.env.CLAUDE_PROJECT_DIR??".";if(!I(d(e)))return{continue:!0,suppressOutput:!0};let r=O(e,".academic-helper","logs");if(!I(r))return{continue:!0,suppressOutput:!0};try{let t=new Date,n=t.toISOString().split("T")[0],i=t.toISOString().split("T")[1].split(".")[0],o=O(r,`${n}.log`),u=s.session_id??"unknown",c=["",`--- Session End: ${i} (${u}) ---`,`Timestamp: ${t.toISOString()}`,"---",""].join(` |
7 | | -`);N(o,c,"utf-8")}catch{}return{continue:!0,suppressOutput:!0}}import{existsSync as w,readFileSync as U}from"node:fs";import{join as D}from"node:path";function j(s){let e=s.project_dir??process.env.CLAUDE_PROJECT_DIR??".";if(!w(D(e,".academic-helper","profile.md")))return{continue:!0,suppressOutput:!0};let r=s.subagent_type??s.subagentType??"";if(r!=="auditor"&&r!=="academic-writer:auditor")return{continue:!0,suppressOutput:!0};let t=s.plugin_root??process.env.CLAUDE_PLUGIN_ROOT,n="";if(t){let o=D(t,"thresholds.json");if(w(o))try{let u=U(o,"utf-8"),c=JSON.parse(u);n=` |
| 5 | +`),o=0;for(;o<i.length;){let a=i[o],c=a.match(/^([\w-]+): (.+)$/);if(c){let[,l,f]=c,u=f.trim();u==="null"?e[l]=null:u==="[]"?e[l]=[]:e[l]=u,o++}else if(/^[\w-]+:\s*$/.test(a)){let l=a.split(":")[0],f=[];for(o++;o<i.length&&i[o].startsWith(" - ");)f.push(i[o].slice(4)),o++;e[l]=f}else o++}}let t=/^## ([^\n]+)\n+```json\n([\s\S]*?)\n```/gm,n;for(;(n=t.exec(s))!==null;){let i=n[1].trim().toLowerCase().replace(/\s+/g,"");try{let o=JSON.parse(n[2]);switch(i){case"tools":e.tools=o;break;case"stylefingerprint":e.styleFingerprint=o;break;case"sources":e.sources=o;break;case"articlestructure":e.articleStructure=o;break;case"outputformatpreferences":e.outputFormatPreferences=o;break}}catch{}}return e}catch{return null}}function k(s){let e=d(s);if(!A(e))return null;try{let r=H(e,"utf-8");return F(r)}catch{return null}}function R(s){let e=s.project_dir??process.env.CLAUDE_PROJECT_DIR??".",r=k(e);if(!r)return{continue:!0,suppressOutput:!0};let t=[];t.push(""),t.push("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"),t.push("\u2551 ACADEMIC WRITER \u2014 SESSION START \u2551"),t.push("\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563"),t.push(`\u2551 Field: ${(r.fieldOfStudy??"Not set").padEnd(38)}\u2551`),t.push(`\u2551 Language: ${(r.targetLanguage??"Not set").padEnd(36)}\u2551`),t.push(`\u2551 Citation: ${(r.citationStyle??"Not set").padEnd(36)}\u2551`),t.push(`\u2551 Fingerprint: ${(r.styleFingerprint?"Loaded":"Missing").padEnd(33)}\u2551`);let n=h(e,"articles"),i=0;if(m(n))try{i=E(n).filter(p=>p.endsWith(".docx")).length}catch{}t.push(`\u2551 Articles: ${String(i).padEnd(36)}\u2551`);let o=r.sources?.length??0;t.push(`\u2551 Sources indexed: ${String(o).padEnd(29)}\u2551`);let a=r.tools??{},c=[];for(let[u,p]of Object.entries(a))p&&typeof p=="object"&&"enabled"in p&&p.enabled&&c.push(u);t.push(`\u2551 Tools: ${(c.length>0?c.join(", "):"None").substring(0,38).padEnd(38)}\u2551`);let l=h(e,".academic-helper","research-brief.md");m(l)&&t.push("\u2551 Research brief: Available \u2551");let f=h(e,"past-articles");if(m(f))try{let u=E(f),p=r.analyzedArticles?.length??0,g=u.filter(y=>y.endsWith(".pdf")||y.endsWith(".docx")).length-p;g>0&&(t.push(`\u2551 New past articles: ${String(g).padEnd(27)}\u2551`),t.push("\u2551 \u2192 Run /academic-writer:voice to update style \u2551"))}catch{}return t.push("\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563"),t.push("\u2551 /academic-writer:write \u2014 Write new article \u2551"),t.push("\u2551 /academic-writer:ideate \u2014 Brainstorm ideas \u2551"),t.push("\u2551 /academic-writer:research \u2014 Investigate a topic \u2551"),t.push("\u2551 /academic-writer:health \u2014 Check integrations \u2551"),t.push("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"),{continue:!0,systemMessage:t.join(` |
| 6 | +`)}}import{existsSync as I,appendFileSync as N}from"node:fs";import{join as b}from"node:path";function w(s){let e=s.project_dir??process.env.CLAUDE_PROJECT_DIR??".";if(!I(d(e)))return{continue:!0,suppressOutput:!0};let r=b(e,".academic-helper","logs");if(!I(r))return{continue:!0,suppressOutput:!0};try{let t=new Date,n=t.toISOString().split("T")[0],i=t.toISOString().split("T")[1].split(".")[0],o=b(r,`${n}.log`),a=s.session_id??"unknown",c=["",`--- Session End: ${i} (${a}) ---`,`Timestamp: ${t.toISOString()}`,"---",""].join(` |
| 7 | +`);N(o,c,"utf-8")}catch{}return{continue:!0,suppressOutput:!0}}import{existsSync as O,readFileSync as U}from"node:fs";import{join as D}from"node:path";function j(s){let e=s.project_dir??process.env.CLAUDE_PROJECT_DIR??".";if(!O(D(e,".academic-helper","profile.md")))return{continue:!0,suppressOutput:!0};let r=s.subagent_type??s.subagentType??"";if(r!=="auditor"&&r!=="academic-writer:auditor")return{continue:!0,suppressOutput:!0};let t=s.plugin_root??process.env.CLAUDE_PLUGIN_ROOT,n="";if(t){let o=D(t,"thresholds.json");if(O(o))try{let a=U(o,"utf-8"),c=JSON.parse(a);n=` |
8 | 8 | Current thresholds: anti-AI ${c.antiAi?.passThreshold}/${c.antiAi?.maxScore}, max rewrite cycles ${c.rewriteCycles?.max}.`}catch{}}return{continue:!0,hookSpecificOutput:{hookEventName:"SubagentStart",additionalContext:["AUDITOR CONTEXT (injected by SubagentStart hook):","- Verify every citation against the canonical sources.json registry.","- A citation passes only when title, author, year, and page all match.","- Mark [NEEDS REVIEW: <field>] when a field is missing or low-confidence.","- Use WebSearch for external verification only when the registry has no entry.","- Validate WebSearch results: title (exact), author, year (\xB11), page range \u2014 anything weaker = [NEEDS REVIEW: external_verification].","- Final output must be a single VERDICT line: PASS or FAIL with reasons.",n].filter(Boolean).join(` |
9 | | -`)}}}import{existsSync as x}from"node:fs";import{spawnSync as W}from"node:child_process";import{join as P}from"node:path";function T(s){let e=s.project_dir??process.env.CLAUDE_PROJECT_DIR??process.cwd();if(!x(P(e,".academic-helper","profile.md")))return{continue:!0,suppressOutput:!0};let r=s.plugin_root??process.env.CLAUDE_PLUGIN_ROOT;if(!r)return{continue:!0,suppressOutput:!0};let t=P(r,"skills","voice","voice-sync.sh");if(!x(t))return{continue:!0,suppressOutput:!0};let n=W("bash",[t,"pull"],{cwd:e,env:{...process.env,VOICE_PROJECT_ROOT:e},encoding:"utf-8"});return n.status!==0&&console.warn(`[voice-pull] non-fatal: ${n.stderr}`),{continue:!0,suppressOutput:!0}}var yt={"lifecycle/notify-stop":S,"lifecycle/session-dashboard":R,"lifecycle/session-end-log":b,"lifecycle/subagent-start":j,"lifecycle/voice-pull":T};export{yt as hooks}; |
| 9 | +`)}}}import{existsSync as x}from"node:fs";import{spawnSync as W}from"node:child_process";import{join as P}from"node:path";function T(s){let e=s.project_dir??process.env.CLAUDE_PROJECT_DIR??process.cwd();if(!x(P(e,".academic-helper","profile.md")))return{continue:!0,suppressOutput:!0};let r=s.plugin_root??process.env.CLAUDE_PLUGIN_ROOT??"",t=P(r,"skills","voice","voice-sync.sh");if(!x(t))return{continue:!0,suppressOutput:!0};let n=W("bash",[t,"pull"],{cwd:e,env:{...process.env,VOICE_PROJECT_ROOT:e},encoding:"utf-8"});return n.status!==0&&console.warn(`[voice-pull] non-fatal: ${n.stderr}`),{continue:!0,suppressOutput:!0}}var yt={"lifecycle/notify-stop":S,"lifecycle/session-dashboard":R,"lifecycle/session-end-log":w,"lifecycle/subagent-start":j,"lifecycle/voice-pull":T};export{yt as hooks}; |
10 | 10 | //# sourceMappingURL=lifecycle.mjs.map |
0 commit comments