claude-context-auto-handoff 1.0.7 → 1.0.8

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.
@@ -8,7 +8,7 @@
8
8
  "plugins": [
9
9
  {
10
10
  "name": "claude-context-handoff",
11
- "version": "1.0.7",
11
+ "version": "1.0.8",
12
12
  "displayName": "Context Auto-Handoff",
13
13
  "description": "Automatically saves session context and generates handoff manifests before Claude compacts or stops.",
14
14
  "source": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-context-handoff",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Automatically saves session context and generates handoff manifests before Claude compacts or stops.",
5
5
  "author": {
6
6
  "name": "Ethualo",
package/README.ko.md CHANGED
@@ -71,17 +71,22 @@ Claude Code 훅은 기본 내장. Codex 훅은 `templates/.codex`를 프로젝
71
71
  **Linux / macOS**
72
72
  ```bash
73
73
  curl -fsSL https://raw.githubusercontent.com/Ethualo/context-handoff-mcp-server/main/scripts/setup.sh | bash
74
+ # Codex도 함께 설정 (훅 + handoff-drafter 서브에이전트 + AGENTS.md):
75
+ curl -fsSL https://raw.githubusercontent.com/Ethualo/context-handoff-mcp-server/main/scripts/setup.sh | bash -s -- --codex
74
76
  ```
75
77
 
76
78
  **Windows (PowerShell)**
77
79
  ```powershell
78
- irm https://raw.githubusercontent.com/Ethualo/context-handoff-mcp-server/main/scripts/setup.ps1 | iex
80
+ irm https://raw.githubusercontent.com/Ethualo/context-handoff-mcp-server/main/scripts/setup.ps1 -OutFile setup.ps1
81
+ .\setup.ps1 # Claude Code만
82
+ .\setup.ps1 -Codex # Codex도 함께 설정 (훅 + handoff-drafter 서브에이전트 + AGENTS.md)
79
83
  ```
80
84
 
81
85
  **npm (크로스플랫폼)**
82
86
  ```bash
83
87
  npm install -g claude-context-auto-handoff
84
- claude-context-handoff-setup
88
+ claude-context-handoff-setup # Claude Code만
89
+ claude-context-handoff-setup --codex # Codex도 함께 설정
85
90
  ```
86
91
 
87
92
  ---
@@ -98,7 +103,7 @@ claude plugin install claude-context-auto-handoff
98
103
 
99
104
  ```bash
100
105
  npm install -g claude-context-auto-handoff
101
- claude-context-handoff-setup # hooks.json 자동 배치
106
+ claude-context-handoff-setup # hooks.json 자동 배치, --codex 붙이면 Codex도 함께 설정
102
107
  ```
103
108
 
104
109
  ### MCP 수동 설정 (Claude Code)
@@ -126,13 +131,14 @@ command = "node"
126
131
  args = ["/path/to/build/index.js"]
127
132
  ```
128
133
 
129
- 그런 다음 훅 템플릿을 프로젝트 루트에 복사:
134
+ 그런 다음 훅 템플릿과 지시문을 프로젝트 루트에 복사:
130
135
 
131
136
  ```bash
132
137
  cp -r /path/to/claude-context-auto-handoff/templates/.codex ./.codex
138
+ cp /path/to/claude-context-auto-handoff/templates/AGENTS.md ./AGENTS.md
133
139
  ```
134
140
 
135
- Claude Code와 동일한 `SessionStart`, `PreCompact`, `Stop` 훅이 활성화됩니다.
141
+ Claude Code와 동일한 `SessionStart`, `PreCompact`, `Stop` 훅이 활성화되고, 핸드오프 초안 작성+저장을 메인 스레드 밖에서 처리하는 `handoff-drafter` 서브에이전트(`.codex/agents/handoff-drafter.toml`)도 함께 활성화됩니다.
136
142
 
137
143
  ---
138
144
 
@@ -164,7 +170,7 @@ Claude Code와 동일한 `SessionStart`, `PreCompact`, `Stop` 훅이 활성화
164
170
  | 이벤트 | 동작 |
165
171
  |--------|------|
166
172
  | `SessionStart` | `.claude/handoff.md`를 읽어 컨텍스트로 주입 |
167
- | `PreCompact` | 압축 전 handoff-save 스킬(Haiku 서브에이전트) 호출 지시 |
173
+ | `PreCompact` | 압축 전 `handoff-drafter` 서브에이전트에 위임 지시 |
168
174
  | `Stop` | 핸드오프가 오래됐거나 없으면 경고 |
169
175
 
170
176
  ### 출력 형식
package/README.md CHANGED
@@ -71,17 +71,22 @@ Claude Code hooks are built-in. Codex hooks require copying `templates/.codex` t
71
71
  **Linux / macOS**
72
72
  ```bash
73
73
  curl -fsSL https://raw.githubusercontent.com/Ethualo/context-handoff-mcp-server/main/scripts/setup.sh | bash
74
+ # Also set up Codex (hooks + handoff-drafter subagent + AGENTS.md):
75
+ curl -fsSL https://raw.githubusercontent.com/Ethualo/context-handoff-mcp-server/main/scripts/setup.sh | bash -s -- --codex
74
76
  ```
75
77
 
76
78
  **Windows (PowerShell)**
77
79
  ```powershell
78
- irm https://raw.githubusercontent.com/Ethualo/context-handoff-mcp-server/main/scripts/setup.ps1 | iex
80
+ irm https://raw.githubusercontent.com/Ethualo/context-handoff-mcp-server/main/scripts/setup.ps1 -OutFile setup.ps1
81
+ .\setup.ps1 # Claude Code only
82
+ .\setup.ps1 -Codex # also set up Codex (hooks + handoff-drafter subagent + AGENTS.md)
79
83
  ```
80
84
 
81
85
  **npm (cross-platform)**
82
86
  ```bash
83
87
  npm install -g claude-context-auto-handoff
84
- claude-context-handoff-setup
88
+ claude-context-handoff-setup # Claude Code only
89
+ claude-context-handoff-setup --codex # also set up Codex
85
90
  ```
86
91
 
87
92
  ---
@@ -98,7 +103,7 @@ claude plugin install claude-context-auto-handoff
98
103
 
99
104
  ```bash
100
105
  npm install -g claude-context-auto-handoff
101
- claude-context-handoff-setup # hooks.json 자동 배치
106
+ claude-context-handoff-setup # hooks.json 자동 배치, --codex 붙이면 Codex도 함께 설정
102
107
  ```
103
108
 
104
109
  ### Manual MCP configuration (Claude Code)
@@ -126,13 +131,14 @@ command = "node"
126
131
  args = ["/path/to/build/index.js"]
127
132
  ```
128
133
 
129
- Then copy the hook templates to your project root:
134
+ Then copy the hook templates and instructions to your project root:
130
135
 
131
136
  ```bash
132
137
  cp -r /path/to/claude-context-auto-handoff/templates/.codex ./.codex
138
+ cp /path/to/claude-context-auto-handoff/templates/AGENTS.md ./AGENTS.md
133
139
  ```
134
140
 
135
- This enables the same `SessionStart`, `PreCompact`, and `Stop` hooks as Claude Code.
141
+ This enables the same `SessionStart`, `PreCompact`, and `Stop` hooks as Claude Code, plus a `handoff-drafter` subagent (`.codex/agents/handoff-drafter.toml`) that drafts and saves the handoff so it doesn't run in your main thread.
136
142
 
137
143
  ---
138
144
 
@@ -164,7 +170,7 @@ Same three hooks fire automatically via `.codex/hooks.json`. No slash commands
164
170
  | Event | Behavior |
165
171
  |-------|----------|
166
172
  | `SessionStart` | Reads `.claude/handoff.md` and injects content as context |
167
- | `PreCompact` | Prompts Codex to invoke the handoff-save skill (Haiku subagent) before compression |
173
+ | `PreCompact` | Prompts Codex to delegate to the `handoff-drafter` subagent before compression |
168
174
  | `Stop` | Warns if handoff is stale (>5 min) or missing |
169
175
 
170
176
  ### Output format
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-context-auto-handoff",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "A Claude Code plugin to automate session handoffs before context compaction.",
5
5
  "type": "module",
6
6
  "main": "build/index.js",
package/scripts/setup.js CHANGED
@@ -4,9 +4,12 @@ import { fileURLToPath } from 'url';
4
4
  import { dirname, join } from 'path';
5
5
 
6
6
  const __dirname = dirname(fileURLToPath(import.meta.url));
7
+ const withCodex = process.argv.slice(2).includes('--codex');
7
8
 
8
9
  if (process.platform === 'win32') {
9
- execSync(`powershell -ExecutionPolicy Bypass -File "${join(__dirname, 'setup.ps1')}"`, { stdio: 'inherit' });
10
+ const codexFlag = withCodex ? ' -Codex' : '';
11
+ execSync(`powershell -ExecutionPolicy Bypass -File "${join(__dirname, 'setup.ps1')}"${codexFlag}`, { stdio: 'inherit' });
10
12
  } else {
11
- execSync(`bash "${join(__dirname, 'setup.sh')}"`, { stdio: 'inherit' });
13
+ const codexFlag = withCodex ? ' --codex' : '';
14
+ execSync(`bash "${join(__dirname, 'setup.sh')}"${codexFlag}`, { stdio: 'inherit' });
12
15
  }
package/scripts/setup.ps1 CHANGED
@@ -1,5 +1,10 @@
1
1
  # context-handoff-mcp-server -- one-line setup for Windows (PowerShell)
2
2
  # Usage: irm https://raw.githubusercontent.com/Ethualo/context-handoff-mcp-server/main/scripts/setup.ps1 | iex
3
+ # Codex support: run the downloaded file with -Codex, e.g. .\setup.ps1 -Codex
4
+
5
+ param(
6
+ [switch]$Codex
7
+ )
3
8
 
4
9
  $ErrorActionPreference = "Stop"
5
10
 
@@ -11,9 +16,11 @@ Write-Host "[Handoff Setup] Installing $PluginName..."
11
16
  # 1. npm global install (builds TypeScript)
12
17
  npm install -g claude-context-auto-handoff
13
18
 
14
- # 2. Register hooks.json (warn if already exists)
15
19
  $NpmRoot = (npm root -g).Trim()
16
- $HooksSrc = Join-Path $NpmRoot "claude-context-auto-handoff\hooks\hooks.json"
20
+ $PkgRoot = Join-Path $NpmRoot "claude-context-auto-handoff"
21
+
22
+ # 2. Register hooks.json (warn if already exists)
23
+ $HooksSrc = Join-Path $PkgRoot "hooks\hooks.json"
17
24
 
18
25
  if (Test-Path $HooksTarget) {
19
26
  Write-Host "[Handoff Setup] WARNING: $HooksTarget already exists."
@@ -25,6 +32,47 @@ if (Test-Path $HooksTarget) {
25
32
  Write-Host "[Handoff Setup] hooks.json registered: $HooksTarget"
26
33
  }
27
34
 
35
+ if ($Codex) {
36
+ Write-Host ""
37
+ Write-Host "[Handoff Setup] Configuring Codex..."
38
+
39
+ # 3. Register MCP server in ~/.codex/config.toml (warn if entry already exists)
40
+ $CodexConfig = "$env:USERPROFILE\.codex\config.toml"
41
+ $ServerBin = Join-Path $PkgRoot "build\index.js"
42
+ $CodexConfigDir = Split-Path $CodexConfig
43
+ if (-not (Test-Path $CodexConfigDir)) { New-Item -ItemType Directory -Force $CodexConfigDir | Out-Null }
44
+ if (-not (Test-Path $CodexConfig)) { New-Item -ItemType File -Path $CodexConfig | Out-Null }
45
+
46
+ $existingConfig = Get-Content $CodexConfig -Raw -ErrorAction SilentlyContinue
47
+ if ($existingConfig -and $existingConfig.Contains("mcp_servers.context-handoff")) {
48
+ Write-Host "[Handoff Setup] WARNING: [mcp_servers.context-handoff] already present in $CodexConfig — skipping."
49
+ } else {
50
+ $TomlBlock = @"
51
+
52
+ [mcp_servers.context-handoff]
53
+ command = "node"
54
+ args = ["$($ServerBin.Replace('\','\\'))"]
55
+ "@
56
+ Add-Content -Path $CodexConfig -Value $TomlBlock
57
+ Write-Host "[Handoff Setup] MCP server registered: $CodexConfig"
58
+ }
59
+
60
+ # 4. Copy .codex hooks + agents + AGENTS.md into the current project (warn if already present)
61
+ if (Test-Path ".\.codex") {
62
+ Write-Host "[Handoff Setup] WARNING: .\.codex already exists — not overwritten. Reference: $PkgRoot\templates\.codex"
63
+ } else {
64
+ Copy-Item (Join-Path $PkgRoot "templates\.codex") ".\.codex" -Recurse
65
+ Write-Host "[Handoff Setup] Codex hooks + handoff-drafter subagent copied: .\.codex"
66
+ }
67
+
68
+ if (Test-Path ".\AGENTS.md") {
69
+ Write-Host "[Handoff Setup] WARNING: .\AGENTS.md already exists — not overwritten. Reference: $PkgRoot\templates\AGENTS.md"
70
+ } else {
71
+ Copy-Item (Join-Path $PkgRoot "templates\AGENTS.md") ".\AGENTS.md"
72
+ Write-Host "[Handoff Setup] AGENTS.md copied: .\AGENTS.md"
73
+ }
74
+ }
75
+
28
76
  Write-Host ""
29
77
  Write-Host "[Handoff Setup] Done!"
30
78
  Write-Host ""
package/scripts/setup.sh CHANGED
@@ -1,19 +1,29 @@
1
1
  #!/usr/bin/env bash
2
2
  # context-handoff-mcp-server -- one-line setup for Linux/macOS
3
3
  # Usage: curl -fsSL https://raw.githubusercontent.com/Ethualo/context-handoff-mcp-server/main/scripts/setup.sh | bash
4
+ # Codex support: ... | bash -s -- --codex
4
5
 
5
6
  set -e
6
7
 
7
8
  PLUGIN_NAME="claude-context-handoff"
8
9
  HOOKS_TARGET="$HOME/.claude/hooks.json"
10
+ WITH_CODEX=false
11
+
12
+ for arg in "$@"; do
13
+ case "$arg" in
14
+ --codex) WITH_CODEX=true ;;
15
+ esac
16
+ done
9
17
 
10
18
  echo "[Handoff Setup] Installing $PLUGIN_NAME..."
11
19
 
12
20
  # 1. npm global install (builds TypeScript)
13
21
  npm install -g claude-context-auto-handoff
14
22
 
23
+ PKG_ROOT="$(npm root -g)/claude-context-auto-handoff"
24
+
15
25
  # 2. Register hooks.json (warn if already exists)
16
- HOOKS_SRC="$(npm root -g)/claude-context-auto-handoff/hooks/hooks.json"
26
+ HOOKS_SRC="$PKG_ROOT/hooks/hooks.json"
17
27
 
18
28
  if [ -f "$HOOKS_TARGET" ]; then
19
29
  echo "[Handoff Setup] WARNING: $HOOKS_TARGET already exists."
@@ -24,6 +34,44 @@ else
24
34
  echo "[Handoff Setup] hooks.json registered: $HOOKS_TARGET"
25
35
  fi
26
36
 
37
+ if [ "$WITH_CODEX" = true ]; then
38
+ echo ""
39
+ echo "[Handoff Setup] Configuring Codex..."
40
+
41
+ # 3. Register MCP server in ~/.codex/config.toml (warn if entry already exists)
42
+ CODEX_CONFIG="$HOME/.codex/config.toml"
43
+ SERVER_BIN="$PKG_ROOT/build/index.js"
44
+ mkdir -p "$(dirname "$CODEX_CONFIG")"
45
+ touch "$CODEX_CONFIG"
46
+
47
+ if grep -q "mcp_servers.context-handoff" "$CODEX_CONFIG" 2>/dev/null; then
48
+ echo "[Handoff Setup] WARNING: [mcp_servers.context-handoff] already present in $CODEX_CONFIG — skipping."
49
+ else
50
+ {
51
+ echo ""
52
+ echo "[mcp_servers.context-handoff]"
53
+ echo "command = \"node\""
54
+ echo "args = [\"$SERVER_BIN\"]"
55
+ } >> "$CODEX_CONFIG"
56
+ echo "[Handoff Setup] MCP server registered: $CODEX_CONFIG"
57
+ fi
58
+
59
+ # 4. Copy .codex hooks + agents + AGENTS.md into the current project (warn if already present)
60
+ if [ -d "./.codex" ]; then
61
+ echo "[Handoff Setup] WARNING: ./.codex already exists — not overwritten. Reference: $PKG_ROOT/templates/.codex"
62
+ else
63
+ cp -r "$PKG_ROOT/templates/.codex" ./.codex
64
+ echo "[Handoff Setup] Codex hooks + handoff-drafter subagent copied: ./.codex"
65
+ fi
66
+
67
+ if [ -f "./AGENTS.md" ]; then
68
+ echo "[Handoff Setup] WARNING: ./AGENTS.md already exists — not overwritten. Reference: $PKG_ROOT/templates/AGENTS.md"
69
+ else
70
+ cp "$PKG_ROOT/templates/AGENTS.md" ./AGENTS.md
71
+ echo "[Handoff Setup] AGENTS.md copied: ./AGENTS.md"
72
+ fi
73
+ fi
74
+
27
75
  echo ""
28
76
  echo "[Handoff Setup] Done!"
29
77
  echo ""
@@ -0,0 +1,17 @@
1
+ name = "handoff-drafter"
2
+ description = "Drafts and saves a session handoff via generate_handoff_manifest. Use before context compaction, or when a session with meaningful work is ending."
3
+ developer_instructions = """
4
+ Draft the handoff fields from the parent session's context, following the Content Generation Rules in AGENTS.md (telegraphese — drop articles/pronouns/filler; WHY over WHAT; no code snippets, path + delta notes only; failedApproaches as "Approach: X -> Result: Y -> Lesson: Z").
5
+
6
+ Then call generate_handoff_manifest yourself with:
7
+ - summary, nextSteps (required)
8
+ - taskDescription, currentStatus, keyDecisions, failedApproaches, modifiedFiles, implicitRules (recommended)
9
+ - blockers (optional)
10
+ - workingDirectory: absolute path to the project root (passed to you by the caller) — always set this explicitly, never rely on the tool's cwd fallback.
11
+
12
+ Report back only a short confirmation: the saved paths (.claude/handoff.md and the archive path). Do not return the drafted field content to the caller.
13
+ """
14
+
15
+ # Optional: pin to a lighter/cheaper model to cut cost on this drafting task,
16
+ # e.g. model = "gpt-5.3-codex-spark". Omitted here so it inherits the parent
17
+ # session's model/sandbox settings by default.
@@ -19,7 +19,7 @@
19
19
  "hooks": [
20
20
  {
21
21
  "type": "command",
22
- "command": "node -e \"console.log('CRITICAL: Context is about to be compressed. You MUST invoke the handoff-save skill NOW (it delegates drafting + calling generate_handoff_manifest to a cheap subagent — do not draft the fields or call the tool yourself) with a complete session summary before this happens. Include: summary, nextSteps, taskDescription, currentStatus, keyDecisions, failedApproaches, modifiedFiles, implicitRules. Do not skip this step.')\"",
22
+ "command": "node -e \"console.log('CRITICAL: Context is about to be compressed. Delegate to the handoff-drafter subagent NOW per AGENTS.md (pass it this project absolute root path) before this happens. Do not skip this step.')\"",
23
23
  "timeout": 5,
24
24
  "statusMessage": "Saving handoff before compaction"
25
25
  }
@@ -32,7 +32,7 @@
32
32
  "hooks": [
33
33
  {
34
34
  "type": "command",
35
- "command": "node -e \"const fs=require('fs'),path=require('path');const f=path.join(process.cwd(),'.claude','handoff.md');if(!fs.existsSync(f)){console.log('No handoff file found. If this session had meaningful work, invoke the handoff-save skill before ending (it delegates to a cheap subagent).')}else{const age=(Date.now()-fs.statSync(f).mtimeMs)/1000;if(age>300){console.log('HANDOFF STALE (last saved '+Math.round(age/60)+' min ago). Invoke the handoff-save skill to update session context.')}}\"",
35
+ "command": "node -e \"const fs=require('fs'),path=require('path');const f=path.join(process.cwd(),'.claude','handoff.md');if(!fs.existsSync(f)){console.log('No handoff file found. If this session had meaningful work, delegate to the handoff-drafter subagent per AGENTS.md before ending.')}else{const age=(Date.now()-fs.statSync(f).mtimeMs)/1000;if(age>300){console.log('HANDOFF STALE (last saved '+Math.round(age/60)+' min ago). Delegate to the handoff-drafter subagent per AGENTS.md to update session context.')}}\"",
36
36
  "timeout": 5,
37
37
  "statusMessage": "Checking handoff status"
38
38
  }
@@ -10,7 +10,9 @@ If the file does not exist, proceed normally.
10
10
 
11
11
  ## Session End / Before Context Grows Large
12
12
 
13
- Before ending the session or when the conversation is getting long, call `generate_handoff_manifest` with the following fields:
13
+ Before ending the session or when the conversation is getting long, delegate to the `handoff-drafter` subagent (`.codex/agents/handoff-drafter.toml`) rather than drafting the fields or calling the tool yourself — it can run on a lighter model and keeps the drafted content out of this thread. Pass it the project's absolute root path so it can set `workingDirectory` correctly (it runs with its own cwd).
14
+
15
+ If the `handoff-drafter` subagent is unavailable, fall back to calling `generate_handoff_manifest` directly with these fields:
14
16
 
15
17
  | Field | Required | Format |
16
18
  |-------|----------|--------|
@@ -23,6 +25,7 @@ Before ending the session or when the conversation is getting long, call `genera
23
25
  | `modifiedFiles` | recommended | `"path/to/file: what changed"` — NO code snippets |
24
26
  | `implicitRules` | recommended | Tech stack, naming conventions, env vars |
25
27
  | `blockers` | optional | Unresolved errors or open questions |
28
+ | `workingDirectory` | recommended | Absolute path to this project's root. Pass it explicitly — do not rely on the tool's cwd fallback. |
26
29
 
27
30
  Output is saved to `.claude/handoff.md` (latest) and `.claude/handoffs/handoff-{timestamp}.md` (archive).
28
31