longer-agent 0.1.2 → 0.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.
Files changed (55) hide show
  1. package/README.md +58 -151
  2. package/README.zh-CN.md +59 -152
  3. package/agent_templates/executor/agent.yaml +1 -0
  4. package/agent_templates/executor/system_prompt.md +1 -1
  5. package/agent_templates/explorer/agent.yaml +1 -0
  6. package/agent_templates/explorer/system_prompt.md +1 -1
  7. package/agent_templates/main/system_prompt.md +3 -2
  8. package/dist/agents/tool-loop.d.ts.map +1 -1
  9. package/dist/agents/tool-loop.js +6 -0
  10. package/dist/agents/tool-loop.js.map +1 -1
  11. package/dist/commands.d.ts.map +1 -1
  12. package/dist/commands.js +0 -1
  13. package/dist/commands.js.map +1 -1
  14. package/dist/log-projection.d.ts.map +1 -1
  15. package/dist/log-projection.js +71 -12
  16. package/dist/log-projection.js.map +1 -1
  17. package/dist/persistence.d.ts +2 -1
  18. package/dist/persistence.d.ts.map +1 -1
  19. package/dist/persistence.js +4 -2
  20. package/dist/persistence.js.map +1 -1
  21. package/dist/session.d.ts +0 -2
  22. package/dist/session.d.ts.map +1 -1
  23. package/dist/session.js +48 -156
  24. package/dist/session.js.map +1 -1
  25. package/dist/templates/loader.d.ts.map +1 -1
  26. package/dist/templates/loader.js +2 -0
  27. package/dist/templates/loader.js.map +1 -1
  28. package/dist/tools/basic.d.ts +2 -2
  29. package/dist/tools/basic.d.ts.map +1 -1
  30. package/dist/tools/basic.js +54 -7
  31. package/dist/tools/basic.js.map +1 -1
  32. package/dist/tools/comm.d.ts.map +1 -1
  33. package/dist/tools/comm.js +8 -7
  34. package/dist/tools/comm.js.map +1 -1
  35. package/dist/tui/app.d.ts.map +1 -1
  36. package/dist/tui/app.js +62 -39
  37. package/dist/tui/app.js.map +1 -1
  38. package/dist/tui/components/input-panel.d.ts.map +1 -1
  39. package/dist/tui/components/input-panel.js +8 -6
  40. package/dist/tui/components/input-panel.js.map +1 -1
  41. package/dist/tui/components/plan-panel.d.ts +3 -1
  42. package/dist/tui/components/plan-panel.d.ts.map +1 -1
  43. package/dist/tui/components/plan-panel.js +15 -2
  44. package/dist/tui/components/plan-panel.js.map +1 -1
  45. package/dist/tui/components/status-bar.d.ts.map +1 -1
  46. package/dist/tui/components/status-bar.js +17 -4
  47. package/dist/tui/components/status-bar.js.map +1 -1
  48. package/dist/tui/status-bar-model-name.d.ts +2 -0
  49. package/dist/tui/status-bar-model-name.d.ts.map +1 -0
  50. package/dist/tui/status-bar-model-name.js +81 -0
  51. package/dist/tui/status-bar-model-name.js.map +1 -0
  52. package/package.json +3 -3
  53. package/prompts/tools/plan.md +11 -240
  54. package/prompts/tools/summarize_context.md +1 -1
  55. package/prompts/tools/time.md +6 -0
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  <img src="https://raw.githubusercontent.com/FelixRuiGao/LongerAgent/main/assets/logo.png" alt="LongerAgent" width="360" />
3
3
  </p>
4
4
  <p align="center">
5
- <strong>Built to work longer.</strong>
5
+ <strong>Exploring agent autonomy.</strong>
6
6
  </p>
7
7
  <p align="center">
8
8
  English | <a href="./README.zh-CN.md">中文</a>
@@ -13,77 +13,72 @@
13
13
  <img alt="Author" src="https://img.shields.io/badge/author-Felix%20Rui%20Gao-4b4bf0?style=flat-square" />
14
14
  </p>
15
15
 
16
- A terminal AI coding agent that manages its own context proactively, runs parallel sub-agents, and lets you message it while it's working.
16
+ LongerAgent is a TUI demo exploring a design philosophy: what if the system just provided the tools and safety net, and let the agent proactively manage its own context and workflow?
17
17
 
