viepilot 3.8.0 → 3.9.1

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/CHANGELOG.md CHANGED
@@ -9,6 +9,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ---
11
11
 
12
+ ## [3.9.1] - 2026-05-25
13
+
14
+ ### Fixed
15
+ - BUG-031: `vp-tools hooks install` wrote wrong hook path (`~/.viepilot/hooks/
16
+ brainstorm-staleness.cjs`) which does not exist; corrected to
17
+ `{adapter.viepilotDir}/lib/hooks/brainstorm-staleness.cjs`; Stop hook no longer
18
+ exits non-zero each turn
19
+ - BUG-031: `vp-tools hooks install` (re-run) now detects and removes stale wrong-path
20
+ entries from settings.json before writing the correct entry
21
+
22
+ ---
23
+
24
+ ## [3.9.0] - 2026-05-24
25
+
26
+ ### Changed
27
+ - ENH-099: skills/vp-auto/SKILL.md — Claude Code adapter tool section expanded with 8 new
28
+ tools: Monitor, CronCreate/Delete/List, EnterWorktree/ExitWorktree, LSP, PushNotification,
29
+ EnterPlanMode/ExitPlanMode (sourced from official tools-reference, May 2026)
30
+ - ENH-099: workflows/autonomous.md — TodoWrite deprecated references replaced with
31
+ TaskCreate/TaskList (disabled since Claude Code v2.1.142); Monitor quality-gate pattern
32
+ and PushNotification phase-complete notification added
33
+ - ENH-099: docs/dev/agents.md — full 28-event hooks inventory table added; Agent Teams
34
+ experimental section (TeamCreate, TeamDelete, SendMessage) documented
35
+
36
+ ---
37
+
12
38
  ## [3.8.0] - 2026-05-24
13
39
 
14
40
  ### Added
package/bin/vp-tools.cjs CHANGED
@@ -1007,7 +1007,7 @@ ${colors.cyan}Examples:${colors.reset}
1007
1007
  matcher: {},
1008
1008
  hooks: [{
1009
1009
  type: 'command',
1010
- command: `node ${path.join(home, '.viepilot', 'hooks', 'brainstorm-staleness.cjs')}`
1010
+ command: `node ${path.join(adapter.viepilotDir(home), 'lib', 'hooks', 'brainstorm-staleness.cjs')}`
1011
1011
  }]
1012
1012
  }]
1013
1013
  }
@@ -1024,7 +1024,7 @@ ${colors.cyan}Examples:${colors.reset}
1024
1024
  }
1025
1025
  const home = os.homedir();
1026
1026
  const configPath = adapter.hooks.configFile(home);
1027
- const hookCommand = `node ${path.join(home, '.viepilot', 'hooks', 'brainstorm-staleness.cjs')}`;
1027
+ const hookCommand = `node ${path.join(adapter.viepilotDir(home), 'lib', 'hooks', 'brainstorm-staleness.cjs')}`;
1028
1028
 
1029
1029
  // Read existing settings.json (create if missing)
1030
1030
  let settings = {};
@@ -1032,15 +1032,22 @@ ${colors.cyan}Examples:${colors.reset}
1032
1032
  try { settings = JSON.parse(fs.readFileSync(configPath, 'utf8')); } catch (_e) { settings = {}; }
1033
1033
  }
1034
1034
 
1035
- // Merge hook entry — idempotent check
1035
+ // Merge hook entry — migration + idempotent check
1036
1036
  if (!settings.hooks) settings.hooks = {};
1037
1037
  if (!settings.hooks.Stop) settings.hooks.Stop = [];
1038
1038
 
1039
+ // Step A: remove any stale entry with the OLD wrong path
1040
+ const wrongPath = `node ${path.join(home, '.viepilot', 'hooks', 'brainstorm-staleness.cjs')}`;
1041
+ settings.hooks.Stop = settings.hooks.Stop.filter((entry) =>
1042
+ !(Array.isArray(entry.hooks) &&
1043
+ entry.hooks.some((h) => h.type === 'command' && h.command === wrongPath))
1044
+ );
1045
+
1046
+ // Step B: idempotent check for correct path
1039
1047
  const alreadyInstalled = settings.hooks.Stop.some((entry) =>
1040
1048
  Array.isArray(entry.hooks) &&
1041
1049
  entry.hooks.some((h) => h.type === 'command' && h.command === hookCommand)
1042
1050
  );
