Feature Idea: Session-to-Repository Context Export
- 主要语言
- Shell
- 星标
- 11.2k
- 派生
- 1.9k
- 平均合并
- 14 小时 16 分钟
- 30 天内合并 PR
- 6
描述
## Building on Copilot CLI Sessions
[Copilot CLI](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/use-copilot-cli) persists sessions as JSONL files in `~/.copilot/session-state/`, supports resumption via `--resume` and `--continue`, and tracks conversation history, tool executions, and corrections.
**Proposal:** Provide native export from session learnings to permanent repository context - instructions, custom agents, skills, and prompt files.
## The Ask
1. **Export session context** - Convert session corrections and explanations into permanent artifacts
2. **Generate from patterns** - Analyze multiple sessions to surface repeated learnings
3. **Support Copilot repository context types:**
- **Repository instructions** - `.github/copilot-instructions.md`
- **Path-specific instructions** - `.github/instructions/*.instructions.md`
- **Custom agents** - `.github/agents/*.agent.md`
- **Prompt files** - `.github/prompts/*.prompt.md`
- **Skills** - `.github/skills/*/`
## Why Export Matters
Sessions accumulate knowledge that currently dies when the session ends:
* Developer corrects "No, we use handler pattern like this" → lost after session
* Developer explains "Platform code goes in Platforms/{os}/" → never captured
* Agent learns project-specific workflow → not available to other agents
* Same mistakes happen across sessions → no learning accumulation
Without export, every session starts from zero. With export, corrections become permanent repository context - whether that's a repository instruction, a path-specific rule, or a specialized agent.
## Why This Matters for Adoption
Repository context (instructions, agents, skills) is powerful but underutilized. Teams don't iterate because:
* No obvious source material for what to document
* Writing context files from scratch is high effort
* No connection between "what I just explained" and "what should be permanent"
**Session → Repository context export changes this:**
```
Developer corrects Copilot → Correction captured in session
↓
"Export this session" → Suggest: instruction? agent? skill?
↓
Review and commit → Future sessions/agents succeed immediately
```
Every correction becomes a repository improvement opportunity.
## The Workflow We Want
End of session:
```
Developer: /export
Copilot: "Found 3 patterns from this session:
1. [corrected 2x] Always null-check PlatformView before access
→ Suggest: .github/instructions/handlers.instructions.md
2. [workflow] Multi-step handler debugging process
→ Suggest: .github/agents/handler-debugger.agent.md
3. [repeated] PropertyMapper over manual setters
→ Suggest: .github/copilot-instructions.md
Export which?"
```
Or from CLI:
```bash
# Export specific session
gh copilot session export abc-123
# Analyze recent sessions for patterns
gh copilot context generate --from-recent 10
# Export to specific target
gh copilot session export --to-agent "handler-expert" abc-123
```
## The Gap
| What Exists | What's Missing |
|-------------|----------------|
| VS Code `/savePrompt` (prompt files only) | Export to instructions, agents, skills |
| Session persistence (JSONL, local) | Session → repository context export in CLI |
| Instructions, agents, skills (manual authoring) | Pattern/correction detection |
| `--resume` for session continuity | Multi-target intelligent suggestions |
| Copilot Memory (auto, 28-day expiry) | Permanent, version-controlled capture |
**Note:** VS Code's `/savePrompt` command creates prompt files from conversations, but:
- Not available in CLI ([#618](https://github.com/github/copilot-cli/issues/618), [#942](https://github.com/github/copilot-cli/issues/942))
- Only outputs `.prompt.md` files, not instructions/agents/skills
- Generalizes conversation rather than detecting corrections and patterns
## Minimal Version
Add `/export` slash command that:
1. Analyzes current session for corrections, explanations, and workflows
2. Suggests appropriate target (instruction, agent, skill, prompt)
3. Generates draft content
4. Outputs to clipboard or suggests file path
We'll handle the file creation and review ourselves.
## Connection to Memory Graduation
This complements [Memory → Instructions graduation](https://gist.github.com/PureWeen/27473a88d6cc3d3c8fa9a86f6a3b0bae):
| Memory Graduation | Session Export |
|-------------------|----------------|
| Cross-session patterns (28 days) | Single session capture (immediate) |
| Automatic learning | Explicit developer action |
| Repository-scoped | Session-scoped |
| "What has Copilot learned?" | "What did I just teach Copilot?" |
| Outputs to instructions | Outputs to instructions, agents, skills, prompts |
Both create feedback loops for continuous repository improvement. Memory catches patterns over time; session export captures knowledge in the moment before it's lost.
## Related Issues
| Issue | Relationship |
|-------|--------------|
| [#667](https://github.com/github/copilot-cli/issues/667) - Persistent Memory | Wants *automatic* cross-session learning. We want *explicit* export with human review. Complementary. |
| [#618](https://github.com/github/copilot-cli/issues/618) - Custom slash commands from prompts | Wants to *read* prompt files in CLI. We want to *write* repository context from sessions. |
| [#942](https://github.com/github/copilot-cli/issues/942) - Slash commands in CLI | Confirms prompt files don't work in CLI. Our ask extends beyond prompts to all context types. |
| [#377](https://github.com/github/copilot-cli/issues/377) - Memory options | Wants visibility into context (`/memory`). We want export *from* context to files. |
| [#714](https://github.com/github/copilot-cli/issues/714) - Session History Search | Search finds past sessions. Export captures learnings as repository context. |
| [#934](https://github.com/github/copilot-cli/issues/934) - Plan Mode | Similar "session → file" concept but for plans, not learnings. |
| [Memory graduation proposal](https://gist.github.com/PureWeen/27473a88d6cc3d3c8fa9a86f6a3b0bae) | Complementary - Memory graduation handles cross-session patterns; session export handles in-the-moment capture. |
## How This Differs
| Existing Feature/Request | This Proposal |
|--------------------------|---------------|
| VS Code `/savePrompt` | Multi-target (not just prompts), CLI support, pattern detection |
| Automatic memory (#667) | Explicit, reviewable export |
| Memory visibility (#377) | Export to version-controlled files |
| Session search (#714) | Convert sessions to reusable context |
| Plan mode (#934) | Captures learnings/corrections, not plans |
## References
* [Copilot CLI docs](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/use-copilot-cli)
* [Repository instructions](https://docs.github.com/en/copilot/customizing-copilot/adding-custom-instructions-for-github-copilot)
* [Custom agents](https://docs.github.com/en/copilot/concepts/agents/coding-agent/about-custom-agents)
* [Prompt files](https://docs.github.com/en/copilot/tutorials/customization-library/prompt-files)
* [Copilot Memory](https://docs.github.com/en/copilot/concepts/agents/copilot-memory)
Our request adds: **session export command**, **pattern detection**, **multi-target generation** (instructions, agents, skills, prompts).
贡献指南
评估
这个 Issue 还没有评估数据。