@ai-memory/plugin-copilot-cli
v0.1.1
Published
GitHub Copilot CLI plugin for Agent Memory - enables persistent memory for CLI interactions
Downloads
243
Maintainers
Readme
Agent Memory Copilot CLI Integration
Persistent memory integration for GitHub Copilot CLI, powered by Agent Memory.
Phase B + C Implementation
This package now provides programmatic Copilot hook automation with comprehensive visual feedback for:
- Context injection on session start (
onSessionStart) - Prompt observation capture (
onUserPromptSubmitted) - Tool-use observation capture (
onPostToolUse) - Session summarization persistence (
onSessionEnd) - NEW: Structured visual feedback with formatted output
- NEW: Progress tracking and session summaries
- NEW: Recovery suggestions for configuration errors
Use createCopilotAutomationHooks in Copilot SDK-style sessions to emulate Claude Code-style memory automation, but aligned to Copilot's callback model.
Usage
import { AgentMemoryClient } from '@ai-memory/sdk';
import { createCopilotAutomationHooks, SessionProgressIndicator } from '@ai-memory/plugin-copilot-cli';
const memory = new AgentMemoryClient({
apiKey: process.env.AGENT_MEMORY_API_KEY!,
workerUrl: process.env.AGENT_MEMORY_WORKER_URL!,
apiUrl: process.env.AGENT_MEMORY_API_URL!,
});
const hooks = createCopilotAutomationHooks(memory, {
projectFallback: 'my-project', // (Optional, deprecated) Fallback project
contextMaxTokens: 2000, // (Optional) Context size limit
verbose: true, // (Optional) Show memory operation logs
});
const progress = new SessionProgressIndicator();
// Pass `hooks` to your Copilot SDK session creation.Visual Feedback Features
Verbose Mode Output
When verbose: true is set:
[memory:info] Session starting in /path/to/project
[memory:✓] Project resolved: my-project
[memory:info] Creating memory session for project: my-project
[memory:✓] Memory session created: mem-abc123def456
[memory:info] Loading context (max 2000 tokens)
[memory:✓] Context loaded: 3 items
━━━━ MEMORY CONTEXT (3 items) ━━━━
[Context from previous sessions...]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[memory:info] Recording user prompt (142 chars)
[memory:✓] User prompt recordedFormatted Context Injection
Use formatContextInjection() to display injected context:
┌─ MEMORY CONTEXT ─────────────────────────────────────┐
│ Items: 3 │
│ Size: 2.0KB │
│ From: recent-sessions, shared-project │
│ │
│ Preview: │
│ Previous discussion about authentication │
│ API endpoint definitions │
│ Test coverage notes │
└───────────────────────────────────────────────────────┘Observation Tracking
Track memory operations with SessionProgressIndicator:
const progress = new SessionProgressIndicator();
progress.recordObservation({
type: 'user-message',
charCount: input.content.length
});
console.log(progress.formatSummary());
// Output: [memory] Session: 3 observations, 2.0KB, 145msError Messages with Recovery
Errors include helpful recovery suggestions:
[memory:✗] Configuration not found
Suggestions:
• Create .memory/config.yml in your project root
• Run: copilot memory init
• Pass project: "your-project" to createCopilotAutomationHooks()API Reference
createCopilotAutomationHooks(memory, options?)
Automatically:
- Create a memory session when Copilot CLI starts
- Track all observations (prompts, tool calls, results)
- Count and log total observations per session
- Persist and summarize on session end
Options:
projectFallback?: string— Legacy fallback project (deprecated, use config-first)contextMaxTokens?: number— Context size limit (default: 2000)verbose?: boolean— Show memory operation logs (default: false)
Visual Feedback Functions
formatMemoryStatus(status)— Format status messagesformatContextInjection(summary)— Format injected context displayformatObservationRecorded(obs)— Format observation confirmationsformatMemoryError(code, message)— Format errors with suggestionsformatBytes(bytes)— Format byte sizes (B, KB, MB)SessionProgressIndicator— Track and summarize operations
Session Tracking
The hooks automatically:
- Create a memory session when Copilot CLI starts
- Track all observations (prompts, tool calls, results)
- Count and log total observations per session
- Persist and summarize on session end
Phase B: Config-First (Error-First)
Now requires .memory/config.yml for project identity:
# .memory/config.yml
project: my-project
# (Optional) Enable context from related projects
inherit_from:
- shared-project
# (Optional) Share context with other projects
shared_with:
- related-projectWithout config, memory operations fail gracefully with helpful error messages.
Exports
copilotCliAdapter- existing adapter-kit-based event normalization.createCopilotAutomationHooks- Copilot callback automation with visual feedback.HookOptions- Configuration interface (projectFallback, contextMaxTokens, verbose).formatMemoryStatus,formatContextInjection,formatObservationRecorded,formatMemoryError,formatBytes- Visual feedback functions.SessionProgressIndicator- Progress tracking class.
Testing
pnpm --filter @ai-memory/plugin-copilot-cli test
pnpm --filter @ai-memory/plugin-copilot-cli typecheck