1043
-
1044
1051
  if (alreadyInstalled) {
1045
1052
  console.log(formatSuccess('ViePilot staleness hook already installed.'));
1046
1053
  console.log(` Config: ${configPath}`);
@@ -139,3 +139,85 @@ describes the exact steps — follow them as a scoped sub-prompt.
139
139
  - File: `agents/{name}-agent.md` (kebab-case, always ends in `-agent`)
140
140
  - Reference: `{name}-agent` (e.g., `tracker-agent`, not `tracker`)
141
141
  - Invocation: `Load agents/{name}-agent.md for full spec.`
142
+
143
+ ## Hook Events Reference (ENH-099)
144
+
145
+ Complete list of 28 hook events supported in Claude Code (as of May 2026).
146
+ Source: [code.claude.com/docs/en/hooks](https://code.claude.com/docs/en/hooks)
147
+
148
+ | Hook | Fires When | Blocking | Key ViePilot Use |
149
+ |------|-----------|---------|-----------------|
150
+ | `SessionStart` | Session begins/resumes | No | Inject context, set env, watch paths |
151
+ | `SessionEnd` | Session terminates | No | Cleanup, logging |
152
+ | `UserPromptSubmit` | User submits prompt | Yes | Block/augment prompts; set session title |
153
+ | `UserPromptExpansion` | Slash command expands | Yes | Audit `/vp-*` invocations |
154
+ | `PreToolUse` | Before any tool executes | Yes | Block destructive commands, log ops |
155
+ | `PostToolUse` | After tool succeeds | No | Validate output, add context |
156
+ | `PostToolUseFailure` | After tool fails | No | Log failures |
157
+ | `PostToolBatch` | After parallel tools resolve | Yes | Validate parallel fan-out batch results |
158
+ | `PermissionRequest` | Permission dialog appears | Yes | Auto-approve known safe patterns |
159
+ | `PermissionDenied` | Tool call denied | No | Signal retry allowed |
160
+ | `Stop` | Claude finishes responding | Yes | Continue autonomous loop without re-prompt |
161
+ | `StopFailure` | Turn ends due to API error | No | Error logging |
162
+ | `Notification` | Claude Code sends notification | No | Desktop notification / terminal bell |
163
+ | `SubagentStart` | Subagent spawned | No | Log agent start, inject context |
164
+ | `SubagentStop` | Subagent finishes | Yes | Block premature stop, collect output |
165
+ | `TaskCreated` | TaskCreate tool used | Yes | Enforce naming conventions |
166
+ | `TaskCompleted` | Task marked complete | Yes | Trigger quality gate automatically |
167
+ | `TeammateIdle` | Agent team teammate idle | Yes | Keep agent alive / assign next task |
168
+ | `CwdChanged` | Working directory changes | No | Reactive env setup (direnv) |
169
+ | `FileChanged` | Watched file changes | No | React to test/code file saves |
170
+ | `ConfigChange` | Config file changes | Yes | Block unexpected config changes |
171
+ | `WorktreeCreate` | Worktree being created | Yes | Custom worktree setup |
172
+ | `WorktreeRemove` | Worktree being removed | No | Cleanup |
173
+ | `PreCompact` | Before context compaction | Yes | Block compaction during critical phase steps |
174
+ | `PostCompact` | After compaction completes | No | Re-inject phase context |
175
+ | `Setup` | `--init-only` / `-p --init` | No | One-time dependency installation |
176
+ | `InstructionsLoaded` | CLAUDE.md / rules loaded | No | Audit logging |
177
+ | `Elicitation` | MCP server requests user input | Yes | Auto-respond to MCP prompts |
178
+
179
+ ### Exit code behavior
180
+ - **Exit 0**: success; JSON output processed
181
+ - **Exit 2**: blocking error; stderr shown, event blocked
182
+ - **Other non-zero**: non-blocking; first line of stderr shown
183
+
184
+ ### Most impactful hooks for ViePilot autonomous runs
185
+ - `TaskCreated` + `TaskCompleted` → hook-driven quality gates (no manual trigger needed)
186
+ - `PreCompact` + `PostCompact` → protect long phases from mid-run context loss
187
+ - `SubagentStart` + `SubagentStop` → trace agent orchestration
188
+ - `Stop` → enables fully autonomous `/vp-auto` without re-prompting
189
+ - `PostToolBatch` → validate parallel fan-out results (ENH-096/097 pattern)
190
+
191
+ ## Agent Teams (Experimental)
192
+
193
+ Agent Teams allow multiple Claude Code sessions to communicate via message passing.
194
+ Requires: `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1` environment variable.
195
+
196
+ ### Tools
197
+
198
+ | Tool | Description |
199
+ |------|-------------|
200
+ | `TeamCreate` | Create a named team with multiple teammate sessions |
201
+ | `TeamDelete` | Disband team and clean up all teammate processes |
202
+ | `SendMessage` | Send a message to a teammate by name, or resume a stopped subagent |
203
+
204
+ ### Architecture
205
+
206
+ ```
207
+ TeamCreate → defines lead + teammates
208
+ TeamLead → assigns tasks via SendMessage
209
+ Teammates → work independently, respond via SendMessage back to lead
210
+ TeamDelete → cleanup after all work complete
211
+ ```
212
+
213
+ ### ViePilot roadmap
214
+
215
+ Agent Teams represent a future upgrade path for the vp-auto orchestration model (ENH-096/097).
216
+ Currently, vp-auto uses fire-and-forget `Agent` spawning (no back-and-forth). Agent Teams
217
+ would enable:
218
+ - Lead orchestrator assigns tasks AND receives status updates
219
+ - Teammates can ask questions mid-task
220
+ - Better handling of inter-task dependency resolution
221
+
222
+ **Status**: experimental — requires `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1`.
223
+ Not yet used in ViePilot workflows. Tracked via ENH-099.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viepilot",
3
- "version": "3.8.0",
3
+ "version": "3.9.1",
4
4
  "description": "**Autonomous Vibe Coding Framework / Bộ khung phát triển tự động có kiểm soát**",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -67,6 +67,22 @@ Use Claude Code tools: `Bash` (shell), `Read` (file), `Edit` + `Write` (file wri
67
67
  `Agent` (spawn subagent — multi-level nesting supported)
68
68
  Interactive: `AskUserQuestion` (deferred — preload via ToolSearch before first call)
69
69
 
70
+ **Additional tools (ENH-099):**
71
+ - `Monitor` — run command in background, each output line fed back to Claude; use for
72
+ `npm test --watchAll=false`, dev server tail, CI polling mid-conversation
73
+ - `CronCreate` / `CronDelete` / `CronList` — in-session scheduled prompts (survive
74
+ `--resume`); use for periodic quality checks during long autonomous phases
75
+ - `EnterWorktree` / `ExitWorktree` — isolated git worktree per task; auto-cleanup on
76
+ exit if no changes; use for parallel task execution without branch conflicts
77
+ (not available to subagents)
78
+ - `LSP` — code intelligence: type errors after each edit, jump to definition, find
79
+ references; requires code intelligence plugin; replaces post-edit `tsc --noEmit`
80
+ - `PushNotification` — desktop + phone push on phase complete or control-point pause
81
+ (Anthropic infra only; not available on Bedrock/Vertex)
82
+ - `EnterPlanMode` / `ExitPlanMode` — plan gate before implementation: EnterPlanMode
83
+ switches to read-only planning; ExitPlanMode presents plan for approval before any
84
+ file edits are made
85
+
70
86
  ## D. Subagent Spawning
71
87
  Use `Agent` tool for subagent dispatch. For parallel task execution: fan-out with multiple
72
88
  `Agent` calls per cluster (see ADAPTER_CONTEXT.orchestration — claude-code supports parallel: true).
@@ -259,7 +259,7 @@ ELSE:
259
259
 
260
260
  **Agent Teams mode** (when `ADAPTER_CONTEXT.orchestration.teams == true` AND pending task count ≥ 8):
261
261
  - Set `TEAMS_MODE = true`
262
- - Activate shared TodoWrite task list for teammate coordination
262
+ - Activate shared TaskCreate/TaskList task list for teammate coordination
263
263
  - Each Agent worker reads from the shared list rather than receiving an explicit task prompt
264
264
 
265
265
  #### 3b-orch: Orchestrator Fan-out (Claude Code only)
@@ -342,7 +342,7 @@ On `QUALITY_GATE: FAIL` or `PARTIAL` → route to control point (retry cluster /
342
342
  On `QUALITY_GATE: PASS` → update PHASE-STATE.md (all cluster tasks → done), update TRACKER.md, continue.
343
343
 
344
344
  **Teams mode** (when `TEAMS_MODE == true`):
345
- - Write all pending task IDs to shared `TodoWrite` list at phase start
345
+ - Write all pending task IDs to shared task list via `TaskCreate` at phase start
346
346
  - Each `Agent(vp-task-executor)` reads next available task from shared list
347
347
  - Prevents duplicate execution when dispatching ≥ 8 tasks concurrently
348
348
 
@@ -689,6 +689,13 @@ quality_gate:
689
689
  - no_lint_errors: true
690
690
  ```
691
691
 
692
+ **Monitor pattern (ENH-099) — long-running verifications:**
693
+ For tests or builds that take minutes, use the `Monitor` tool instead of blocking `Bash`:
694
+ ```
695
+ Monitor: tail -f test-output.log — react when output contains "FAIL" or "Tests: N failed"
696
+ ```
697
+ This keeps the agentic loop active while the background process runs.
698
+
692
699
  #### Test Generation — test-generator-agent (ENH-057, BUG-028 fix)
693
700
 
694
701
  **Trigger**: current task is the last task in the phase AND task.md contains `## Acceptance Criteria`
@@ -845,6 +852,12 @@ Before phase-level verification, run a UI stub check:
845
852
  2. Check phase quality gate
846
853
  3. Write SUMMARY.md using `templates/phase/SUMMARY.md` as base.
847
854
 
855
+ **PushNotification (ENH-099, optional):**
856
+ After phase quality gate passes, send a desktop + phone alert:
857
+ - Message: "Phase {N} — {name} complete ✅ ({tasks} tasks, {tests} tests)"
858
+ - Requires Anthropic-hosted Claude Code (not available on Bedrock/Vertex).
859
+ - Call: `PushNotification` tool with the summary message.
860
+
848
861
  Populate `{{CREATED_FILES}}`, `{{MODIFIED_FILES}}`, `{{DELETED_FILES}}` from git:
849
862
  ```bash
850
863
  # Get ALL individual files changed since phase start tag