{%- set insight_cfg = config.get('insight', {}) -%}
{%- set enabled = insight_cfg.get('enabled', True) -%}
{%- if enabled -%}
# Insight Accumulation Workflow

## Why Accumulate Insights

> **Every dialogue may produce experience worth accumulating. Whether the AI Agent is executing autonomously or a human is driving development through IDE dialogue, the habit of insight accumulation should be maintained throughout.**

The Insight system is the project's "organizational memory" -- it extracts experience scattered across dialogues, code, and documentation into structured knowledge for future developers (human or AI) to retrieve and reuse.

## When to Accumulate

In the following scenarios, proactively consider creating an Insight:

| Scenario | Example | Suggested Category |
|----------|---------|-------------------|
| **Solved a tricky bug** | Found GBK encoding causes emoji crash | `debug` |
| **Discovered a better approach** | Using dataclass instead of dict for type safety | `technique` |
| **Made an important architecture/design decision** | Chose Jinja2 over Mako as template engine | `decision` |
| **Summarized tool/framework experience** | pytest fixture scope selection strategy | `tool` |
| **Established a reusable workflow** | CI/CD config checklist for upgrading from 3.8 to 3.9+ | `workflow` |
| **Found cross-module integration points** | EventLog and InsightManager collaboration pattern | `integration` |

## Accumulation Flow

### IDE Dialogue Mode (Human + AI Dialogue)

Near the end of dialogue, perform the following check:

```
1. Review the main outcomes of this dialogue
2. Determine if there is experience worth accumulating (refer to scenario table above)
3. If yes -> Use vibecollab insight add to create an Insight
4. If no -> Skip, continue normal dialogue end flow
```

**Creation command example**:
```bash
vibecollab insight add \
  --title "Windows GBK Encoding Compatibility Solution" \
  --tags "windows,encoding,gbk,unicode" \
  --category debug \
  --body "On Windows GBK terminals, directly outputting emoji characters causes UnicodeEncodeError. Solution: create a shared _compat.py module with unified EMOJI dict and BULLET variable, auto-downgrade to ASCII substitutes in GBK environment."
```

### Agent Autonomous Mode

After completing tasks, the Agent should automatically evaluate whether there is experience worth accumulating and call `vibecollab insight add` when appropriate.

### Viewing and Searching

```bash
# List all Insights
vibecollab insight list

# Search by tags
vibecollab insight search --tags "encoding,windows"

# View details
vibecollab insight show INS-001
```

## AI Dialogue End Checklist

**Before** executing the normal dialogue end flow (update docs -> git commit), complete the following:

- [ ] **Experience check**: Did this dialogue produce new experience worth accumulating?
- [ ] **Existing search**: Is there already a similar Insight? (avoid duplicate accumulation)
- [ ] **Accumulation execution**: If new experience -> `vibecollab insight add`

> **Tip**: Better to over-accumulate than to miss. Insights have an automatic decay mechanism -- infrequently retrieved experience will naturally decrease in weight.

---
{%- endif -%}
