| … | … | @@ -31,6 +31,16 @@ function classifyProject (cwd) { |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | function main () { |
| 34 | // Only inject on first prompt of session — check if briefing already delivered |
| 35 | const BRIEFING_FLAG = '/tmp/claude-briefing-delivered.flag' |
| 36 | if (fs.existsSync(BRIEFING_FLAG)) { |
| 37 | // Check if flag is from current session (less than 1 hour old) |
| 38 | try { |
| 39 | const age = Date.now() - fs.statSync(BRIEFING_FLAG).mtimeMs |
| 40 | if (age < 3600000) return // already briefed this session |
| 41 | } catch {} |
| 42 | } |
| 43 | |
| 34 | 44 | const cwd = process.cwd() |
| 35 | 45 | const project = classifyProject(cwd) |
| 36 | 46 | if (!project) return // not a known project — no briefing needed |
| … | … | @@ -125,7 +135,12 @@ function main () { |
| 125 | 135 | lines.push('═'.repeat(50)) |
| 126 | 136 | lines.push('') |
| 127 | 137 | |
| 128 | | process.stderr.write(lines.join('\n')) |
| 138 | // Mark as delivered so we don't repeat |
| 139 | fs.writeFileSync(BRIEFING_FLAG, new Date().toISOString()) |
| 140 | |
| 141 | // Output as additionalContext JSON — Claude sees this as system context |
| 142 | const output = { additionalContext: lines.join('\n') } |
| 143 | process.stdout.write(JSON.stringify(output)) |
| 129 | 144 | } |
| 130 | 145 | |
| 131 | 146 | main() |