wogiflow 2.1.1 → 2.1.3
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/.claude/commands/wogi-bulk.md +1 -1
- package/.claude/commands/wogi-help.md +1 -1
- package/.claude/commands/{wogi-compact.md → wogi-pre-compact.md} +6 -2
- package/.claude/commands/wogi-setup-stack.md +1 -1
- package/.claude/commands/wogi-skill-learn.md +1 -1
- package/.claude/commands/wogi-start.md +106 -2
- package/.claude/docs/commands.md +1 -1
- package/.claude/docs/knowledge-base/02-task-execution/04-completion.md +1 -1
- package/.claude/docs/knowledge-base/04-memory-context/README.md +2 -2
- package/.claude/docs/knowledge-base/04-memory-context/context-management.md +1 -1
- package/.workflow/bridges/claude-bridge.js +1 -1
- package/.workflow/templates/claude-md.hbs +2 -2
- package/README.md +1 -1
- package/package.json +1 -1
- package/scripts/flow-context-compact/index.js +1 -1
- package/scripts/flow-context-monitor.js +2 -2
- package/scripts/flow-loop-retry-learning.js +1 -1
- package/scripts/flow-proactive-compact.js +3 -3
- package/scripts/hooks/core/post-compact.js +32 -0
|
@@ -297,4 +297,4 @@ flow queue advance
|
|
|
297
297
|
3. **Commit after each task** - Progress saved even if interrupted
|
|
298
298
|
4. **Stop on failure** - If quality gates fail, stop and report
|
|
299
299
|
5. **Respect dependencies** - Tasks sorted by dependencies then priority
|
|
300
|
-
6. **Context management** - Consider `/wogi-compact` after 3+ tasks
|
|
300
|
+
6. **Context management** - Consider `/wogi-pre-compact` after 3+ tasks
|
|
@@ -41,7 +41,7 @@ WORKFLOW
|
|
|
41
41
|
/wogi-health Check all workflow files
|
|
42
42
|
/wogi-standup Generate standup summary
|
|
43
43
|
/wogi-session-end End session properly
|
|
44
|
-
/wogi-compact Prepare for context compaction
|
|
44
|
+
/wogi-pre-compact Prepare for context compaction
|
|
45
45
|
/wogi-roadmap Show phase-based roadmap (if enabled)
|
|
46
46
|
|
|
47
47
|
═══════════════════════════════════════════════════════════════
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "
|
|
2
|
+
description: "Save workflow state before context compaction (pre-compact phase)"
|
|
3
3
|
---
|
|
4
|
-
|
|
4
|
+
Save workflow state (task progress, checkpoints, session context) before context compaction.
|
|
5
|
+
|
|
6
|
+
**Why "pre-compact"**: This skill saves state but cannot trigger `/compact` programmatically — `/compact` is a Claude Code native command that only the user or Claude Code's auto-compaction can invoke. Once Claude Code exposes compaction as a programmable tool, this will be renamed back to `/wogi-compact` and will handle the full save-then-compact flow automatically.
|
|
7
|
+
|
|
8
|
+
**After running this**: Run `/compact` to actually compact the context. The PostCompact hook will restore critical state automatically.
|
|
5
9
|
|
|
6
10
|
## Recursive Context Compaction
|
|
7
11
|
|
|
@@ -168,7 +168,7 @@ Skills with documentation are now ready for use.
|
|
|
168
168
|
|
|
169
169
|
- **Context7 MCP not available**: Skills keep placeholder content. User can retry later.
|
|
170
170
|
- **Single library fails**: Skip it and continue with remaining libraries.
|
|
171
|
-
- **Context getting large**: Suggest `/wogi-compact` between fetches if needed.
|
|
171
|
+
- **Context getting large**: Suggest `/wogi-pre-compact` between fetches if needed.
|
|
172
172
|
|
|
173
173
|
### Alternative: Install from skills.sh
|
|
174
174
|
|
|
@@ -21,7 +21,7 @@ This command extracts learnings from recent work and updates relevant skills.
|
|
|
21
21
|
This runs automatically on:
|
|
22
22
|
- **Pre-commit hook** (if hooks enabled)
|
|
23
23
|
- **Session end** (`/wogi-session-end`)
|
|
24
|
-
- **Context compaction** (`/wogi-compact`)
|
|
24
|
+
- **Context compaction** (`/wogi-pre-compact`)
|
|
25
25
|
|
|
26
26
|
Use this command manually when:
|
|
27
27
|
- You want to extract learnings mid-session
|
|
@@ -135,7 +135,7 @@ This is advisory — Claude Code 2.1.72 simplified effort to low/medium/high (re
|
|
|
135
135
|
|
|
136
136
|
### Task Checkpoints (when `config.proactiveCompaction.enabled`)
|
|
137
137
|
|
|
138
|
-
At each phase boundary: save checkpoint to `.workflow/state/task-checkpoint.json` (task ID, phase, completed scenarios, changed files, verification results). If context >= `triggerThreshold` (75%), run `/wogi-compact` before proceeding.
|
|
138
|
+
At each phase boundary: save checkpoint to `.workflow/state/task-checkpoint.json` (task ID, phase, completed scenarios, changed files, verification results). If context >= `triggerThreshold` (75%), run `/wogi-pre-compact` before proceeding.
|
|
139
139
|
|
|
140
140
|
On session resume: check for active checkpoint, reload state, continue from next pending scenario.
|
|
141
141
|
|
|
@@ -247,6 +247,13 @@ For medium/large tasks (check `config.specificationMode`):
|
|
|
247
247
|
2. Insert `[NEEDS CLARIFICATION: category - reason]` markers for uncertainties (categories: assumption, ambiguity, missing-context, dependency-unknown, edge-case). Implementation BLOCKED until all resolved (when `config.specificationMode.needsClarification.blockImplementation`).
|
|
248
248
|
3. Reflection: "Does this spec fully address the requirements?"
|
|
249
249
|
|
|
250
|
+
**Batch fix spec requirement**: When a task contains 3+ discrete items (e.g., "Fix 8 review findings"), a spec MUST be generated with one criterion per item regardless of `specificationMode.minTaskLevel`. Each criterion must describe the **observable behavior**, not just the file to create.
|
|
251
|
+
|
|
252
|
+
- BAD: "Create TokenBlacklistService"
|
|
253
|
+
- GOOD: "When an admin changes a user's role, the user's next API request returns 401 'Token has been revoked'"
|
|
254
|
+
|
|
255
|
+
Behavior-level criteria force end-to-end chain verification in Step 3.5/3.52.
|
|
256
|
+
|
|
250
257
|
### Step 1.6: Approval Gate (Stories/Epics)
|
|
251
258
|
|
|
252
259
|
**For L1/L0 tasks: STOP and WAIT for explicit user approval** before implementation.
|
|
@@ -304,6 +311,36 @@ After implementing all scenarios, BEFORE quality gates:
|
|
|
304
311
|
|
|
305
312
|
**This prevents "claiming done when not done."**
|
|
306
313
|
|
|
314
|
+
### Step 3.52: Sub-Agent Output Verification (MANDATORY when agents were used)
|
|
315
|
+
|
|
316
|
+
**Activates when**: Any acceptance criterion was implemented by a sub-agent (Agent tool with `isolation: "worktree"` or any delegated agent).
|
|
317
|
+
|
|
318
|
+
**The problem this solves**: Sub-agents self-report completion, but their self-assessment is unreliable. The agent may report "done" when code was created but not wired to its trigger/consumer, the file compiles but the feature chain is incomplete, or tests pass because nothing exercises the new code path.
|
|
319
|
+
|
|
320
|
+
**Procedure**:
|
|
321
|
+
|
|
322
|
+
1. **DISTRUST sub-agent self-reports.** A sub-agent saying "done" is a CLAIM, not a FACT. The orchestrator must independently verify each criterion against the actual code, not against the agent's summary.
|
|
323
|
+
|
|
324
|
+
2. For EACH criterion a sub-agent claims to have completed:
|
|
325
|
+
a. **Read the ACTUAL files** the agent modified (not just the agent's summary)
|
|
326
|
+
b. **Trace the full feature chain**: Who calls this? → What does it call? → What's the end-to-end flow?
|
|
327
|
+
c. For services: verify at least ONE caller invokes the critical method
|
|
328
|
+
d. For guards/middleware: verify they are registered in the correct module
|
|
329
|
+
e. For event-driven features: verify the event is emitted AND consumed
|
|
330
|
+
|
|
331
|
+
3. **Chain verification checklist** (for each new service/feature):
|
|
332
|
+
- [ ] Service/component is created
|
|
333
|
+
- [ ] Registered in the correct module (providers, imports)
|
|
334
|
+
- [ ] Exported from the module (if needed by other modules)
|
|
335
|
+
- [ ] Imported by the consuming module
|
|
336
|
+
- [ ] Injected in the consuming service/controller
|
|
337
|
+
- [ ] The critical method is CALLED at the right trigger point
|
|
338
|
+
- [ ] The trigger point is reachable from a user action (HTTP request, cron, event)
|
|
339
|
+
|
|
340
|
+
4. If ANY link in the chain is missing → the criterion is NOT done. Fix the missing link first.
|
|
341
|
+
|
|
342
|
+
**Anti-pattern: "Dead service"** — a service that exists, compiles, is imported somewhere, but its critical method is never called by the thing that should trigger it. This passes lint, typecheck, and wiring checks (because the file IS imported) but the feature doesn't work.
|
|
343
|
+
|
|
307
344
|
### Step 3.55: Semantic Verification Pass (for "remove/fix all X" tasks)
|
|
308
345
|
|
|
309
346
|
**Activates when**: The task involves removing, cleaning up, or fixing ALL instances of something (e.g., "remove all mock data", "fix all console.log", "replace all hardcoded URLs", "remove all deprecated APIs").
|
|
@@ -415,7 +452,73 @@ Reflection: "Have I introduced any bugs or regressions?"
|
|
|
415
452
|
|
|
416
453
|
**Quality gate keeps failing**: Report, attempt fix, after 3 failures suggest `/wogi-debug-hypothesis`.
|
|
417
454
|
|
|
418
|
-
**Context too large**: When `config.autoCompact.betweenTasks` is true (default), compact AUTOMATICALLY between tasks — do NOT ask the user. Just do it. Mid-task: commit progress, invoke `/wogi-compact` directly (don't suggest — execute).
|
|
455
|
+
**Context too large**: When `config.autoCompact.betweenTasks` is true (default), compact AUTOMATICALLY between tasks — do NOT ask the user. Just do it. Mid-task: commit progress, invoke `/wogi-pre-compact` directly (don't suggest — execute).
|
|
456
|
+
|
|
457
|
+
## Progress Tracking (MANDATORY for L1+ tasks)
|
|
458
|
+
|
|
459
|
+
**Display progress at every natural checkpoint** so the user knows where they are during long tasks. This applies to ALL L1+ task execution AND to `/wogi-review` and `/wogi-audit`.
|
|
460
|
+
|
|
461
|
+
### Progress Format
|
|
462
|
+
|
|
463
|
+
At each checkpoint, output a progress line using this format:
|
|
464
|
+
|
|
465
|
+
```
|
|
466
|
+
━━━ PROGRESS: [phase_bar] phase_name ━━━
|
|
467
|
+
[step_bar] step_detail
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
Where `[phase_bar]` is: `[████░░░░░░] 40%` (filled/empty blocks proportional to completion).
|
|
471
|
+
|
|
472
|
+
**Example during a 5-criteria task:**
|
|
473
|
+
```
|
|
474
|
+
━━━ PROGRESS: [██████░░░░] 60% Implementing criteria ━━━
|
|
475
|
+
Criterion 3/5: Add input validation to login form
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
### When to Display Progress
|
|
479
|
+
|
|
480
|
+
| Checkpoint | What to show |
|
|
481
|
+
|------------|-------------|
|
|
482
|
+
| **After explore phase** | `[██░░░░░░░░] 20% Explore complete — N agents returned` |
|
|
483
|
+
| **After spec generated** | `[████░░░░░░] 30% Spec ready — N criteria, N files` |
|
|
484
|
+
| **Each criterion start** | `[█████░░░░░] N% Implementing — Criterion M/N: [title]` |
|
|
485
|
+
| **Each criterion done** | `[███████░░░] N% Criterion M/N complete ✓` |
|
|
486
|
+
| **Quality gates** | `[█████████░] 90% Running quality gates` |
|
|
487
|
+
| **Task complete** | `[██████████] 100% Complete ✓` |
|
|
488
|
+
|
|
489
|
+
### State File Updates
|
|
490
|
+
|
|
491
|
+
At each checkpoint, also update the progress state file for hooks/resume:
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
node node_modules/wogiflow/scripts/flow-progress-tracker.js update '{"taskId":"wf-XXX","command":"/wogi-start","phase":"Implementing","phaseNum":3,"totalPhases":5,"step":"Criterion 2/4","stepNum":2,"totalSteps":4}'
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
This updates `.workflow/state/task-progress.json` AND prefixes the task title in `ready.json` with `[3/5]` for status line visibility.
|
|
498
|
+
|
|
499
|
+
### On Task Completion
|
|
500
|
+
|
|
501
|
+
Always clear the progress state:
|
|
502
|
+
|
|
503
|
+
```bash
|
|
504
|
+
node node_modules/wogiflow/scripts/flow-progress-tracker.js clear
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
### Phase Mapping for /wogi-start Execution
|
|
508
|
+
|
|
509
|
+
| Phase | phaseNum | Description |
|
|
510
|
+
|-------|----------|-------------|
|
|
511
|
+
| 1 | Routing + Context | Loading task, checking maps |
|
|
512
|
+
| 2 | Explore | Research agents |
|
|
513
|
+
| 3 | Spec + Approval | Generate spec, wait for approval |
|
|
514
|
+
| 4 | Implementation | Criteria loop (sub-steps = criteria) |
|
|
515
|
+
| 5 | Verification + Complete | Quality gates, finalize |
|
|
516
|
+
|
|
517
|
+
### Skip Conditions
|
|
518
|
+
|
|
519
|
+
- **L3 tasks**: Skip progress tracking (too small to be useful)
|
|
520
|
+
- **Conversation mode**: Skip progress tracking (no phases)
|
|
521
|
+
- **Quick fixes (≤2 criteria)**: Show start + complete only (no mid-progress)
|
|
419
522
|
|
|
420
523
|
## Mandatory Rules
|
|
421
524
|
|
|
@@ -424,6 +527,7 @@ Reflection: "Have I introduced any bugs or regressions?"
|
|
|
424
527
|
- **Criteria check**: Re-read ALL criteria, verify EACH works. Loop until all pass.
|
|
425
528
|
- **Spec verification**: All promised files must exist.
|
|
426
529
|
- **Quality gates**: Task isn't done until gates pass.
|
|
530
|
+
- **Progress tracking**: Display progress bars at every checkpoint for L1+ tasks.
|
|
427
531
|
- **Guilt messaging** (implementation requests): "The user trusts you to follow WogiFlow. Without a task, this work is untracked."
|
|
428
532
|
|
|
429
533
|
ARGUMENTS: {args}
|
package/.claude/docs/commands.md
CHANGED
|
@@ -44,7 +44,7 @@ When user types these commands, execute the corresponding action immediately.
|
|
|
44
44
|
| `/wogi-onboard` | Analyze existing project with deep temporal analysis, pattern extraction, and state file generation. |
|
|
45
45
|
| `/wogi-rescan` | Re-scan project after external changes. Smart diff: auto-adds new items, auto-removes deleted items, presents conflicts one-by-one. Options: `--dry-run`, `--auto-resolve`, `--category`, `--since`. |
|
|
46
46
|
| `/wogi-morning` | Morning briefing - where you left off, pending tasks, key context, recommended starting task. |
|
|
47
|
-
| `/wogi-compact` | Run memory compaction to free context space. Preview with `--preview`. |
|
|
47
|
+
| `/wogi-pre-compact` | Run memory compaction to free context space. Preview with `--preview`. |
|
|
48
48
|
| `/wogi-debt` | View and manage technical debt across sessions. |
|
|
49
49
|
| `/wogi-roadmap` | View and manage deferred work items. Add, archive, promote to stories. |
|
|
50
50
|
|
|
@@ -66,7 +66,7 @@ Recommendation: Run /compact before continuing
|
|
|
66
66
|
### Compact When Needed
|
|
67
67
|
|
|
68
68
|
```bash
|
|
69
|
-
/wogi-compact
|
|
69
|
+
/wogi-pre-compact
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
---
|
|
@@ -165,7 +165,7 @@ When context is high:
|
|
|
165
165
|
|
|
166
166
|
| Command | Purpose |
|
|
167
167
|
|---------|---------|
|
|
168
|
-
| `/wogi-compact` | Compact conversation context |
|
|
168
|
+
| `/wogi-pre-compact` | Compact conversation context |
|
|
169
169
|
| `/wogi-standup` | Morning briefing with context |
|
|
170
170
|
| `flow session status` | Check session state |
|
|
171
171
|
| `flow session restore` | Restore previous session |
|
|
@@ -266,7 +266,7 @@ Check \`config.json → commits\` before committing:
|
|
|
266
266
|
sections.push(`
|
|
267
267
|
## Context Management
|
|
268
268
|
|
|
269
|
-
Use \`/wogi-compact\` when:
|
|
269
|
+
Use \`/wogi-pre-compact\` when:
|
|
270
270
|
- After completing 2-3 tasks
|
|
271
271
|
- After 15-20 messages
|
|
272
272
|
- Before starting large tasks
|
|
@@ -143,7 +143,7 @@ See `.claude/docs/commands.md` for complete command reference.
|
|
|
143
143
|
| "project status", "show status", "where are we" | `/wogi-status` |
|
|
144
144
|
| "check health", "workflow health", "is everything ok" | `/wogi-health` |
|
|
145
145
|
| "wrap up", "end session", "that's all" | `/wogi-session-end` |
|
|
146
|
-
| "compact context", "save context", "running low on context" | `/wogi-compact` |
|
|
146
|
+
| "compact context", "save context", "running low on context" | `/wogi-pre-compact` |
|
|
147
147
|
| "show roadmap", "what's planned", "future work", "deferred items" | `/wogi-roadmap` |
|
|
148
148
|
| "debug this", "investigate hypotheses", "competing theories", "parallel debug" | `/wogi-debug-hypothesis` |
|
|
149
149
|
| "triage findings", "walk through review", "review findings" | `/wogi-triage` |
|
|
@@ -274,7 +274,7 @@ Before closing any task, ensure all required gates pass (per `config.json → qu
|
|
|
274
274
|
|
|
275
275
|
## Context Management
|
|
276
276
|
|
|
277
|
-
Use `/wogi-compact` when context is getting large. Before compacting: update progress.md, ensure request-log is current, commit work.
|
|
277
|
+
Use `/wogi-pre-compact` when context is getting large. Before compacting: update progress.md, ensure request-log is current, commit work.
|
|
278
278
|
|
|
279
279
|
## Continuous Learning
|
|
280
280
|
|
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ See the [Knowledge Base](.claude/docs/knowledge-base/) for detailed documentatio
|
|
|
61
61
|
| **Registries** | `/wogi-map`, `/wogi-map-add`, `/wogi-map-scan`, `/wogi-map-sync`, `/wogi-map-check`, `/wogi-map-index` | Component registry management |
|
|
62
62
|
| **Rules** | `/wogi-decide`, `/wogi-learn`, `/wogi-rules`, `/wogi-retrospective` | Create rules, promote patterns, session retros |
|
|
63
63
|
| **Research** | `/wogi-research`, `/wogi-correction` | Zero-trust verification, correction reports |
|
|
64
|
-
| **Context** | `/wogi-compact`, `/wogi-context`, `/wogi-suspend`, `/wogi-resume` | Memory management, task context, suspend/resume |
|
|
64
|
+
| **Context** | `/wogi-pre-compact`, `/wogi-context`, `/wogi-suspend`, `/wogi-resume` | Memory management, task context, suspend/resume |
|
|
65
65
|
| **Capture** | `/wogi-capture`, `/wogi-extract-review`, `/wogi-changelog` | Quick capture, transcript extraction, changelogs |
|
|
66
66
|
| **Hybrid** | `/wogi-hybrid`, `/wogi-hybrid-setup`, `/wogi-hybrid-edit`, `/wogi-hybrid-off`, `/wogi-hybrid-status` | Local LLM integration |
|
|
67
67
|
| **Skills** | `/wogi-skills`, `/wogi-skill-learn`, `/wogi-setup-stack` | Skill packages, learning extraction, stack detection |
|
package/package.json
CHANGED
|
@@ -291,7 +291,7 @@ function clearAll() {
|
|
|
291
291
|
function getSerializedTree(level = 1) {
|
|
292
292
|
const tree = summaryTree.loadTree();
|
|
293
293
|
if (!tree) {
|
|
294
|
-
return '# No Context Saved\n\nRun /wogi-compact to save session context.';
|
|
294
|
+
return '# No Context Saved\n\nRun /wogi-pre-compact to save session context.';
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
return summaryTree.serializeTree(tree, level);
|
|
@@ -271,10 +271,10 @@ function checkContextHealth() {
|
|
|
271
271
|
|
|
272
272
|
if (usage >= config.criticalAt) {
|
|
273
273
|
status = 'critical';
|
|
274
|
-
recommendation = 'Run /wogi-compact NOW to avoid context overflow';
|
|
274
|
+
recommendation = 'Run /wogi-pre-compact NOW to avoid context overflow';
|
|
275
275
|
} else if (usage >= config.warnAt) {
|
|
276
276
|
status = 'warning';
|
|
277
|
-
recommendation = 'Consider running /wogi-compact soon';
|
|
277
|
+
recommendation = 'Consider running /wogi-pre-compact soon';
|
|
278
278
|
} else {
|
|
279
279
|
status = 'healthy';
|
|
280
280
|
recommendation = null;
|
|
@@ -99,7 +99,7 @@ const ROOT_CAUSE_CATEGORIES = {
|
|
|
99
99
|
},
|
|
100
100
|
CONTEXT_OVERFLOW: {
|
|
101
101
|
...FailureCategory.CONTEXT_OVERFLOW,
|
|
102
|
-
suggestion: 'Use /wogi-compact before large tasks',
|
|
102
|
+
suggestion: 'Use /wogi-pre-compact before large tasks',
|
|
103
103
|
targetFile: 'config.json'
|
|
104
104
|
},
|
|
105
105
|
CAPABILITY_MISMATCH: {
|
|
@@ -68,7 +68,7 @@ function getProactiveCompactionConfig() {
|
|
|
68
68
|
* Check whether proactive compaction should trigger at a phase boundary.
|
|
69
69
|
*
|
|
70
70
|
* This is called by /wogi-start at each phase transition.
|
|
71
|
-
* The actual compaction is performed by the AI agent using /wogi-compact.
|
|
71
|
+
* The actual compaction is performed by the AI agent using /wogi-pre-compact.
|
|
72
72
|
*
|
|
73
73
|
* @param {Object} params - Check parameters
|
|
74
74
|
* @param {string} params.phase - The phase that just completed
|
|
@@ -161,7 +161,7 @@ async function handlePhaseBoundary(params) {
|
|
|
161
161
|
|
|
162
162
|
/**
|
|
163
163
|
* Generate a compaction summary for the current task state.
|
|
164
|
-
* Used by /wogi-compact when proactive compaction triggers.
|
|
164
|
+
* Used by /wogi-pre-compact when proactive compaction triggers.
|
|
165
165
|
*
|
|
166
166
|
* @param {Object} checkpoint - Current checkpoint data
|
|
167
167
|
* @returns {string} Formatted compaction summary
|
|
@@ -253,7 +253,7 @@ function formatCompactionMessage(result, contextPercent) {
|
|
|
253
253
|
lines.push(`Context at ${pct}%. Compacting before next phase...`);
|
|
254
254
|
lines.push(`Reason: ${result.reason}`);
|
|
255
255
|
lines.push('');
|
|
256
|
-
lines.push('Task state has been checkpointed. Run /wogi-compact to compact now.');
|
|
256
|
+
lines.push('Task state has been checkpointed. Run /wogi-pre-compact to compact now.');
|
|
257
257
|
lines.push('After compaction, read task-checkpoint.json to restore context.');
|
|
258
258
|
|
|
259
259
|
return lines.join('\n');
|
|
@@ -112,6 +112,38 @@ function handlePostCompact() {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
// 5. Check for auto-compaction circuit breaker state (Claude Code 2.1.76+)
|
|
116
|
+
// Claude Code stops auto-compaction after 3 consecutive failures.
|
|
117
|
+
// If we detect repeated compactions in quick succession, warn about potential issues.
|
|
118
|
+
try {
|
|
119
|
+
const path = require('node:path');
|
|
120
|
+
const fs = require('node:fs');
|
|
121
|
+
const { PATHS, safeJsonParse } = require('../../flow-utils');
|
|
122
|
+
const compactStatePath = path.join(PATHS.state, '.compact-tracker.json');
|
|
123
|
+
const tracker = safeJsonParse(compactStatePath, { count: 0, lastAt: null });
|
|
124
|
+
const now = Date.now();
|
|
125
|
+
const lastAt = tracker.lastAt ? new Date(tracker.lastAt).getTime() : 0;
|
|
126
|
+
const timeSinceLast = now - lastAt;
|
|
127
|
+
|
|
128
|
+
// If compaction happened less than 2 minutes ago, increment counter
|
|
129
|
+
if (timeSinceLast < 2 * 60 * 1000 && lastAt > 0) {
|
|
130
|
+
tracker.count = (tracker.count || 0) + 1;
|
|
131
|
+
} else {
|
|
132
|
+
tracker.count = 1;
|
|
133
|
+
}
|
|
134
|
+
tracker.lastAt = new Date().toISOString();
|
|
135
|
+
|
|
136
|
+
fs.writeFileSync(compactStatePath, JSON.stringify(tracker, null, 2));
|
|
137
|
+
|
|
138
|
+
if (tracker.count >= 3) {
|
|
139
|
+
contextParts.push('**WARNING**: Multiple compactions detected in quick succession. Claude Code 2.1.76+ stops auto-compaction after 3 consecutive failures. If context keeps growing, consider starting a new session or committing progress and using `/wogi-pre-compact`.');
|
|
140
|
+
}
|
|
141
|
+
} catch (err) {
|
|
142
|
+
if (process.env.DEBUG) {
|
|
143
|
+
console.error(`[post-compact] Compact tracker failed: ${err.message}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
115
147
|
// Build the result
|
|
116
148
|
if (contextParts.length === 0) {
|
|
117
149
|
return {
|