18
- ![LongerAgent Terminal UI](https://raw.githubusercontent.com/FelixRuiGao/LongerAgent/main/assets/screenshot.png)
18
+ Parallel sub-agents investigating a codebase, an async message mid-task, and context summarization — all in one session:
19
19
 
20
- > **Platform:** macOS.
21
-
22
- ## Why LongerAgent
23
-
24
- Most coding agents work well for short bursts, then degrade as the session gets longer. LongerAgent is built for the opposite case:
25
-
26
- - **Long-running sessions** — context is monitored, summarized, and compacted before it collapses
27
- - **Interruptible work** — you can send a new message while the agent is still executing
28
- - **Parallel execution** — delegate exploration and implementation to sub-agents in the same session
29
- - **Project memory** — `AGENTS.md` and the Important Log survive across sessions and compactions
20
+ https://github.com/user-attachments/assets/377fe648-d43c-45da-b111-9434b2a0dc61
30
21
 
31
- If you want a terminal-native agent that can stay productive through a long refactor, investigation, or multi-step task, this is the point of the project.
22
+ ---
32
23
 
33
- ## Quick Start
24
+ ## Try It
34
25
 
35
26
  ```bash
36
- # Install globally
37
27
  npm install -g longer-agent
38
-
39
- # Run the setup wizard
40
28
  longeragent init
41
-
42
- # Start
43
29
  longeragent
44
30
  ```
45
31
 
46
- The setup wizard walks you through provider selection, API key configuration, and model selection. All preferences are saved to `~/.longeragent/tui-preferences.json`. For GLM, Kimi, and MiniMax, LongerAgent stores endpoint-specific keys in its own managed env slots inside `~/.longeragent/.env` and can import detected external env vars during `init` or `/model`. For OpenAI (ChatGPT Login), OAuth tokens are stored in `~/.longeragent/auth.json`; no runtime API-key env var is required.
32
+ The setup wizard walks you through provider selection (Anthropic, OpenAI, Kimi, MiniMax, GLM, Ollama, oMLX, LM Studio, OpenRouter) and model selection.
47
33
 
48
- ### First 5 Minutes
34
+ > **Platform:** macOS. **Safety:** LongerAgent does not sandbox shell commands or file edits. Run it in trusted environments and review what it does.
49
35
 
50
- Typical first session:
36
+ ### CLI
51
37
 
52
38
  ```text
53
- $ longeragent
54
- You: audit the auth flow and find dead code
55
- You: while you do that, also check whether password reset uses the same token path
56
- You: /summarize keep the final findings and file references
39
+ longeragent # Start with auto-detected config
40
+ longeragent init # Run setup wizard
41
+ longeragent oauth # Log in to OpenAI via OAuth (device code / browser)
42
+ longeragent oauth status # Check OAuth login status
43
+ longeragent oauth logout # Log out
44
+ longeragent --templates <path> # Use a specific templates directory
45
+ longeragent --verbose # Enable debug logging
46
+ longeragent --version # Show the current version
57
47
  ```
58
48
 
59
- Useful early commands:
49
+ ### Commands
60
50
 
61
- ```text
62
- /model # switch model/provider; can import or paste missing keys
63
- /mcp # connect configured MCP servers and list discovered tools
64
- /thinking # raise or lower reasoning depth
65
- /skills # enable or disable installed skills
66
- /resume # reopen an older session from log
67
- ```
51
+ | Command | Description |
52
+ |---------|-------------|
53
+ | `/model` | Switch between configured models at runtime; can prompt for missing managed-provider keys |
54
+ | `/mcp` | Connect configured MCP servers on demand and list discovered tools |
55
+ | `/thinking` | Control thinking/reasoning depth per model |
56
+ | `/skills` | Enable/disable skills with a checkbox picker |
57
+ | `/resume` | Resume a previous session from its log |
58
+ | `/summarize` | Summarize older context segments to free up space |
59
+ | `/compact` | Full context reset with a continuation summary |
68
60
 
69
- > **Safety:** LongerAgent does not sandbox shell commands or file edits. Run it in trusted environments and review what it does.
61
+ ---
70
62
 
71
- ## Demo
63
+ ## The Design Ideas
72
64
 
73
- Parallel sub-agents investigating a codebase, an async message mid-task, and context summarization — all in one session.
65
+ ### Agent-Driven Context Management
74
66
 
75
- https://github.com/user-attachments/assets/377fe648-d43c-45da-b111-9434b2a0dc61
67
+ LongerAgent gives the agent tools to inspect its own context distribution (`show_context`) and surgically compress what it chooses (`summarize_context`). Each conversation segment is internally tagged with a unique ID and a token-cost annotation, so the agent can make rational cost-benefit decisions about what to keep and what to compress. The system only steps in as a last-resort safety net.
76
68
 
77
- ---
69
+ Three layers work together: hint compression nudges the agent early, agent-initiated summarization gives it precise control, and auto-compact catches anything that slips through.
78
70
 
79
- ## Highlights
71
+ ### Parallel Sub-Agents
72
+
73
+ Instead of doing everything sequentially, the agent can spawn sub-agents — each with its own context window and tool access — to explore or execute in parallel. Three built-in templates (`main`, `explorer`, `executor`) scope what each sub-agent can do. Results are delivered back to the main agent for synthesis.
74
+
75
+ ### Interruptible Execution
76
+
77
+ You can type a message at any time — even while the agent is mid-task. Messages are queued and delivered at the next activation boundary. No need to wait, no need to restart.
78
+
79
+ ### Persistent Memory
80
80
 
81
- - **Three-layer context management** hinting, surgical summarization, and full compaction
82
- - **Parallel sub-agents** — spawn workers from chat or YAML call files
83
- - **Skills system** — install, manage, and create reusable skill packages from inside the agent
84
- - **Persistent memory** — `AGENTS.md` files and Important Log survive across sessions and compactions
85
- - **Async messaging** — talk to the agent while it's mid-task
86
- - **10 providers** — Anthropic, OpenAI, Kimi, MiniMax, GLM, Ollama, oMLX, LM Studio, OpenRouter, and more
81
+ Two `AGENTS.md` files (global and project-level) and an Important Log survive across sessions and context resets. The agent reads them for continuity and writes to them to save long-term knowledge.
87
82
 
88
83
  ## What It Feels Like
89
84
 
@@ -94,80 +89,19 @@ LongerAgent is optimized for a specific workflow:
94
89
  3. Interrupt it with clarifications or side requests without losing momentum.
95
90
  4. Keep the session alive by summarizing or compacting instead of restarting from scratch.
96
91
 
97
- That combination is the core product, more than any individual slash command or tool.
98
-
99
- ## Usage
100
-
101
- ### Context Management
102
-
103
- The agent manages its own context automatically, but you can also intervene:
104
-
105
- ```text
106
- /summarize # Summarize older context segments
107
- /summarize Keep the auth refactor details # Summarize with specific instructions
108
- /compact # Full context reset with continuation summary
109
- /compact Preserve the DB schema decisions # Compact with specific instructions
110
- ```
111
-
112
- `/summarize` surgically compresses selected segments while preserving key decisions — use it when context is growing but you're not ready for a full reset. `/compact` is the nuclear option: full reset with a continuation summary so the agent picks up where it left off.
113
-
114
- The agent can also do both on its own via `show_context` and `summarize_context` tools — no user action needed.
115
-
116
- An **Important Log** is maintained throughout the session — key discoveries, failed approaches, and architectural decisions are written here and survive every compaction.
117
-
118
- ### Sub-Agents
119
-
120
- Tell the agent to spawn sub-agents, or define tasks in a YAML call file:
92
+ That combination is the core of the demo, more than any individual slash command or tool.
121
93
 
122
- ```yaml
123
- # tasks.yaml
124
- tasks:
125
- - name: research
126
- template: explorer
127
- prompt: "Investigate how authentication works in this codebase"
128
- - name: refactor
129
- template: executor
130
- prompt: "Rename all legacy API endpoints to v2"
131
- ```
132
-
133
- Three built-in templates: **main** (full tools), **explorer** (read-only), **executor** (task-focused). Sub-agents run concurrently and report back when done.
134
-
135
- ### Skills
136
-
137
- Skills are reusable tool definitions the agent can load on demand.
138
-
139
- ```text
140
- You: "Install skill: apple-notes" # Agent uses built-in skill-manager
141
- You: /skills # Toggle skills on/off with a picker
142
- ```
143
-
144
- Create your own by adding a `SKILL.md` to `~/.longeragent/skills/<name>/`.
145
-
146
- ### Persistent Memory
147
-
148
- Two `AGENTS.md` files are loaded on every turn:
149
-
150
- - **`~/AGENTS.md`** — Global preferences across all projects
151
- - **`<project>/AGENTS.md`** — Project-specific patterns and architecture notes
94
+ ## Read More
152
95
 
153
- The agent reads them for context and can write to them to save long-term knowledge. These persist across sessions and context resets.
96
+ - **[Design Philosophy Deep-Dive](https://felixruigao.hashnode.dev/exploring-agent-autonomy-building-a-coding-cli-that-manages-its-own-context)** the ideas behind this demo in detail
97
+ - **[Documentation Site](https://felixruigao.github.io/LongerAgent/)** — full guides on context management, sub-agents, skills, providers, and more
154
98
 
155
- ### Async Messaging
156
-
157
- Type messages at any time — even while the agent is working. Messages are queued and delivered at the next activation boundary.
99
+ ---
158
100
 
159
101
  <details>
160
- <summary><strong>How context management works (details)</strong></summary>
161
-
162
- Three layers work together to keep context under control:
163
-
164
- 1. **Hint Compression** — As context grows, the system prompts the agent to proactively summarize older segments
165
- 2. **Agent-Initiated Summarization** — The agent inspects its own context distribution via `show_context` and surgically compresses selected segments with `summarize_context`, preserving key decisions and unresolved issues
166
- 3. **Auto-Compact** — Near the limit, the system performs a full context reset with a continuation summary — the agent picks up exactly where it left off
167
-
168
- </details>
102
+ <summary><strong>Reference</strong></summary>
169
103
 
170
- ## Supported Providers
104
+ ### Supported Providers
171
105
 
172
106
  | Provider | Models | Auth |
173
107
  |----------|--------|-------------|
@@ -183,11 +117,11 @@ Three layers work together to keep context under control:
183
117
 
184
118
  > \* **Kimi Coding Plan note:** The `kimi-code` endpoint (`api.kimi.com/coding/v1`) is currently restricted by Moonshot to whitelisted agents. You may receive a `403 Kimi For Coding is currently only available for Coding Agents` error. Use `kimi` or `kimi-cn` (standard API) instead.
185
119
 
186
- ## Tools
120
+ ### Tools
187
121
 
188
- **15 built-in tools:**
122
+ **16 built-in tools:**
189
123
 
190
- `read_file` · `list_dir` · `glob` · `grep` · `edit_file` · `write_file` · `apply_patch` · `bash` · `bash_background` · `bash_output` · `kill_shell` · `diff` · `test` · `web_search` · `web_fetch`
124
+ `read_file` · `list_dir` · `glob` · `grep` · `edit_file` · `write_file` · `apply_patch` · `bash` · `bash_background` · `bash_output` · `kill_shell` · `diff` · `test` · `time` · `web_search` · `web_fetch`
191
125
 
192
126
  `read_file` supports image files (PNG, JPG, GIF, WebP, etc.) on multimodal models — the agent can directly see and analyze images.
193
127
 
@@ -199,22 +133,7 @@ Three layers work together to keep context under control:
199
133
 
200
134
  **MCP Integration** — Connect to Model Context Protocol servers for additional tools. Use `/mcp` to verify configured servers and inspect discovered tools before your first turn.
201
135
 
202
- ## Slash Commands
203
-
204
- | Command | Description |
205
- |---------|-------------|
206
- | `/model` | Switch between configured models at runtime; can prompt for missing managed-provider keys |
207
- | `/mcp` | Connect configured MCP servers on demand and list discovered tools |
208
- | `/thinking` | Control thinking/reasoning depth per model |
209
- | `/skills` | Enable/disable skills with a checkbox picker |
210
- | `/resume` | Resume a previous session from its log |
211
- | `/summarize` | Summarize older context segments to free up space |
212
- | `/compact` | Full context reset with a continuation summary |
213
-
214
- ## Configuration
215
-
216
- LongerAgent loads bundled defaults from the installed package and user overrides from `~/.longeragent/`.
217
- `longeragent init` creates and updates the LongerAgent home directory, including managed API-key slots in `~/.longeragent/.env`.
136
+ ### Configuration
218
137
 
219
138
  ```text
220
139
  ~/.longeragent/
@@ -227,7 +146,7 @@ LongerAgent loads bundled defaults from the installed package and user overrides
227
146
  └── prompts/ # User prompt overrides
228
147
  ```
229
148
 
230
- ## Architecture
149
+ ### Architecture
231
150
 
232
151
  LongerAgent is built around a **Session → Agent → Provider** pipeline:
233
152
 
@@ -236,20 +155,10 @@ LongerAgent is built around a **Session → Agent → Provider** pipeline:
236
155
  - **Agent** wraps a model + system prompt + tools into a reusable execution unit
237
156
  - **Provider** adapters normalize streaming, reasoning, tool calls, and usage across 10 providers
238
157
 
239
- ## CLI Options
240
-
241
- ```text
242
- longeragent # Start with auto-detected config
243
- longeragent --version # Show the current version
244
- longeragent init # Run setup wizard
245
- longeragent oauth # Log in to OpenAI via OAuth (device code / browser)
246
- longeragent oauth status # Check OAuth login status
247
- longeragent oauth logout # Log out
248
- longeragent --templates <path> # Use a specific templates directory
249
- longeragent --verbose # Enable debug logging
250
- ```
158
+ </details>
251
159
 
252
- ## Development
160
+ <details>
161
+ <summary><strong>Development</strong></summary>
253
162
 
254
163
  ```bash
255
164
  pnpm install # Install dependencies
@@ -259,9 +168,7 @@ pnpm test # Run tests (vitest)
259
168
  pnpm typecheck # Type check
260
169
  ```
261
170
 
262
- ## Security
263
-
264
- LongerAgent does not sandbox commands or require approval before file edits and shell execution. Use it in trusted environments and review what it does.
171
+ </details>
265
172
 
266
173
  ## License
267
174
 
package/README.zh-CN.md CHANGED
@@ -2,7 +2,7 @@
2
2
  <img src="https://raw.githubusercontent.com/FelixRuiGao/LongerAgent/main/assets/logo.png" alt="LongerAgent" width="360" />
3
3
  </p>
4
4
  <p align="center">
5
- <strong>Built to work longer.</strong>
5
+ <strong>探索 Agent 自治。</strong>
6
6
  </p>
7
7
  <p align="center">
8
8
  <a href="./README.md">English</a> | 中文
@@ -13,77 +13,72 @@
13
13
  <img alt="Author" src="https://img.shields.io/badge/author-Felix%20Rui%20Gao-4b4bf0?style=flat-square" />
14
14
  </p>
15
15
 
16
- 一个能主动管理自身上下文、运行并行子 Agent、并允许你在工作中随时发送消息的终端 AI 编程助手。
16
+ LongerAgent 是一个 TUI Demo,探索一种设计哲学:如果系统只提供工具和安全兜底,让 Agent 主动管理自己的上下文和工作流,会怎样?
17
17
 
18
- ![LongerAgent Terminal UI](https://raw.githubusercontent.com/FelixRuiGao/LongerAgent/main/assets/screenshot.png)
18
+ 并行子 Agent 调查代码架构、运行中发送异步消息、上下文压缩——一个会话内完成:
19
19
 
20
- > **平台:** macOS。
21
-
22
- ## 为什么是 LongerAgent
23
-
24
- 很多 Coding Agent 在短任务里表现不错,但会话一长就开始失速。LongerAgent 是反过来设计的:
25
-
26
- - **长会话** —— 在上下文崩掉之前就监控、压缩、重置
27
- - **可打断执行** —— Agent 工作到一半时,你还能继续发消息
28
- - **并行执行** —— 同一会话里把探索和执行拆给多个子 Agent
29
- - **项目记忆** —— `AGENTS.md` 和 Important Log 跨会话、跨压缩保留
20
+ https://github.com/user-attachments/assets/377fe648-d43c-45da-b111-9434b2a0dc61
30
21
 
31
- 如果你想要的是一个真正适合长时间重构、排查、迭代执行的终端 Agent,这就是它的设计目标。
22
+ ---
32
23
 
33
- ## 快速开始
24
+ ## 试一试
34
25
 
35
26
  ```bash
36
- # 全局安装
37
27
  npm install -g longer-agent
38
-
39
- # 运行配置向导
40
28
  longeragent init
41
-
42
- # 启动
43
29
  longeragent
44
30
  ```
45
31
 
46
- 初始化向导会引导你完成 provider 选择、API key 配置和模型选择。所有配置保存在 `~/.longeragent/tui-preferences.json`。对 GLM、Kimi、MiniMax,LongerAgent 会把 endpoint 独立的 key 存进自己管理的 `~/.longeragent/.env` 槽位里,并在 `init` 或 `/model` 时导入检测到的外部环境变量。对 OpenAI(ChatGPT Login),OAuth token 保存在 `~/.longeragent/auth.json`,运行时不需要 API key 环境变量。
32
+ 配置向导会引导你完成 provider 选择(AnthropicOpenAI、Kimi、MiniMax、GLM、Ollama、oMLX、LM Studio、OpenRouter)和模型选择。
47
33
 
48
- ### 5 分钟
34
+ > **平台:** macOS。 **安全提示:** LongerAgent 不对 shell 命令或文件编辑做沙箱隔离。请在可信环境中使用,并留意它的实际操作。
49
35
 
50
- 一个典型的首次会话会是这样:
36
+ ### CLI
51
37
 
52
38
  ```text
53
- $ longeragent
54
- 你:检查一下认证流程,顺便找出死代码
55
- 你:另外也看看 password reset 是否复用了同一条 token 路径
56
- 你:/summarize 保留最终结论和文件引用
39
+ longeragent # 使用自动检测的配置启动
40
+ longeragent init # 运行配置向导
41
+ longeragent oauth # 通过 OAuth 登录 OpenAI(设备码 / 浏览器)
42
+ longeragent oauth status # 查看 OAuth 登录状态
43
+ longeragent oauth logout # 登出
44
+ longeragent --templates <path> # 使用指定模板目录
45
+ longeragent --verbose # 启用调试日志
46
+ longeragent --version # 显示当前版本
57
47
  ```
58
48
 
59
- 前期最常用的几个命令:
49
+ ### 命令
60
50
 
61
- ```text
62
- /model # 切换模型/provider;缺 key 时可直接导入或粘贴
63
- /mcp # 连接已配置的 MCP server 并列出发现的工具
64
- /thinking # 调高或调低推理深度
65
- /skills # 启用或禁用已安装技能
66
- /resume # 从日志恢复旧会话
67
- ```
51
+ | 命令 | 说明 |
52
+ |------|------|
53
+ | `/model` | 运行时切换已配置的模型;可为托管 provider 补 key |
54
+ | `/mcp` | 按需连接已配置的 MCP server 并列出已发现工具 |
55
+ | `/thinking` | 控制每个模型的思考/推理深度 |
56
+ | `/skills` | 勾选启用/禁用技能 |
57
+ | `/resume` | 从日志恢复之前的会话 |
58
+ | `/summarize` | 压缩较早的上下文片段以释放空间 |
59
+ | `/compact` | 全量上下文重置,附带延续摘要 |
68
60
 
69
- > **安全提示:** LongerAgent 不会对 shell 命令或文件编辑做沙箱隔离。请只在可信环境中使用,并留意它的实际操作。
61
+ ---
70
62
 
71
- ## 演示
63
+ ## 设计理念
72
64
 
73
- 并行子 Agent 调查代码架构、运行中发送异步消息、上下文压缩——一个会话内完成。
65
+ ### Agent 驱动的上下文管理
74
66
 
75
- https://github.com/user-attachments/assets/377fe648-d43c-45da-b111-9434b2a0dc61
67
+ LongerAgent 给 Agent 提供工具来检视自身上下文分布(`show_context`)并精确压缩它自己选择的部分(`summarize_context`)。每个对话片段内部都标记了唯一 ID 和 token 成本注解,让 Agent 能做出理性的成本收益决策。系统只在最后关头作为安全兜底介入。
76
68
 
77
- ---
69
+ 三层机制协同工作:提示压缩在早期推动 Agent 主动压缩,Agent 主导的精确压缩给予它精细控制,自动 compact 兜住漏网之鱼。
78
70
 
79
- ## 亮点
71
+ ### 并行子 Agent
72
+
73
+ Agent 不必按顺序做所有事,它可以 spawn 子 Agent——每个拥有独立的上下文窗口和工具访问权——并行探索或执行。三个内置模板(`main`、`explorer`、`executor`)限定每个子 Agent 的能力范围。结果汇报给主 Agent 进行综合。
74
+
75
+ ### 可打断执行
76
+
77
+ 你可以随时输入消息——即使 Agent 正在执行任务。消息排队等待,在下一个激活边界送达。不用等,不用重开。
78
+
79
+ ### 持久记忆
80
80
 
81
- - **三层上下文管理** —— 提示、精确压缩、全量 compact 三层协作
82
- - **并行子 Agent** —— 可在对话里或通过 YAML 调用文件派发任务
83
- - **Skills 系统** —— 直接在 Agent 内安装、管理、创建可复用技能包
84
- - **持久记忆** —— `AGENTS.md` 和 Important Log 跨会话、跨压缩存续
85
- - **异步消息** —— Agent 工作中随时发送消息,不用等它完成
86
- - **10 大 Provider** —— Anthropic、OpenAI、Kimi、MiniMax、GLM、Ollama、oMLX、LM Studio、OpenRouter 等
81
+ 两个 `AGENTS.md` 文件(全局和项目级)以及 Important Log 跨会话、跨上下文重置保留。Agent 读取它们维持连续性,也写入它们保存长期知识。
87
82
 
88
83
  ## 实际使用感受
89
84
 
@@ -94,80 +89,19 @@ LongerAgent 重点优化的是这样一条工作流:
94
89
  3. 中途随时插话补充要求,不需要重新开局。
95
90
  4. 通过 summarize 或 compact 维持会话寿命,而不是上下文一满就从头再来。
96
91
 
97
- 这个组合本身,才是 LongerAgent 的核心价值,而不只是某一个命令或工具。
98
-
99
- ## 使用
100
-
101
- ### 上下文管理
102
-
103
- Agent 会自动管理上下文,你也可以手动介入:
104
-
105
- ```text
106
- /summarize # 压缩较早的上下文片段
107
- /summarize 保留认证重构的细节 # 带指令的压缩
108
- /compact # 全量上下文重置,附带延续摘要
109
- /compact 保留数据库 Schema 的决策 # 带指令的重置
110
- ```
111
-
112
- `/summarize` 会精确压缩选定的片段,同时保留关键决策——适合上下文在增长但还不需要全量重置的时候。`/compact` 是终极手段:全量重置,生成延续摘要,Agent 从中断处继续。
113
-
114
- Agent 也可以通过 `show_context` 和 `summarize_context` 工具自主完成以上操作——无需用户干预。
115
-
116
- 会话全程维护一份 **Important Log**——关键发现、失败的尝试、架构决策都会写入其中,在每次压缩后依然保留。
117
-
118
- ### 子 Agent
119
-
120
- 让 Agent 自行 spawn 子 Agent,或通过 YAML 调用文件定义任务:
92
+ 这个组合本身,才是 Demo 的核心,而不只是某一个命令或工具。
121
93
 
122
- ```yaml
123
- # tasks.yaml
124
- tasks:
125
- - name: research
126
- template: explorer
127
- prompt: "调查这个代码库中认证模块的工作方式"
128
- - name: refactor
129
- template: executor
130
- prompt: "将所有旧版 API 端点重命名为 v2"
131
- ```
132
-
133
- 三个内置模板:**main**(全部工具)、**explorer**(只读)、**executor**(任务执行)。子 Agent 并发运行,完成后汇报结果。
134
-
135
- ### Skills
136
-
137
- Skills 是可按需加载的可复用工具定义。
138
-
139
- ```text
140
- 你: "安装 skill: apple-notes" # Agent 使用内置 skill-manager
141
- 你: /skills # 勾选启用/禁用
142
- ```
143
-
144
- 自定义 skill:在 `~/.longeragent/skills/<name>/` 下添加 `SKILL.md` 即可。
145
-
146
- ### 持久记忆
147
-
148
- 每轮对话自动加载两个 `AGENTS.md` 文件:
149
-
150
- - **`~/AGENTS.md`** —— 所有项目通用的全局偏好
151
- - **`<project>/AGENTS.md`** —— 项目级的架构笔记和模式
94
+ ## 进一步了解
152
95
 
153
- Agent 读取它们获取背景信息,也可以写入以保存长期知识。跨会话和上下文重置持久存在。
96
+ - **[设计哲学详解](https://felixruigao.hashnode.dev/exploring-agent-autonomy-building-a-coding-cli-that-manages-its-own-context)** —— 这个 Demo 背后的设计思考
97
+ - **[文档站](https://felixruigao.github.io/LongerAgent/)** —— 上下文管理、子 Agent、Skills、Provider 等完整指南
154
98
 
155
- ### 异步消息
156
-
157
- 随时输入消息——即使 Agent 正在工作。消息会排队,在下一个激活边界送达。
99
+ ---
158
100
 
159
101
  <details>
160
- <summary><strong>上下文管理机制详解</strong></summary>
161
-
162
- 三层机制协同工作,控制上下文:
163
-
164
- 1. **提示压缩** —— 随着上下文增长,系统提示 Agent 主动压缩较早的片段
165
- 2. **Agent 主导的压缩** —— Agent 通过 `show_context` 检查上下文分布,用 `summarize_context` 精确压缩选定片段,保留关键决策和未解决的问题
166
- 3. **自动压缩** —— 接近上限时,系统执行全量上下文重置并生成延续摘要——Agent 从中断处继续
167
-
168
- </details>
102
+ <summary><strong>参考</strong></summary>
169
103
 
170
- ## 支持的 Provider
104
+ ### 支持的 Provider
171
105
 
172
106
  | Provider | 模型 | 鉴权方式 |
173
107
  |----------|------|----------|
@@ -183,11 +117,11 @@ Agent 读取它们获取背景信息,也可以写入以保存长期知识。
183
117
 
184
118
  > \* **Kimi Coding Plan 说明:** `kimi-code` 端点(`api.kimi.com/coding/v1`)目前被 Moonshot 限制为白名单 Agent,可能会收到 `403 Kimi For Coding is currently only available for Coding Agents` 错误。请改用 `kimi` 或 `kimi-cn`(标准 API)。
185
119
 
186
- ## 工具
120
+ ### 工具
187
121
 
188
- **15 个内置工具:**
122
+ **16 个内置工具:**
189
123
 
190
- `read_file` · `list_dir` · `glob` · `grep` · `edit_file` · `write_file` · `apply_patch` · `bash` · `bash_background` · `bash_output` · `kill_shell` · `diff` · `test` · `web_search` · `web_fetch`
124
+ `read_file` · `list_dir` · `glob` · `grep` · `edit_file` · `write_file` · `apply_patch` · `bash` · `bash_background` · `bash_output` · `kill_shell` · `diff` · `test` · `time` · `web_search` · `web_fetch`
191
125
 
192
126
  `read_file` 在多模态模型上支持图片文件(PNG、JPG、GIF、WebP 等)——Agent 可以直接查看和分析图片。
193
127
 
@@ -199,22 +133,7 @@ Agent 读取它们获取背景信息,也可以写入以保存长期知识。
199
133
 
200
134
  **MCP 集成** —— 连接 Model Context Protocol 服务器以扩展工具。可用 `/mcp` 在第一轮对话前主动验证 server 配置并查看工具列表。
201
135
 
202
- ## 斜杠命令
203
-
204
- | 命令 | 说明 |
205
- |------|------|
206
- | `/model` | 运行时切换已配置的模型;可为托管 provider 补 key |
207
- | `/mcp` | 按需连接已配置的 MCP server 并列出已发现工具 |
208
- | `/thinking` | 控制每个模型的思考/推理深度 |
209
- | `/skills` | 勾选启用/禁用技能 |
210
- | `/resume` | 从日志恢复之前的会话 |
211
- | `/summarize` | 压缩较早的上下文片段以释放空间 |
212
- | `/compact` | 全量上下文重置,附带延续摘要 |
213
-
214
- ## 配置
215
-
216
- LongerAgent 从安装包加载内置默认值,从 `~/.longeragent/` 加载用户覆盖。
217
- `longeragent init` 会引导完成配置并更新 `~/.longeragent/.env` 里的托管 provider key 槽位。
136
+ ### 配置
218
137
 
219
138
  ```text
220
139
  ~/.longeragent/
@@ -227,29 +146,19 @@ LongerAgent 从安装包加载内置默认值,从 `~/.longeragent/` 加载用
227
146
  └── prompts/ # 用户 Prompt 覆盖
228
147
  ```
229
148
 
230
- ## 架构
149
+ ### 架构
231
150
 
232
151
  LongerAgent 围绕 **Session → Agent → Provider** 流水线构建:
233
152
 
234
153
  - **Session** 编排 turn 循环、消息投递、压缩、子 Agent 生命周期
235
154
  - **Session Log** 是唯一事实来源——20+ 种条目类型记录所有运行时事件;TUI 显示和 Provider 输入都是同一数据的投影
236
155
  - **Agent** 将模型 + 系统 Prompt + 工具封装为可复用的执行单元
237
- - **Provider** 适配器在 7 个 Provider 家族间统一流式输出、推理、工具调用和用量
238
-
239
- ## CLI 选项
156
+ - **Provider** 适配器在 10 个 Provider 间统一流式输出、推理、工具调用和用量
240
157
 
241
- ```text
242
- longeragent # 使用自动检测的配置启动
243
- longeragent --version # 显示当前版本
244
- longeragent init # 运行配置向导
245
- longeragent oauth # 通过 OAuth 登录 OpenAI(设备码 / 浏览器)
246
- longeragent oauth status # 查看 OAuth 登录状态
247
- longeragent oauth logout # 登出
248
- longeragent --templates <path> # 使用指定模板目录
249
- longeragent --verbose # 启用调试日志
250
- ```
158
+ </details>
251
159
 
252
- ## 开发
160
+ <details>
161
+ <summary><strong>开发</strong></summary>
253
162
 
254
163
  ```bash
255
164
  pnpm install # 安装依赖
@@ -259,9 +168,7 @@ pnpm test # 运行测试(vitest)
259
168
  pnpm typecheck # 类型检查
260
169
  ```
261
170
 
262
- ## 安全
263
-
264
- LongerAgent 不对命令做沙盒隔离,也不会在文件编辑和 Shell 执行前要求审批。请在可信环境中使用,并留意它的操作。
171
+ </details>
265
172
 
266
173
  ## 许可证
267
174
 
@@ -16,6 +16,7 @@ tools:
16
16
  - bash_output
17
17
  - kill_shell
18
18
  - test
19
+ - time
19
20
  - web_search
20
21
  - web_fetch
21
22
  prompt_sections: [important_log, agents_md]
@@ -1,4 +1,4 @@
1
- You are a task execution agent of LongerAgent, developed by Felix Rui Gao. Your role is to execute bounded tasks with side effects — running tests, making edits, installing dependencies, generating files — and report the results clearly.
1
+ You are a task execution agent of LongerAgent. Your role is to execute bounded tasks with side effects — running tests, making edits, installing dependencies, generating files — and report the results clearly.
2
2
 
3
3
  Your working directory is {PROJECT_ROOT}.
4
4
 
@@ -7,6 +7,7 @@ tools:
7
7
  - list_dir
8
8
  - grep
9
9
  - glob
10
+ - time
10
11
  - web_search
11
12
  - web_fetch
12
13
  prompt_sections: [important_log, agents_md]
@@ -1,4 +1,4 @@
1
- You are an exploration agent of LongerAgent, developed by Felix Rui Gao. Your role is to read and analyze files, directories, and external resources as instructed, then return a clear, structured summary.
1
+ You are an exploration agent of LongerAgent. Your role is to read and analyze files, directories, and external resources as instructed, then return a clear, structured summary.
2
2
 
3
3
  Your working directory is {PROJECT_ROOT}.
4
4
 
@@ -1,4 +1,4 @@
1
- You are the Primary Agent of LongerAgent, an autonomous AI coding agent. You work in an interactive CLI environment, handling coding, debugging, review, architecture, exploration, and planning. You work directly with tools: reading files, writing code, running tests, searching codebases, and orchestrating sub-agents for parallel work.
1
+ You are LongerAgent, an autonomous coding agent that operates in the terminal. You have full access to the filesystem, shell, and web — you do the work yourself, not describe it. You are built for sustained, deep work: managing your own context through active summarization, delegating exploration to parallel sub-agents, and maintaining persistent notes that survive context resets.
2
2
 
3
3
  ## Tone and Output
4
4
 
@@ -37,9 +37,10 @@ When you discover something that should be addressed but wasn't requested, menti
37
37
  2. **Keep a notebook.** Maintain your important log as a persistent engineering notebook. Record key discoveries, decisions, and failed approaches. It survives context resets and compactions — always visible after your system prompt.
38
38
  3. **Guard your context window.** Every token costs. Proactively compress with `summarize_context` and preserve cross-reset knowledge in your important log.
39
39
  4. **Delegate exploration aggressively.** You are the orchestrator — focus on high-level reasoning, planning, and executing changes. Delegate all codebase exploration, dependency analysis, pattern searches, and information gathering to sub-agents. Your context window is too valuable for bulk reading; sub-agents work in separate contexts at no cost to yours.
40
+ 5. **Plan before you build.** For non-trivial tasks, create a tracked plan before writing code. It keeps you oriented across context resets and shows the user your progress.
40
41
 
41
42
  ## Path Variables
42
43
 
43
44
  - **`{PROJECT_ROOT}`** — Target project directory. Read/write project source files here.
44
- - **`{SESSION_ARTIFACTS}`** — Session-local storage for call files, scratch files, plan files, and custom sub-agent templates. Located outside `{PROJECT_ROOT}` (under `~/.longeragent/`). Does not persist across sessions. Always use absolute paths with this variable — do not assume any relative relationship to `{PROJECT_ROOT}`.
45
+ - **`{SESSION_ARTIFACTS}`** — Session-local storage for call files, scratch files, and custom sub-agent templates. Located outside `{PROJECT_ROOT}` (under `~/.longeragent/`). Does not persist across sessions. Always use absolute paths with this variable — do not assume any relative relationship to `{PROJECT_ROOT}`.
45
46
  - **`{SYSTEM_DATA}`** — Cross-session persistent storage. Managed by the system; do not access directly.