longer-agent 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +227 -0
- package/README.zh-CN.md +227 -0
- package/agent_templates/executor/agent.yaml +22 -0
- package/agent_templates/executor/system_prompt.md +17 -0
- package/agent_templates/explorer/agent.yaml +13 -0
- package/agent_templates/explorer/system_prompt.md +19 -0
- package/agent_templates/main/agent.yaml +7 -0
- package/agent_templates/main/system_prompt.md +45 -0
- package/configExample.yaml +83 -0
- package/dist/agents/agent.d.ts +79 -0
- package/dist/agents/agent.d.ts.map +1 -0
- package/dist/agents/agent.js +156 -0
- package/dist/agents/agent.js.map +1 -0
- package/dist/agents/tool-loop.d.ts +140 -0
- package/dist/agents/tool-loop.d.ts.map +1 -0
- package/dist/agents/tool-loop.js +465 -0
- package/dist/agents/tool-loop.js.map +1 -0
- package/dist/ask.d.ts +81 -0
- package/dist/ask.d.ts.map +1 -0
- package/dist/ask.js +34 -0
- package/dist/ask.js.map +1 -0
- package/dist/auth/openai-oauth.d.ts +66 -0
- package/dist/auth/openai-oauth.d.ts.map +1 -0
- package/dist/auth/openai-oauth.js +640 -0
- package/dist/auth/openai-oauth.js.map +1 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +254 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands.d.ts +118 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +862 -0
- package/dist/commands.js.map +1 -0
- package/dist/config.d.ts +130 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +648 -0
- package/dist/config.js.map +1 -0
- package/dist/context-rendering.d.ts +69 -0
- package/dist/context-rendering.d.ts.map +1 -0
- package/dist/context-rendering.js +250 -0
- package/dist/context-rendering.js.map +1 -0
- package/dist/document-projection.d.ts +12 -0
- package/dist/document-projection.d.ts.map +1 -0
- package/dist/document-projection.js +75 -0
- package/dist/document-projection.js.map +1 -0
- package/dist/ephemeral-log.d.ts +15 -0
- package/dist/ephemeral-log.d.ts.map +1 -0
- package/dist/ephemeral-log.js +173 -0
- package/dist/ephemeral-log.js.map +1 -0
- package/dist/file-attach.d.ts +89 -0
- package/dist/file-attach.d.ts.map +1 -0
- package/dist/file-attach.js +571 -0
- package/dist/file-attach.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/init-wizard.d.ts +13 -0
- package/dist/init-wizard.d.ts.map +1 -0
- package/dist/init-wizard.js +328 -0
- package/dist/init-wizard.js.map +1 -0
- package/dist/log-entry.d.ts +104 -0
- package/dist/log-entry.d.ts.map +1 -0
- package/dist/log-entry.js +292 -0
- package/dist/log-entry.js.map +1 -0
- package/dist/log-projection.d.ts +73 -0
- package/dist/log-projection.d.ts.map +1 -0
- package/dist/log-projection.js +651 -0
- package/dist/log-projection.js.map +1 -0
- package/dist/mcp-client.d.ts +55 -0
- package/dist/mcp-client.d.ts.map +1 -0
- package/dist/mcp-client.js +402 -0
- package/dist/mcp-client.js.map +1 -0
- package/dist/model-selection.d.ts +16 -0
- package/dist/model-selection.d.ts.map +1 -0
- package/dist/model-selection.js +181 -0
- package/dist/model-selection.js.map +1 -0
- package/dist/network-retry.d.ts +38 -0
- package/dist/network-retry.d.ts.map +1 -0
- package/dist/network-retry.js +140 -0
- package/dist/network-retry.js.map +1 -0
- package/dist/persistence.d.ts +104 -0
- package/dist/persistence.d.ts.map +1 -0
- package/dist/persistence.js +644 -0
- package/dist/persistence.js.map +1 -0
- package/dist/primitives/context.d.ts +29 -0
- package/dist/primitives/context.d.ts.map +1 -0
- package/dist/primitives/context.js +85 -0
- package/dist/primitives/context.js.map +1 -0
- package/dist/progress.d.ts +51 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +229 -0
- package/dist/progress.js.map +1 -0
- package/dist/provider-presets.d.ts +34 -0
- package/dist/provider-presets.d.ts.map +1 -0
- package/dist/provider-presets.js +181 -0
- package/dist/provider-presets.js.map +1 -0
- package/dist/providers/anthropic.d.ts +32 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +450 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/base.d.ts +135 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +104 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/glm.d.ts +18 -0
- package/dist/providers/glm.d.ts.map +1 -0
- package/dist/providers/glm.js +59 -0
- package/dist/providers/glm.js.map +1 -0
- package/dist/providers/kimi.d.ts +23 -0
- package/dist/providers/kimi.d.ts.map +1 -0
- package/dist/providers/kimi.js +89 -0
- package/dist/providers/kimi.js.map +1 -0
- package/dist/providers/minimax.d.ts +20 -0
- package/dist/providers/minimax.d.ts.map +1 -0
- package/dist/providers/minimax.js +192 -0
- package/dist/providers/minimax.js.map +1 -0
- package/dist/providers/openai-chat.d.ts +33 -0
- package/dist/providers/openai-chat.d.ts.map +1 -0
- package/dist/providers/openai-chat.js +543 -0
- package/dist/providers/openai-chat.js.map +1 -0
- package/dist/providers/openai-responses.d.ts +26 -0
- package/dist/providers/openai-responses.d.ts.map +1 -0
- package/dist/providers/openai-responses.js +443 -0
- package/dist/providers/openai-responses.js.map +1 -0
- package/dist/providers/openrouter.d.ts +24 -0
- package/dist/providers/openrouter.d.ts.map +1 -0
- package/dist/providers/openrouter.js +177 -0
- package/dist/providers/openrouter.js.map +1 -0
- package/dist/providers/registry.d.ts +7 -0
- package/dist/providers/registry.d.ts.map +1 -0
- package/dist/providers/registry.js +38 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/security/path.d.ts +51 -0
- package/dist/security/path.d.ts.map +1 -0
- package/dist/security/path.js +187 -0
- package/dist/security/path.js.map +1 -0
- package/dist/security/sensitive-files.d.ts +3 -0
- package/dist/security/sensitive-files.d.ts.map +1 -0
- package/dist/security/sensitive-files.js +41 -0
- package/dist/security/sensitive-files.js.map +1 -0
- package/dist/session.d.ts +446 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +4595 -0
- package/dist/session.js.map +1 -0
- package/dist/settings.d.ts +46 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +134 -0
- package/dist/settings.js.map +1 -0
- package/dist/show-context.d.ts +35 -0
- package/dist/show-context.d.ts.map +1 -0
- package/dist/show-context.js +320 -0
- package/dist/show-context.js.map +1 -0
- package/dist/skills/loader.d.ts +49 -0
- package/dist/skills/loader.d.ts.map +1 -0
- package/dist/skills/loader.js +166 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/summarize-context.d.ts +29 -0
- package/dist/summarize-context.d.ts.map +1 -0
- package/dist/summarize-context.js +247 -0
- package/dist/summarize-context.js.map +1 -0
- package/dist/templates/loader.d.ts +104 -0
- package/dist/templates/loader.d.ts.map +1 -0
- package/dist/templates/loader.js +514 -0
- package/dist/templates/loader.js.map +1 -0
- package/dist/tools/basic.d.ts +29 -0
- package/dist/tools/basic.d.ts.map +1 -0
- package/dist/tools/basic.js +2079 -0
- package/dist/tools/basic.js.map +1 -0
- package/dist/tools/comm.d.ts +17 -0
- package/dist/tools/comm.d.ts.map +1 -0
- package/dist/tools/comm.js +192 -0
- package/dist/tools/comm.js.map +1 -0
- package/dist/tools/web-fetch.d.ts +11 -0
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +237 -0
- package/dist/tools/web-fetch.js.map +1 -0
- package/dist/tools/web-search.d.ts +24 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +51 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tui/app.d.ts +35 -0
- package/dist/tui/app.d.ts.map +1 -0
- package/dist/tui/app.js +1042 -0
- package/dist/tui/app.js.map +1 -0
- package/dist/tui/checkbox-picker.d.ts +35 -0
- package/dist/tui/checkbox-picker.d.ts.map +1 -0
- package/dist/tui/checkbox-picker.js +85 -0
- package/dist/tui/checkbox-picker.js.map +1 -0
- package/dist/tui/command-picker.d.ts +31 -0
- package/dist/tui/command-picker.d.ts.map +1 -0
- package/dist/tui/command-picker.js +113 -0
- package/dist/tui/command-picker.js.map +1 -0
- package/dist/tui/components/ask-panel.d.ts +21 -0
- package/dist/tui/components/ask-panel.d.ts.map +1 -0
- package/dist/tui/components/ask-panel.js +81 -0
- package/dist/tui/components/ask-panel.js.map +1 -0
- package/dist/tui/components/conversation-panel.d.ts +68 -0
- package/dist/tui/components/conversation-panel.d.ts.map +1 -0
- package/dist/tui/components/conversation-panel.js +611 -0
- package/dist/tui/components/conversation-panel.js.map +1 -0
- package/dist/tui/components/input-panel.d.ts +27 -0
- package/dist/tui/components/input-panel.d.ts.map +1 -0
- package/dist/tui/components/input-panel.js +725 -0
- package/dist/tui/components/input-panel.js.map +1 -0
- package/dist/tui/components/logo-panel.d.ts +14 -0
- package/dist/tui/components/logo-panel.d.ts.map +1 -0
- package/dist/tui/components/logo-panel.js +37 -0
- package/dist/tui/components/logo-panel.js.map +1 -0
- package/dist/tui/components/plan-panel.d.ts +10 -0
- package/dist/tui/components/plan-panel.d.ts.map +1 -0
- package/dist/tui/components/plan-panel.js +8 -0
- package/dist/tui/components/plan-panel.js.map +1 -0
- package/dist/tui/components/status-bar.d.ts +24 -0
- package/dist/tui/components/status-bar.d.ts.map +1 -0
- package/dist/tui/components/status-bar.js +80 -0
- package/dist/tui/components/status-bar.js.map +1 -0
- package/dist/tui/input/editor-state.d.ts +22 -0
- package/dist/tui/input/editor-state.d.ts.map +1 -0
- package/dist/tui/input/editor-state.js +157 -0
- package/dist/tui/input/editor-state.js.map +1 -0
- package/dist/tui/input/keymap.d.ts +3 -0
- package/dist/tui/input/keymap.d.ts.map +1 -0
- package/dist/tui/input/keymap.js +72 -0
- package/dist/tui/input/keymap.js.map +1 -0
- package/dist/tui/input/paste-slots.d.ts +17 -0
- package/dist/tui/input/paste-slots.d.ts.map +1 -0
- package/dist/tui/input/paste-slots.js +46 -0
- package/dist/tui/input/paste-slots.js.map +1 -0
- package/dist/tui/input/paste.d.ts +15 -0
- package/dist/tui/input/paste.d.ts.map +1 -0
- package/dist/tui/input/paste.js +35 -0
- package/dist/tui/input/paste.js.map +1 -0
- package/dist/tui/input/protocol.d.ts +9 -0
- package/dist/tui/input/protocol.d.ts.map +1 -0
- package/dist/tui/input/protocol.js +387 -0
- package/dist/tui/input/protocol.js.map +1 -0
- package/dist/tui/input/sanitize.d.ts +6 -0
- package/dist/tui/input/sanitize.d.ts.map +1 -0
- package/dist/tui/input/sanitize.js +20 -0
- package/dist/tui/input/sanitize.js.map +1 -0
- package/dist/tui/input/types.d.ts +18 -0
- package/dist/tui/input/types.d.ts.map +1 -0
- package/dist/tui/input/types.js +2 -0
- package/dist/tui/input/types.js.map +1 -0
- package/dist/tui/launch.d.ts +23 -0
- package/dist/tui/launch.d.ts.map +1 -0
- package/dist/tui/launch.js +104 -0
- package/dist/tui/launch.js.map +1 -0
- package/dist/tui/theme.d.ts +20 -0
- package/dist/tui/theme.d.ts.map +1 -0
- package/dist/tui/theme.js +29 -0
- package/dist/tui/theme.js.map +1 -0
- package/dist/tui/types.d.ts +136 -0
- package/dist/tui/types.d.ts.map +1 -0
- package/dist/tui/types.js +9 -0
- package/dist/tui/types.js.map +1 -0
- package/package.json +76 -0
- package/prompts/sections/agents_md.md +23 -0
- package/prompts/sections/important_log.md +16 -0
- package/prompts/sections/system_mechanisms.md +18 -0
- package/prompts/tools/apply_patch.md +31 -0
- package/prompts/tools/ask.md +18 -0
- package/prompts/tools/bash.md +13 -0
- package/prompts/tools/bash_background.md +9 -0
- package/prompts/tools/bash_output.md +9 -0
- package/prompts/tools/check_status.md +3 -0
- package/prompts/tools/diff.md +5 -0
- package/prompts/tools/edit_file.md +11 -0
- package/prompts/tools/glob.md +7 -0
- package/prompts/tools/grep.md +20 -0
- package/prompts/tools/kill_agent.md +3 -0
- package/prompts/tools/kill_shell.md +5 -0
- package/prompts/tools/list_dir.md +5 -0
- package/prompts/tools/plan.md +252 -0
- package/prompts/tools/read_file.md +9 -0
- package/prompts/tools/show_context.md +12 -0
- package/prompts/tools/skill.md +7 -0
- package/prompts/tools/spawn_agent.md +195 -0
- package/prompts/tools/summarize_context.md +122 -0
- package/prompts/tools/test.md +5 -0
- package/prompts/tools/wait.md +17 -0
- package/prompts/tools/web_fetch.md +9 -0
- package/prompts/tools/web_search.md +5 -0
- package/prompts/tools/write_file.md +11 -0
- package/skills/.staging/.gitkeep +0 -0
- package/skills/explain-code/SKILL.md +15 -0
- package/skills/skill-manager/SKILL.md +83 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Felix Rui Gao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/FelixRuiGao/LongerAgent/main/assets/logo.png" alt="LongerAgent" width="360" />
|
|
3
|
+
</p>
|
|
4
|
+
<p align="center">
|
|
5
|
+
<strong>A terminal AI coding agent built for long sessions.</strong>
|
|
6
|
+
</p>
|
|
7
|
+
<p align="center">
|
|
8
|
+
English | <a href="./README.zh-CN.md">中文</a>
|
|
9
|
+
</p>
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="./LICENSE"><img alt="License" src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" /></a>
|
|
12
|
+
<img alt="Node" src="https://img.shields.io/badge/node-%3E%3D18-brightgreen?style=flat-square" />
|
|
13
|
+
<img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-5-blue?style=flat-square&logo=typescript&logoColor=white" />
|
|
14
|
+
<img alt="Author" src="https://img.shields.io/badge/author-Felix%20Rui%20Gao-4b4bf0?style=flat-square" />
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
Most AI agents crash, loop, or silently lose context when conversations get long. LongerAgent is built from the ground up for sessions that last longer — with a structured log architecture, three-layer context management, and persistent memory that survives across sessions.
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
https://github.com/user-attachments/assets/e405916d-f205-4995-b4b3-ce81b19af618
|
|
22
|
+
|
|
23
|
+
> **Platform:** macOS. Windows is not tested.
|
|
24
|
+
>
|
|
25
|
+
> **Security:** LongerAgent does not sandbox commands or require approval before file edits and shell execution. Use it in trusted environments and review what it does.
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Install globally
|
|
31
|
+
npm install -g longer-agent
|
|
32
|
+
|
|
33
|
+
# Run the setup wizard (creates ~/.longeragent/config.yaml)
|
|
34
|
+
longeragent init
|
|
35
|
+
|
|
36
|
+
# Start
|
|
37
|
+
longeragent
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Highlights
|
|
43
|
+
|
|
44
|
+
- **Three-layer context management** — sessions that last longer and longer
|
|
45
|
+
- **Parallel sub-agents** — spawn workers for concurrent tasks from YAML call files
|
|
46
|
+
- **Skills system** — install, manage, and create reusable skill packages by itself
|
|
47
|
+
- **Persistent memory** — `AGENTS.md` files and Important Log survive across sessions and compactions
|
|
48
|
+
- **Async messaging** — talk to the agent while it's mid-task
|
|
49
|
+
- **7 provider families** — Anthropic, OpenAI, Kimi, MiniMax, GLM, OpenRouter, and any OpenRouter-compatible model
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
### Context Management
|
|
54
|
+
|
|
55
|
+
The agent manages its own context automatically, but you can also intervene:
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
/summarize # Summarize older context segments
|
|
59
|
+
/summarize Keep the auth refactor details # Summarize with specific instructions
|
|
60
|
+
/compact # Full context reset with continuation summary
|
|
61
|
+
/compact Preserve the DB schema decisions # Compact with specific instructions
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`/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.
|
|
65
|
+
|
|
66
|
+
The agent can also do both on its own via `show_context` and `summarize_context` tools — no user action needed.
|
|
67
|
+
|
|
68
|
+
An **Important Log** is maintained throughout the session — key discoveries, failed approaches, and architectural decisions are written here and survive every compaction.
|
|
69
|
+
|
|
70
|
+
### Sub-Agents
|
|
71
|
+
|
|
72
|
+
Tell the agent to spawn sub-agents, or define tasks in a YAML call file:
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
# tasks.yaml
|
|
76
|
+
tasks:
|
|
77
|
+
- name: research
|
|
78
|
+
template: explorer
|
|
79
|
+
prompt: "Investigate how authentication works in this codebase"
|
|
80
|
+
- name: refactor
|
|
81
|
+
template: executor
|
|
82
|
+
prompt: "Rename all legacy API endpoints to v2"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Three built-in templates: **main** (full tools), **explorer** (read-only), **executor** (task-focused). Sub-agents run concurrently and report back when done.
|
|
86
|
+
|
|
87
|
+
### Skills
|
|
88
|
+
|
|
89
|
+
Skills are reusable tool definitions the agent can load on demand.
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
You: "Install skill: apple-notes" # Agent uses built-in skill-manager
|
|
93
|
+
You: /skills # Toggle skills on/off with a picker
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Create your own by adding a `SKILL.md` to `~/.longeragent/skills/<name>/`.
|
|
97
|
+
|
|
98
|
+
### Persistent Memory
|
|
99
|
+
|
|
100
|
+
Two `AGENTS.md` files are loaded on every turn:
|
|
101
|
+
|
|
102
|
+
- **`~/AGENTS.md`** — Global preferences across all projects
|
|
103
|
+
- **`<project>/AGENTS.md`** — Project-specific patterns and architecture notes
|
|
104
|
+
|
|
105
|
+
The agent reads them for context and can write to them to save long-term knowledge. These persist across sessions and context resets.
|
|
106
|
+
|
|
107
|
+
### Async Messaging
|
|
108
|
+
|
|
109
|
+
Type messages at any time — even while the agent is working. Messages are queued and delivered at the next activation boundary.
|
|
110
|
+
|
|
111
|
+
<details>
|
|
112
|
+
<summary><strong>How context management works (details)</strong></summary>
|
|
113
|
+
|
|
114
|
+
Three layers work together to keep context under control:
|
|
115
|
+
|
|
116
|
+
1. **Hint Compression** — As context grows, the system prompts the agent to proactively summarize older segments
|
|
117
|
+
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
|
|
118
|
+
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
|
|
119
|
+
|
|
120
|
+
</details>
|
|
121
|
+
|
|
122
|
+
## Supported Providers
|
|
123
|
+
|
|
124
|
+
| Provider | Models | Env Variable |
|
|
125
|
+
|----------|--------|-------------|
|
|
126
|
+
| **Anthropic** | Claude Haiku 4.5, Opus 4.6, Sonnet 4.6 (+ 1M context variants) | `ANTHROPIC_API_KEY` |
|
|
127
|
+
| **OpenAI** | GPT-5.2, GPT-5.2 Codex, GPT-5.3 Codex, GPT-5.4 | `OPENAI_API_KEY` or OAuth |
|
|
128
|
+
| **Kimi / Moonshot** | Kimi K2.5, K2 Instruct (Global, China, Coding Plan) | `KIMI_CN_API_KEY` / `KIMI_API_KEY` |
|
|
129
|
+
| **MiniMax** | M2.1, M2.5 (Global, China) | `MINIMAX_API_KEY` |
|
|
130
|
+
| **GLM / Zhipu** | GLM-5, GLM-4.7 (Global, China, Coding Plan) | `GLM_API_KEY` |
|
|
131
|
+
| **OpenRouter** | Curated presets for Claude, GPT, Kimi, MiniMax, GLM, plus any custom model | `OPENROUTER_API_KEY` |
|
|
132
|
+
|
|
133
|
+
## Tools
|
|
134
|
+
|
|
135
|
+
**15 built-in tools:**
|
|
136
|
+
|
|
137
|
+
`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`
|
|
138
|
+
|
|
139
|
+
`read_file` supports image files (PNG, JPG, GIF, WebP, etc.) on multimodal models — the agent can directly see and analyze images.
|
|
140
|
+
|
|
141
|
+
**8 orchestration tools:**
|
|
142
|
+
|
|
143
|
+
`spawn_agent` · `kill_agent` · `check_status` · `wait` · `show_context` · `summarize_context` · `ask` · `plan`
|
|
144
|
+
|
|
145
|
+
**Skills system** — Load reusable skill definitions as a dynamic `skill` tool. Manage with `/skills` (checkbox picker for enable/disable), hot-reload with `reload_skills`. Includes a built-in `skill-manager` that teaches the agent to search, download, and install new skills autonomously.
|
|
146
|
+
|
|
147
|
+
**MCP Integration** — Connect to Model Context Protocol servers for additional tools.
|
|
148
|
+
|
|
149
|
+
## Slash Commands
|
|
150
|
+
|
|
151
|
+
| Command | Description |
|
|
152
|
+
|---------|-------------|
|
|
153
|
+
| `/model` | Switch between configured models at runtime |
|
|
154
|
+
| `/thinking` | Control thinking/reasoning depth per model |
|
|
155
|
+
| `/skills` | Enable/disable skills with a checkbox picker |
|
|
156
|
+
| `/resume` | Resume a previous session from its log |
|
|
157
|
+
| `/summarize` | Summarize older context segments to free up space |
|
|
158
|
+
| `/compact` | Full context reset with a continuation summary |
|
|
159
|
+
|
|
160
|
+
## Configuration
|
|
161
|
+
|
|
162
|
+
LongerAgent loads bundled defaults from the installed package and user overrides from `~/.longeragent/`.
|
|
163
|
+
`longeragent init` creates `config.yaml` plus empty override directories.
|
|
164
|
+
|
|
165
|
+
```text
|
|
166
|
+
~/.longeragent/
|
|
167
|
+
├── config.yaml # Model and provider configurations (created by init)
|
|
168
|
+
├── settings.json # Runtime tuning (optional)
|
|
169
|
+
├── tui-preferences.json # Auto-saved TUI state
|
|
170
|
+
├── agent_templates/ # User template overrides
|
|
171
|
+
├── skills/ # User skills
|
|
172
|
+
└── prompts/ # User prompt overrides
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
See [configExample.yaml](./configExample.yaml) for a configuration reference.
|
|
176
|
+
|
|
177
|
+
### Runtime Settings (`settings.json`)
|
|
178
|
+
|
|
179
|
+
```jsonc
|
|
180
|
+
{
|
|
181
|
+
// Override max output tokens (clamped to [4096, model max])
|
|
182
|
+
"max_output_tokens": 32000,
|
|
183
|
+
// Context management thresholds (percentage of effective context, 20-95)
|
|
184
|
+
"context": {
|
|
185
|
+
"summarize_hint_level1": 60,
|
|
186
|
+
"summarize_hint_level2": 80,
|
|
187
|
+
"compact_output": 85,
|
|
188
|
+
"compact_toolcall": 90
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Architecture
|
|
194
|
+
|
|
195
|
+
LongerAgent is built around a **Session → Agent → Provider** pipeline:
|
|
196
|
+
|
|
197
|
+
- **Session** orchestrates the turn loop, message delivery, summarization, compaction, and sub-agent lifecycle
|
|
198
|
+
- **Session Log** is the single source of truth — 20+ entry types capture every runtime event; the TUI display and provider input are both projections of the same data
|
|
199
|
+
- **Agent** wraps a model + system prompt + tools into a reusable execution unit
|
|
200
|
+
- **Provider** adapters normalize streaming, reasoning, tool calls, and usage across 7 provider families
|
|
201
|
+
|
|
202
|
+
## CLI Options
|
|
203
|
+
|
|
204
|
+
```text
|
|
205
|
+
longeragent # Start with auto-detected config
|
|
206
|
+
longeragent init # Run setup wizard
|
|
207
|
+
longeragent oauth # Log in to OpenAI via OAuth (device code / browser)
|
|
208
|
+
longeragent oauth status # Check OAuth login status
|
|
209
|
+
longeragent oauth logout # Log out
|
|
210
|
+
longeragent --config <path> # Use a specific config file
|
|
211
|
+
longeragent --templates <path> # Use a specific templates directory
|
|
212
|
+
longeragent --verbose # Enable debug logging
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Development
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
pnpm install # Install dependencies
|
|
219
|
+
pnpm dev # Development mode (auto-reload)
|
|
220
|
+
pnpm build # Build
|
|
221
|
+
pnpm test # Run tests (vitest)
|
|
222
|
+
pnpm typecheck # Type check
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## License
|
|
226
|
+
|
|
227
|
+
[MIT](./LICENSE)
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/FelixRuiGao/LongerAgent/main/assets/logo.png" alt="LongerAgent" width="360" />
|
|
3
|
+
</p>
|
|
4
|
+
<p align="center">
|
|
5
|
+
<strong>为长时间会话而生的终端 AI 编程助手。</strong>
|
|
6
|
+
</p>
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="./README.md">English</a> | 中文
|
|
9
|
+
</p>
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="./LICENSE"><img alt="License" src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" /></a>
|
|
12
|
+
<img alt="Node" src="https://img.shields.io/badge/node-%3E%3D18-brightgreen?style=flat-square" />
|
|
13
|
+
<img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-5-blue?style=flat-square&logo=typescript&logoColor=white" />
|
|
14
|
+
<img alt="Author" src="https://img.shields.io/badge/author-Felix%20Rui%20Gao-4b4bf0?style=flat-square" />
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
大多数 AI 助手在长对话中会崩溃、循环或悄悄丢失上下文。LongerAgent 从底层为长时间会话而设计——结构化日志架构、三层上下文管理、跨会话持久记忆。
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
https://github.com/user-attachments/assets/e405916d-f205-4995-b4b3-ce81b19af618
|
|
22
|
+
|
|
23
|
+
> **平台:** macOS。Windows 未经测试。
|
|
24
|
+
>
|
|
25
|
+
> **安全:** LongerAgent 不对命令做沙盒隔离,也不会在文件编辑和 Shell 执行前要求审批。请在可信环境中使用,并留意它的操作。
|
|
26
|
+
|
|
27
|
+
## 快速开始
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# 全局安装
|
|
31
|
+
npm install -g longer-agent
|
|
32
|
+
|
|
33
|
+
# 运行配置向导(创建 ~/.longeragent/config.yaml)
|
|
34
|
+
longeragent init
|
|
35
|
+
|
|
36
|
+
# 启动
|
|
37
|
+
longeragent
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 亮点
|
|
43
|
+
|
|
44
|
+
- **三层上下文管理** —— 会话越来越长,也不怕
|
|
45
|
+
- **并行子 Agent** —— 通过 YAML 调用文件 spawn 多个 worker 并发执行
|
|
46
|
+
- **Skills 系统** —— 自主搜索、安装和管理可复用的技能包
|
|
47
|
+
- **持久记忆** —— `AGENTS.md` 和 Important Log 跨会话、跨压缩存续
|
|
48
|
+
- **异步消息** —— Agent 工作中随时发送消息,不用等它完成
|
|
49
|
+
- **7 大 Provider** —— Anthropic、OpenAI、Kimi、MiniMax、GLM、OpenRouter,以及任何 OpenRouter 兼容模型
|
|
50
|
+
|
|
51
|
+
## 使用
|
|
52
|
+
|
|
53
|
+
### 上下文管理
|
|
54
|
+
|
|
55
|
+
Agent 会自动管理上下文,你也可以手动介入:
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
/summarize # 压缩较早的上下文片段
|
|
59
|
+
/summarize 保留认证重构的细节 # 带指令的压缩
|
|
60
|
+
/compact # 全量上下文重置,附带延续摘要
|
|
61
|
+
/compact 保留数据库 Schema 的决策 # 带指令的重置
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`/summarize` 会精确压缩选定的片段,同时保留关键决策——适合上下文在增长但还不需要全量重置的时候。`/compact` 是终极手段:全量重置,生成延续摘要,Agent 从中断处继续。
|
|
65
|
+
|
|
66
|
+
Agent 也可以通过 `show_context` 和 `summarize_context` 工具自主完成以上操作——无需用户干预。
|
|
67
|
+
|
|
68
|
+
会话全程维护一份 **Important Log**——关键发现、失败的尝试、架构决策都会写入其中,在每次压缩后依然保留。
|
|
69
|
+
|
|
70
|
+
### 子 Agent
|
|
71
|
+
|
|
72
|
+
让 Agent 自行 spawn 子 Agent,或通过 YAML 调用文件定义任务:
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
# tasks.yaml
|
|
76
|
+
tasks:
|
|
77
|
+
- name: research
|
|
78
|
+
template: explorer
|
|
79
|
+
prompt: "调查这个代码库中认证模块的工作方式"
|
|
80
|
+
- name: refactor
|
|
81
|
+
template: executor
|
|
82
|
+
prompt: "将所有旧版 API 端点重命名为 v2"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
三个内置模板:**main**(全部工具)、**explorer**(只读)、**executor**(任务执行)。子 Agent 并发运行,完成后汇报结果。
|
|
86
|
+
|
|
87
|
+
### Skills
|
|
88
|
+
|
|
89
|
+
Skills 是可按需加载的可复用工具定义。
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
你: "安装 skill: apple-notes" # Agent 使用内置 skill-manager
|
|
93
|
+
你: /skills # 勾选启用/禁用
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
自定义 skill:在 `~/.longeragent/skills/<name>/` 下添加 `SKILL.md` 即可。
|
|
97
|
+
|
|
98
|
+
### 持久记忆
|
|
99
|
+
|
|
100
|
+
每轮对话自动加载两个 `AGENTS.md` 文件:
|
|
101
|
+
|
|
102
|
+
- **`~/AGENTS.md`** —— 所有项目通用的全局偏好
|
|
103
|
+
- **`<project>/AGENTS.md`** —— 项目级的架构笔记和模式
|
|
104
|
+
|
|
105
|
+
Agent 读取它们获取背景信息,也可以写入以保存长期知识。跨会话和上下文重置持久存在。
|
|
106
|
+
|
|
107
|
+
### 异步消息
|
|
108
|
+
|
|
109
|
+
随时输入消息——即使 Agent 正在工作。消息会排队,在下一个激活边界送达。
|
|
110
|
+
|
|
111
|
+
<details>
|
|
112
|
+
<summary><strong>上下文管理机制详解</strong></summary>
|
|
113
|
+
|
|
114
|
+
三层机制协同工作,控制上下文:
|
|
115
|
+
|
|
116
|
+
1. **提示压缩** —— 随着上下文增长,系统提示 Agent 主动压缩较早的片段
|
|
117
|
+
2. **Agent 主导的压缩** —— Agent 通过 `show_context` 检查上下文分布,用 `summarize_context` 精确压缩选定片段,保留关键决策和未解决的问题
|
|
118
|
+
3. **自动压缩** —— 接近上限时,系统执行全量上下文重置并生成延续摘要——Agent 从中断处继续
|
|
119
|
+
|
|
120
|
+
</details>
|
|
121
|
+
|
|
122
|
+
## 支持的 Provider
|
|
123
|
+
|
|
124
|
+
| Provider | 模型 | 环境变量 |
|
|
125
|
+
|----------|------|----------|
|
|
126
|
+
| **Anthropic** | Claude Haiku 4.5、Opus 4.6、Sonnet 4.6(含 1M 上下文变体) | `ANTHROPIC_API_KEY` |
|
|
127
|
+
| **OpenAI** | GPT-5.2、GPT-5.2 Codex、GPT-5.3 Codex、GPT-5.4 | `OPENAI_API_KEY` 或 OAuth |
|
|
128
|
+
| **Kimi / Moonshot** | Kimi K2.5、K2 Instruct(国际、国内、Coding Plan) | `KIMI_CN_API_KEY` / `KIMI_API_KEY` |
|
|
129
|
+
| **MiniMax** | M2.1、M2.5(国际、国内) | `MINIMAX_API_KEY` |
|
|
130
|
+
| **GLM / 智谱** | GLM-5、GLM-4.7(国际、国内、Coding Plan) | `GLM_API_KEY` |
|
|
131
|
+
| **OpenRouter** | Claude、GPT、Kimi、MiniMax、GLM 预设,及任意自定义模型 | `OPENROUTER_API_KEY` |
|
|
132
|
+
|
|
133
|
+
## 工具
|
|
134
|
+
|
|
135
|
+
**15 个内置工具:**
|
|
136
|
+
|
|
137
|
+
`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`
|
|
138
|
+
|
|
139
|
+
`read_file` 在多模态模型上支持图片文件(PNG、JPG、GIF、WebP 等)——Agent 可以直接查看和分析图片。
|
|
140
|
+
|
|
141
|
+
**8 个编排工具:**
|
|
142
|
+
|
|
143
|
+
`spawn_agent` · `kill_agent` · `check_status` · `wait` · `show_context` · `summarize_context` · `ask` · `plan`
|
|
144
|
+
|
|
145
|
+
**Skills 系统** —— 将可复用的技能定义加载为动态 `skill` 工具。通过 `/skills` 管理(勾选启用/禁用),`reload_skills` 热重载。内置 `skill-manager` 可教 Agent 自主搜索、下载和安装新技能。
|
|
146
|
+
|
|
147
|
+
**MCP 集成** —— 连接 Model Context Protocol 服务器以扩展工具。
|
|
148
|
+
|
|
149
|
+
## 斜杠命令
|
|
150
|
+
|
|
151
|
+
| 命令 | 说明 |
|
|
152
|
+
|------|------|
|
|
153
|
+
| `/model` | 运行时切换已配置的模型 |
|
|
154
|
+
| `/thinking` | 控制每个模型的思考/推理深度 |
|
|
155
|
+
| `/skills` | 勾选启用/禁用技能 |
|
|
156
|
+
| `/resume` | 从日志恢复之前的会话 |
|
|
157
|
+
| `/summarize` | 压缩较早的上下文片段以释放空间 |
|
|
158
|
+
| `/compact` | 全量上下文重置,附带延续摘要 |
|
|
159
|
+
|
|
160
|
+
## 配置
|
|
161
|
+
|
|
162
|
+
LongerAgent 从安装包加载内置默认值,从 `~/.longeragent/` 加载用户覆盖。
|
|
163
|
+
`longeragent init` 会创建 `config.yaml` 及空的覆盖目录。
|
|
164
|
+
|
|
165
|
+
```text
|
|
166
|
+
~/.longeragent/
|
|
167
|
+
├── config.yaml # 模型和 Provider 配置(由 init 创建)
|
|
168
|
+
├── settings.json # 运行时调优(可选)
|
|
169
|
+
├── tui-preferences.json # TUI 状态自动保存
|
|
170
|
+
├── agent_templates/ # 用户模板覆盖
|
|
171
|
+
├── skills/ # 用户技能
|
|
172
|
+
└── prompts/ # 用户 Prompt 覆盖
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
参见 [configExample.yaml](./configExample.yaml) 获取配置参考。
|
|
176
|
+
|
|
177
|
+
### 运行时设置(`settings.json`)
|
|
178
|
+
|
|
179
|
+
```jsonc
|
|
180
|
+
{
|
|
181
|
+
// 覆盖最大输出 token 数(限制在 [4096, 模型最大值])
|
|
182
|
+
"max_output_tokens": 32000,
|
|
183
|
+
// 上下文管理阈值(有效上下文的百分比,20-95)
|
|
184
|
+
"context": {
|
|
185
|
+
"summarize_hint_level1": 60,
|
|
186
|
+
"summarize_hint_level2": 80,
|
|
187
|
+
"compact_output": 85,
|
|
188
|
+
"compact_toolcall": 90
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## 架构
|
|
194
|
+
|
|
195
|
+
LongerAgent 围绕 **Session → Agent → Provider** 流水线构建:
|
|
196
|
+
|
|
197
|
+
- **Session** 编排 turn 循环、消息投递、压缩、子 Agent 生命周期
|
|
198
|
+
- **Session Log** 是唯一事实来源——20+ 种条目类型记录所有运行时事件;TUI 显示和 Provider 输入都是同一数据的投影
|
|
199
|
+
- **Agent** 将模型 + 系统 Prompt + 工具封装为可复用的执行单元
|
|
200
|
+
- **Provider** 适配器在 7 个 Provider 家族间统一流式输出、推理、工具调用和用量
|
|
201
|
+
|
|
202
|
+
## CLI 选项
|
|
203
|
+
|
|
204
|
+
```text
|
|
205
|
+
longeragent # 使用自动检测的配置启动
|
|
206
|
+
longeragent init # 运行配置向导
|
|
207
|
+
longeragent oauth # 通过 OAuth 登录 OpenAI(设备码 / 浏览器)
|
|
208
|
+
longeragent oauth status # 查看 OAuth 登录状态
|
|
209
|
+
longeragent oauth logout # 登出
|
|
210
|
+
longeragent --config <path> # 使用指定配置文件
|
|
211
|
+
longeragent --templates <path> # 使用指定模板目录
|
|
212
|
+
longeragent --verbose # 启用调试日志
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## 开发
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
pnpm install # 安装依赖
|
|
219
|
+
pnpm dev # 开发模式(自动重载)
|
|
220
|
+
pnpm build # 构建
|
|
221
|
+
pnpm test # 运行测试(vitest)
|
|
222
|
+
pnpm typecheck # 类型检查
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## 许可证
|
|
226
|
+
|
|
227
|
+
[MIT](./LICENSE)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type: agent
|
|
2
|
+
name: executor
|
|
3
|
+
description: "Executes bounded tasks with file and shell access."
|
|
4
|
+
system_prompt_file: system_prompt.md
|
|
5
|
+
tools:
|
|
6
|
+
- read_file
|
|
7
|
+
- write_file
|
|
8
|
+
- edit_file
|
|
9
|
+
- apply_patch
|
|
10
|
+
- list_dir
|
|
11
|
+
- glob
|
|
12
|
+
- grep
|
|
13
|
+
- diff
|
|
14
|
+
- bash
|
|
15
|
+
- bash_background
|
|
16
|
+
- bash_output
|
|
17
|
+
- kill_shell
|
|
18
|
+
- test
|
|
19
|
+
- web_search
|
|
20
|
+
- web_fetch
|
|
21
|
+
prompt_sections: [important_log, agents_md]
|
|
22
|
+
max_tool_rounds: 200
|
|
@@ -0,0 +1,17 @@
|
|
|
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.
|
|
2
|
+
|
|
3
|
+
Your working directory is {PROJECT_ROOT}.
|
|
4
|
+
|
|
5
|
+
Workflow:
|
|
6
|
+
1. Understand the task requirements fully before acting.
|
|
7
|
+
2. Use search and read tools to examine the relevant code.
|
|
8
|
+
3. Make the requested changes or execute the requested commands.
|
|
9
|
+
4. Verify your changes (run tests, check output) when appropriate.
|
|
10
|
+
5. Report what was done, what succeeded, and any issues encountered.
|
|
11
|
+
|
|
12
|
+
Output guidelines:
|
|
13
|
+
- Lead with what was done and the outcome.
|
|
14
|
+
- Include file paths and line numbers for all changes made.
|
|
15
|
+
- Report errors or unexpected behavior explicitly.
|
|
16
|
+
- Keep your response focused — only include information relevant to the task.
|
|
17
|
+
- **Important:** Your final output is the ONLY thing the primary agent will see. Include all relevant findings, file paths, and code references in your response — nothing from your tool calls will be forwarded.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type: agent
|
|
2
|
+
name: explorer
|
|
3
|
+
description: "Explores files and directories. Read-only."
|
|
4
|
+
system_prompt_file: system_prompt.md
|
|
5
|
+
tools:
|
|
6
|
+
- read_file
|
|
7
|
+
- list_dir
|
|
8
|
+
- grep
|
|
9
|
+
- glob
|
|
10
|
+
- web_search
|
|
11
|
+
- web_fetch
|
|
12
|
+
prompt_sections: [important_log, agents_md]
|
|
13
|
+
max_tool_rounds: 200
|
|
@@ -0,0 +1,19 @@
|
|
|
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.
|
|
2
|
+
|
|
3
|
+
Your working directory is {PROJECT_ROOT}.
|
|
4
|
+
|
|
5
|
+
Workflow:
|
|
6
|
+
1. Use `list_dir` to understand the directory structure if needed.
|
|
7
|
+
2. Use `read_file` to read the specified files.
|
|
8
|
+
3. Use `grep` to find specific patterns when asked about particular code elements.
|
|
9
|
+
4. Use `web_search` when you need current external information not present in local files.
|
|
10
|
+
5. Synthesize your findings into a concise response.
|
|
11
|
+
|
|
12
|
+
Output guidelines:
|
|
13
|
+
- Lead with the direct answer or key finding.
|
|
14
|
+
- For file summaries: list the main components (classes, functions, key variables) with one-line descriptions.
|
|
15
|
+
- For code questions: quote the relevant code snippet, then explain.
|
|
16
|
+
- For directory exploration: present a structured overview of what each file/module does.
|
|
17
|
+
- Keep your response focused — only include information relevant to what was asked.
|
|
18
|
+
- Do NOT modify any files. You are read-only.
|
|
19
|
+
- **Important:** Your final output is the ONLY thing the primary agent will see. Include all relevant findings, file paths, and code references in your response — nothing from your tool calls will be forwarded.
|
|
@@ -0,0 +1,45 @@
|
|
|
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.
|
|
2
|
+
|
|
3
|
+
## Tone and Output
|
|
4
|
+
|
|
5
|
+
Keep responses short. Non-code text should not exceed 4 lines unless the user asks for detail or the task is genuinely complex.
|
|
6
|
+
|
|
7
|
+
**No preamble or postamble.** Do not open with "Sure!", "Great question!", "I'll help you with that." Do not close with "Let me know if you need anything else." Do not summarize what you just did unless the user asks.
|
|
8
|
+
|
|
9
|
+
**Confirm, don't explain.** After completing a task, state what was done briefly.
|
|
10
|
+
|
|
11
|
+
<example>
|
|
12
|
+
user: what is 2+2?
|
|
13
|
+
assistant: 4
|
|
14
|
+
</example>
|
|
15
|
+
|
|
16
|
+
<example>
|
|
17
|
+
user: Fix the typo in line 12 of config.ts
|
|
18
|
+
assistant: Fixed: changed "recieve" to "receive" in config.ts:12.
|
|
19
|
+
</example>
|
|
20
|
+
|
|
21
|
+
**Code over prose.** When the answer is code, show the code. Use text only for decisions, context, or information that cannot be expressed as code.
|
|
22
|
+
|
|
23
|
+
**Professional objectivity.** Correct errors directly. Do not validate feelings or add unnecessary encouragement. If the user's approach has problems, say so and explain why.
|
|
24
|
+
|
|
25
|
+
## Proactiveness
|
|
26
|
+
|
|
27
|
+
Do the task you are asked to do — nothing more. Do not:
|
|
28
|
+
- Add features, refactoring, or cleanup beyond what was requested.
|
|
29
|
+
- Create files the user did not ask for (documentation, test stubs, configs).
|
|
30
|
+
- Run destructive operations (git reset --hard, rm -rf) without explicit instruction.
|
|
31
|
+
|
|
32
|
+
When you discover something that should be addressed but wasn't requested, mention it in your response or note it in your important log — do not act on it.
|
|
33
|
+
|
|
34
|
+
## Core Principles
|
|
35
|
+
|
|
36
|
+
1. **Do the work yourself.** Read files, write code, run tests, search the codebase. Don't describe what you would do — do it.
|
|
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
|
+
3. **Guard your context window.** Every token costs. Proactively compress with `summarize_context` and preserve cross-reset knowledge in your important log.
|
|
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
|
+
|
|
41
|
+
## Path Variables
|
|
42
|
+
|
|
43
|
+
- **`{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
|
+
- **`{SYSTEM_DATA}`** — Cross-session persistent storage. Managed by the system; do not access directly.
|