Skip to content

PerryLink/loop-copilot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

loop-copilot — Goal-Driven Autonomous Dev Loop for GitHub Copilot

Version License

设定一个自然语言目标,自动完成设计->实施->测试->验证的完整闭环——面向 1 亿+ GitHub 开发者,无需切换工具链。

English | 中文


English

loop-copilot extends GitHub Copilot Chat into a fully autonomous, end-to-end development loop using the Copilot SDK SessionHooks extension system.

Features

  • Full closed-loop workflow — design bubble (brainstorm -> research -> plan) + implementation bubble (plan -> task -> code -> review -> test -> verify)
  • Bun-compiled CLI binary — single-file executable, cross-platform, zero npm dependencies at runtime
  • Copilot SDK SessionHooks integration — PreToolUse allow/deny/ask decision matrix with modifiedArgs and additionalContext
  • P0/P1/P2 issue routing — automatic fallback: redesign (P0), fix-at-design-or-impl level (P1), patch (P2)
  • convergence_counter with fast-path early termination — CR >= 2 with no new issues triggers early exit
  • 6-method auth chain — P1-P6 priority auto-detection with BYOK fallback
  • State persistence — state.json survives compaction and session restarts; Default-FAIL contract

Quick Start

# Clone and build
git clone https://github.com/PerryLink/loop-copilot.git
cd loop-copilot
bun install
bun run src/index.ts

# Or build standalone binary
bun build --compile --target=bun src/index.ts --outfile loop-copilot
./loop-copilot --goal "Write a Python CLI weather tool"

Requirements: Bun >= 1.0.0, GitHub Copilot extension installed in your editor, Copilot API access token.

FAQ

Q: How does this compare to just chatting with Copilot?

A: Copilot Chat is one-turn-at-a-time — you ask, it answers, you decide what to do next. loop-copilot automates the entire loop: it drives Copilot through 11 phases (design, implement, test, verify), routes failures back to the right phase, tracks convergence, and stops only when verification passes or the turn limit is hit. You set a goal; Copilot does the rest.

Q: What are the SessionHooks and why are they needed?

A: The Copilot SDK exposes four hook points — SessionStart, PreToolUse, PostToolUse, SessionEnd. loop-copilot registers handlers at each point to inject context (CLAUDE.md skeleton + state.json), intercept dangerous operations (allow/deny/ask), audit tool outputs, and enforce the G6 hard verification gate. Without hooks, the loop has no way to enforce safety or track state across Copilot sessions.

Q: Do I need my own API key?

A: loop-copilot's 6-method auth chain auto-detects available credentials in priority order (P1: Copilot subscription token, P2: GitHub token, P3-P6: various OAuth/env methods). If none are found, you can use the BYOK (Bring Your Own Key) fallback by setting COPILOT_API_KEY in your environment.

Related Projects

License

Apache License 2.0 — see LICENSE for full text.

Copyright 2026 Perry Link


中文

English | 中文

loop-copilot —— 面向 GitHub Copilot 的目标驱动全自动开发闭环系统

设定一个自然语言目标,自动完成 设计 → 实施 → 测试 → 验证 的完整闭环 —— 面向 1 亿+ GitHub 开发者,无需切换工具链。

loop-copilot 将 GitHub Copilot Chat 的交互模式扩展为全自动的端到端开发闭环,基于 Copilot SDK SessionHooks 扩展系统。

特性

  • 完整闭环工作流 —— 设计气泡(头脑风暴 → 调研 → 方案)+ 实施气泡(计划 → 任务 → 编码 → 审查 → 测试 → 验证)
  • Bun 编译 CLI 二进制 —— 单文件可执行,跨平台,运行时零 npm 依赖
  • Copilot SDK SessionHooks 集成 —— PreToolUse allow/deny/ask 决策矩阵,支持 modifiedArgs 和 additionalContext
  • P0/P1/P2 问题路由 —— 自动回退:重新设计(P0)、在设计或实施阶段修复(P1)、打补丁(P2)
  • 收敛计数器 + 快速通道提前终止 —— CR >= 2 且无新问题时触发提前退出
  • 6 方法认证链 —— P1-P6 优先级自动检测,支持 BYOK 回退
  • 状态持久化 —— state.json 在压缩和会话重启后依然存活;Default-FAIL 合约

快速开始

# 克隆并构建
git clone https://github.com/PerryLink/loop-copilot.git
cd loop-copilot
bun install
bun run src/index.ts

# 或构建独立二进制文件
bun build --compile --target=bun src/index.ts --outfile loop-copilot
./loop-copilot --goal "Write a Python CLI weather tool"

依赖要求:Bun >= 1.0.0,编辑器中安装 GitHub Copilot 扩展,Copilot API 访问令牌。

常见问题

Q:这和直接跟 Copilot 聊天有什么区别?

A:Copilot Chat 每次只处理一轮——你问,它答,你决定下一步。loop-copilot 自动化了整个循环:它驱动 Copilot 经历 11 个阶段(设计、实施、测试、验证),将失败路由回正确阶段,追踪收敛情况,仅在验证通过或达到轮次上限时才停止。你设定目标,Copilot 完成剩下的工作。

Q:SessionHooks 是什么?为什么需要它们?

A:Copilot SDK 暴露了四个钩子点 —— SessionStartPreToolUsePostToolUseSessionEnd。loop-copilot 在每个点上注册处理程序,用于注入上下文(CLAUDE.md 骨架 + state.json)、拦截危险操作(allow/deny/ask)、审计工具输出,以及强制执行 G6 硬验证闸门。没有钩子,循环就无法在 Copilot 会话之间强制执行安全策略或追踪状态。

Q:我需要自己的 API 密钥吗?

A:loop-copilot 的 6 方法认证链会按优先级自动检测可用凭证(P1:Copilot 订阅令牌,P2:GitHub 令牌,P3-P6:各种 OAuth/环境变量方法)。如果都未找到,可以通过设置 COPILOT_API_KEY 环境变量使用 BYOK(自带密钥)回退方案。

相关项目

许可证

Apache License 2.0 —— 详见 LICENSE 文件。

Copyright 2026 Perry Link

About

Autonomous closed-loop for GitHub Copilot via SDK SessionHooks. G1-G6 matrix, 6-auth, L1-L3 safety & layered CLAUDE.md (~82% token savings). Part of the Loop Engineering family.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors