tagword-codeagent 1.1.6__py3-none-any.whl

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 (173) hide show
  1. codeagent/__init__.py +10 -0
  2. codeagent/__main__.py +13 -0
  3. codeagent/cli/__init__.py +13 -0
  4. codeagent/cli/entrypoint.py +161 -0
  5. codeagent/cli/main.py +979 -0
  6. codeagent/core/__init__.py +2 -0
  7. codeagent/core/attachments.py +342 -0
  8. codeagent/core/audio_models.py +50 -0
  9. codeagent/core/bootstrap.py +178 -0
  10. codeagent/core/default_presets.py +159 -0
  11. codeagent/core/env.py +106 -0
  12. codeagent/core/folder_picker.py +151 -0
  13. codeagent/core/image_understanding.py +90 -0
  14. codeagent/core/models.py +6 -0
  15. codeagent/core/paths.py +238 -0
  16. codeagent/core/pricing.py +107 -0
  17. codeagent/core/process_ports.py +258 -0
  18. codeagent/core/seed_bridge.py +21 -0
  19. codeagent/core/settings.py +98 -0
  20. codeagent/core/speech_synth.py +330 -0
  21. codeagent/core/team_config.py +247 -0
  22. codeagent/core/team_manager.py +245 -0
  23. codeagent/core/token_counter.py +41 -0
  24. codeagent/core/tts_voices.py +103 -0
  25. codeagent/core/usage_billing.py +72 -0
  26. codeagent/core/vision_models.py +93 -0
  27. codeagent/memory/diary.py +144 -0
  28. codeagent/persona_defaults/README.md +12 -0
  29. codeagent/persona_defaults/agent.md +352 -0
  30. codeagent/persona_defaults/identity.md +29 -0
  31. codeagent/persona_defaults/memory.md +4 -0
  32. codeagent/persona_defaults/skills.md +325 -0
  33. codeagent/persona_defaults/soul.md +38 -0
  34. codeagent/persona_defaults/tools.md +41 -0
  35. codeagent/persona_defaults/user.md +18 -0
  36. codeagent/runtime/__init__.py +11 -0
  37. codeagent/runtime/agent_context.py +6 -0
  38. codeagent/runtime/agent_runtime.py +21 -0
  39. codeagent/runtime/compact_prompt.py +9 -0
  40. codeagent/runtime/compact_state.py +40 -0
  41. codeagent/runtime/llm_worker.py +132 -0
  42. codeagent/runtime/orchestrator.py +161 -0
  43. codeagent/runtime/prompt_enrichment.py +324 -0
  44. codeagent/runtime/session_manager.py +30 -0
  45. codeagent/runtime/task_split.py +38 -0
  46. codeagent/runtime/turn_loop.py +13 -0
  47. codeagent/runtime/worker.py +48 -0
  48. codeagent/server/__init__.py +505 -0
  49. codeagent/server/app_factory.py +1292 -0
  50. codeagent/server/attachment_api.py +261 -0
  51. codeagent/server/hub.py +175 -0
  52. codeagent/server/icon.png +0 -0
  53. codeagent/server/self_healing.py +143 -0
  54. codeagent/server/team_engine.py +243 -0
  55. codeagent/server/tts_api.py +51 -0
  56. codeagent/server/webui_api_app.py +3180 -0
  57. codeagent/skills/__init__.py +2 -0
  58. codeagent/skills/select.py +144 -0
  59. codeagent/tools/__init__.py +6 -0
  60. codeagent/tools/agent_tools.py +10 -0
  61. codeagent/web/__init__.py +1 -0
  62. codeagent/web/__pycache__/__init__.cpython-313.pyc +0 -0
  63. codeagent/web/__pycache__/app.cpython-313.pyc +0 -0
  64. codeagent/web/__pycache__/auth_impl.cpython-313.pyc +0 -0
  65. codeagent/web/auth_impl.py +326 -0
  66. codeagent/web/static/00-marked.min.js +6 -0
  67. codeagent/web/static/00-mermaid.min.js +2314 -0
  68. codeagent/web/static/00-purify.min.js +3 -0
  69. codeagent/web/static/00-storage.js +83 -0
  70. codeagent/web/static/00-utils.js +51 -0
  71. codeagent/web/static/01-theme.css +96 -0
  72. codeagent/web/static/01a-scroll.js +86 -0
  73. codeagent/web/static/01b-think.js +62 -0
  74. codeagent/web/static/01c-session-identity.js +81 -0
  75. codeagent/web/static/01c-session-thinking.js +61 -0
  76. codeagent/web/static/01c-session-tree-menus.js +349 -0
  77. codeagent/web/static/01c-session-tree.js +531 -0
  78. codeagent/web/static/01c-session-utilities.js +83 -0
  79. codeagent/web/static/01c-vision-model.js +132 -0
  80. codeagent/web/static/01d-image-gen-model.js +84 -0
  81. codeagent/web/static/01e-audio-model.js +97 -0
  82. codeagent/web/static/01f-compose-ui.js +88 -0
  83. codeagent/web/static/01g-tts-settings.js +128 -0
  84. codeagent/web/static/01h-music-model.js +85 -0
  85. codeagent/web/static/01i-model-stack.js +291 -0
  86. codeagent/web/static/01j-video-gen-model.js +85 -0
  87. codeagent/web/static/01k-model-stack-bootstrap.js +66 -0
  88. codeagent/web/static/01k-model-stack-state.js +209 -0
  89. codeagent/web/static/01q-inflight.js +195 -0
  90. codeagent/web/static/02-reset.css +22 -0
  91. codeagent/web/static/02-session-ui.js +201 -0
  92. codeagent/web/static/03-layout-p1.css +2 -0
  93. codeagent/web/static/03-layout-p2.css +2 -0
  94. codeagent/web/static/03a-links-stream.js +88 -0
  95. codeagent/web/static/03b-stream-text.js +119 -0
  96. codeagent/web/static/03c-render-bubble.js +520 -0
  97. codeagent/web/static/03d-agent-bubble.js +126 -0
  98. codeagent/web/static/03e-tool-trace.js +182 -0
  99. codeagent/web/static/03f-timeline.js +54 -0
  100. codeagent/web/static/03g-bubble-tts.js +292 -0
  101. codeagent/web/static/04-components-p1.css +1 -0
  102. codeagent/web/static/04-components-p2b.css +1 -0
  103. codeagent/web/static/04-components-p3.css +2 -0
  104. codeagent/web/static/04-components-p4.css +1 -0
  105. codeagent/web/static/04-components-p5.css +1 -0
  106. codeagent/web/static/04-components-p6.css +58 -0
  107. codeagent/web/static/04-components-p7.css +4 -0
  108. codeagent/web/static/04-components-p8.css +1 -0
  109. codeagent/web/static/04-components-p9.css +1 -0
  110. codeagent/web/static/04-ws-connect.js +351 -0
  111. codeagent/web/static/04-ws-helpers.js +116 -0
  112. codeagent/web/static/05-chat-p1.css +1058 -0
  113. codeagent/web/static/05-chat-p2.css +1 -0
  114. codeagent/web/static/05-chat-p3.css +295 -0
  115. codeagent/web/static/05a-session-history.js +176 -0
  116. codeagent/web/static/05b-session-list.js +114 -0
  117. codeagent/web/static/05c-dialog.js +123 -0
  118. codeagent/web/static/05d-project-create.js +172 -0
  119. codeagent/web/static/05e-project-remote.js +143 -0
  120. codeagent/web/static/06-chat.js +552 -0
  121. codeagent/web/static/06-utilities.css +181 -0
  122. codeagent/web/static/06b-attachments.js +304 -0
  123. codeagent/web/static/06c-camera.js +488 -0
  124. codeagent/web/static/07-activity-bar.css +127 -0
  125. codeagent/web/static/09-git-p1.css +1 -0
  126. codeagent/web/static/09-git-p2.css +1 -0
  127. codeagent/web/static/09a-init-bind.js +110 -0
  128. codeagent/web/static/09b-panel-toggle.js +80 -0
  129. codeagent/web/static/09c-api-refresh.js +100 -0
  130. codeagent/web/static/09d-status-log.js +80 -0
  131. codeagent/web/static/09e-commit.js +80 -0
  132. codeagent/web/static/09f-remote.js +93 -0
  133. codeagent/web/static/11a-cron-parse.js +117 -0
  134. codeagent/web/static/11b-cron-panel.js +100 -0
  135. codeagent/web/static/11c-cron-card.js +133 -0
  136. codeagent/web/static/11d-cron-form.js +105 -0
  137. codeagent/web/static/11e-env-config.js +168 -0
  138. codeagent/web/static/11f-env-llm-a-state.js +136 -0
  139. codeagent/web/static/11f-env-llm-b-form.js +409 -0
  140. codeagent/web/static/11f-env-llm-c-board.js +322 -0
  141. codeagent/web/static/11g-env-paths-git.js +973 -0
  142. codeagent/web/static/11h-env-mcp-a-state.js +161 -0
  143. codeagent/web/static/11h-env-mcp-b-form.js +229 -0
  144. codeagent/web/static/11h-env-mcp-c-board.js +565 -0
  145. codeagent/web/static/12-plugins.js +127 -0
  146. codeagent/web/static/13a-skills.js +156 -0
  147. codeagent/web/static/13a-todo-utils.js +140 -0
  148. codeagent/web/static/13b-todo-fetch.js +106 -0
  149. codeagent/web/static/13b-tools.js +127 -0
  150. codeagent/web/static/13c-todo-crud.js +92 -0
  151. codeagent/web/static/14-activity-bar.js +177 -0
  152. codeagent/web/static/15-plans.css +194 -0
  153. codeagent/web/static/15-plans.js +219 -0
  154. codeagent/web/static/16-mobile.css +612 -0
  155. codeagent/web/static/16-mobile.js +178 -0
  156. codeagent/web/static/17-preset-ux.css +287 -0
  157. codeagent/web/static/18-agent-mgr.css +616 -0
  158. codeagent/web/static/18-agent-mgr.js +204 -0
  159. codeagent/web/static/24-health-dashboard.js +68 -0
  160. codeagent/web/static/99-brand-polish.css +152 -0
  161. codeagent/web/static/body.html +824 -0
  162. codeagent/web/static/setup/setup_form.html +171 -0
  163. codeagent/web/static/setup/setup_head.html +100 -0
  164. codeagent/web/static/setup/setup_tail.html +264 -0
  165. codeagent/web/static/setup/setup_test.html +38 -0
  166. codeagent/web/web_login.html +265 -0
  167. codeagent/web/webui.html +35 -0
  168. tagword_codeagent-1.1.6.dist-info/METADATA +273 -0
  169. tagword_codeagent-1.1.6.dist-info/RECORD +173 -0
  170. tagword_codeagent-1.1.6.dist-info/WHEEL +5 -0
  171. tagword_codeagent-1.1.6.dist-info/entry_points.txt +3 -0
  172. tagword_codeagent-1.1.6.dist-info/licenses/LICENSE +21 -0
  173. tagword_codeagent-1.1.6.dist-info/top_level.txt +1 -0
@@ -0,0 +1,265 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
+ <meta name="color-scheme" content="light dark"/>
7
+ <link rel="icon" type="image/png" href="/icon.png"/>
8
+ <link rel="apple-touch-icon" href="/icon.png"/>
9
+ <title>CodeAgent · 登录</title>
10
+ <style>
11
+ :root {
12
+ color-scheme: light dark;
13
+ --font-sans: "Inter", "Segoe UI Variable", system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
14
+ --font-mono: ui-monospace, "SF Mono", Consolas, monospace;
15
+ --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
16
+ --r-md: 8px; --r-lg: 10px; --r-xl: 14px; --r-2xl: 18px;
17
+ --bg: #fbfbfc;
18
+ --bg-panel: #ffffff;
19
+ --bg-subtle: #f5f5f7;
20
+ --border: #e6e6ea;
21
+ --border-strong: #d4d4d8;
22
+ --text: #18181b;
23
+ --text-secondary: #3f3f46;
24
+ --text-muted: #71717a;
25
+ --text-subtle: #a1a1aa;
26
+ --accent: #4f46e5;
27
+ --accent-hover: #4338ca;
28
+ --accent-soft: rgba(79, 70, 229, 0.09);
29
+ --accent-ring: rgba(79, 70, 229, 0.22);
30
+ --danger: #dc2626;
31
+ --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
32
+ --shadow-lg: 0 18px 36px -10px rgba(16, 24, 40, 0.12), 0 4px 10px -4px rgba(16, 24, 40, 0.05);
33
+ --shadow-focus: 0 0 0 3px var(--accent-ring);
34
+ }
35
+ @media (prefers-color-scheme: dark) {
36
+ :root {
37
+ --bg: #0a0a0b;
38
+ --bg-panel: #111113;
39
+ --bg-subtle: #161618;
40
+ --border: rgba(255,255,255,0.08);
41
+ --border-strong: rgba(255,255,255,0.14);
42
+ --text: #f4f4f5;
43
+ --text-secondary: #d4d4d8;
44
+ --text-muted: #a1a1aa;
45
+ --text-subtle: #71717a;
46
+ --accent: #a5b4fc;
47
+ --accent-hover: #c7d2fe;
48
+ --accent-soft: rgba(129, 140, 248, 0.16);
49
+ --accent-ring: rgba(129, 140, 248, 0.35);
50
+ --danger: #f87171;
51
+ --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
52
+ --shadow-lg: 0 24px 48px -14px rgba(0,0,0,0.6);
53
+ }
54
+ }
55
+
56
+ *, *::before, *::after { box-sizing: border-box; }
57
+ body {
58
+ margin: 0;
59
+ min-height: 100vh;
60
+ font-family: var(--font-sans);
61
+ font-size: 14px;
62
+ color: var(--text);
63
+ background: var(--bg);
64
+ background-image:
65
+ radial-gradient(ellipse 120% 80% at 50% -20%, var(--accent-soft), transparent 55%);
66
+ display: flex;
67
+ align-items: center;
68
+ justify-content: center;
69
+ padding: var(--sp-6) var(--sp-4);
70
+ }
71
+
72
+ .login-card {
73
+ width: 100%;
74
+ max-width: 400px;
75
+ padding: var(--sp-8) var(--sp-6);
76
+ background: var(--bg-panel);
77
+ border: 1px solid var(--border);
78
+ border-radius: var(--r-2xl);
79
+ box-shadow: var(--shadow-lg);
80
+ }
81
+
82
+ .login-brand {
83
+ display: flex;
84
+ align-items: center;
85
+ gap: var(--sp-4);
86
+ margin-bottom: var(--sp-6);
87
+ }
88
+ .login-brand__logo {
89
+ width: 44px;
90
+ height: 44px;
91
+ border-radius: var(--r-lg);
92
+ object-fit: contain;
93
+ background: linear-gradient(160deg, #fff, var(--bg-subtle));
94
+ padding: 4px;
95
+ box-shadow:
96
+ var(--shadow-sm),
97
+ 0 0 0 1px color-mix(in srgb, var(--accent) 14%, var(--border));
98
+ flex-shrink: 0;
99
+ }
100
+ .login-brand__name {
101
+ font-size: 18px;
102
+ font-weight: 650;
103
+ letter-spacing: -0.02em;
104
+ color: var(--text);
105
+ line-height: 1.2;
106
+ }
107
+ .login-brand__tag {
108
+ font-size: 12px;
109
+ color: var(--text-muted);
110
+ margin-top: 4px;
111
+ font-weight: 450;
112
+ }
113
+
114
+ .login-badge {
115
+ display: inline-flex;
116
+ align-items: center;
117
+ padding: 3px 10px;
118
+ border-radius: 999px;
119
+ font-size: 11px;
120
+ font-weight: 600;
121
+ color: var(--accent);
122
+ background: var(--accent-soft);
123
+ margin-bottom: var(--sp-4);
124
+ }
125
+
126
+ .login-lead {
127
+ margin: 0 0 var(--sp-5);
128
+ font-size: 14px;
129
+ color: var(--text-secondary);
130
+ line-height: 1.5;
131
+ }
132
+
133
+ .login-label {
134
+ display: block;
135
+ font-size: 12px;
136
+ font-weight: 600;
137
+ color: var(--text-muted);
138
+ margin-bottom: var(--sp-2);
139
+ }
140
+
141
+ .login-input {
142
+ width: 100%;
143
+ padding: 11px 14px;
144
+ border-radius: var(--r-lg);
145
+ border: 1px solid var(--border);
146
+ background: var(--bg-subtle);
147
+ color: var(--text);
148
+ font-size: 14px;
149
+ font-family: var(--font-mono);
150
+ letter-spacing: 0.02em;
151
+ transition: border-color 0.15s ease, box-shadow 0.15s ease;
152
+ }
153
+ .login-input::placeholder { color: var(--text-subtle); }
154
+ .login-input:focus {
155
+ outline: none;
156
+ border-color: var(--accent);
157
+ box-shadow: var(--shadow-focus);
158
+ background: var(--bg-panel);
159
+ }
160
+
161
+ .login-btn {
162
+ width: 100%;
163
+ margin-top: var(--sp-5);
164
+ padding: 11px var(--sp-4);
165
+ border: none;
166
+ border-radius: var(--r-lg);
167
+ font-size: 14px;
168
+ font-weight: 600;
169
+ font-family: inherit;
170
+ cursor: pointer;
171
+ color: #fff;
172
+ background: var(--accent);
173
+ box-shadow: 0 1px 2px rgba(79, 70, 229, 0.22);
174
+ transition: background 0.12s ease, transform 0.12s ease;
175
+ }
176
+ .login-btn:hover { background: var(--accent-hover); }
177
+ .login-btn:active { transform: translateY(1px); }
178
+
179
+ @media (prefers-color-scheme: dark) {
180
+ .login-btn {
181
+ background: linear-gradient(140deg, #6366f1 0%, #4f46e5 100%);
182
+ box-shadow: 0 1px 3px rgba(0,0,0,0.35);
183
+ }
184
+ .login-btn:hover {
185
+ filter: brightness(1.06);
186
+ }
187
+ }
188
+
189
+ .login-err {
190
+ margin-top: var(--sp-4);
191
+ min-height: 1.35em;
192
+ font-size: 13px;
193
+ color: var(--danger);
194
+ }
195
+
196
+ .login-foot {
197
+ margin-top: var(--sp-6);
198
+ padding-top: var(--sp-5);
199
+ border-top: 1px solid var(--border);
200
+ font-size: 11.5px;
201
+ color: var(--text-subtle);
202
+ line-height: 1.55;
203
+ }
204
+ .login-foot code {
205
+ font-family: var(--font-mono);
206
+ font-size: 11px;
207
+ padding: 1px 6px;
208
+ border-radius: var(--r-md);
209
+ background: var(--bg-subtle);
210
+ color: var(--text-muted);
211
+ }
212
+ </style>
213
+ </head>
214
+ <body>
215
+ <main class="login-card" aria-labelledby="login-title">
216
+ <div class="login-brand">
217
+ <img class="login-brand__logo" src="/icon.png" alt="" width="44" height="44" decoding="async"/>
218
+ <div>
219
+ <div class="login-brand__name" id="login-title">CodeAgent</div>
220
+ <div class="login-brand__tag">本地 Agent 工作台 · Web UI</div>
221
+ </div>
222
+ </div>
223
+
224
+ <span class="login-badge" aria-hidden="true">令牌登录</span>
225
+ <p class="login-lead">此 Web UI 已开启访问保护,请输入令牌后即可进入。</p>
226
+
227
+ <label class="login-label" for="t">访问令牌</label>
228
+ <input id="t" class="login-input" type="password" autocomplete="current-password" placeholder="粘贴令牌" spellcheck="false"/>
229
+ <button type="button" class="login-btn" id="go">进入工作台</button>
230
+ <div id="err" class="login-err" role="alert"></div>
231
+
232
+ <p class="login-foot">
233
+ 本地生成:<code>codeagent webui-token init</code>
234
+ · 亦可设置 <code>CODEAGENT_WEBUI_TOKEN</code>
235
+ </p>
236
+ </main>
237
+ <script>
238
+ document.getElementById('go').onclick = async () => {
239
+ const err = document.getElementById('err');
240
+ err.textContent = '';
241
+ const token = document.getElementById('t').value.trim();
242
+ if (!token) { err.textContent = '请输入令牌'; return; }
243
+ try {
244
+ const r = await fetch('/api/ui/auth', {
245
+ method: 'POST',
246
+ headers: { 'Content-Type': 'application/json' },
247
+ credentials: 'same-origin',
248
+ body: JSON.stringify({ token })
249
+ });
250
+ const j = await r.json().catch(() => ({}));
251
+ if (!r.ok) { err.textContent = j.detail || r.statusText; return; }
252
+ if (j.ws_query_token) {
253
+ try { sessionStorage.setItem('oa_webui_ws_token', j.ws_query_token); } catch (_) {}
254
+ } else {
255
+ try { sessionStorage.removeItem('oa_webui_ws_token'); } catch (_) {}
256
+ }
257
+ location.href = '/';
258
+ } catch (e) {
259
+ err.textContent = String(e);
260
+ }
261
+ };
262
+ document.getElementById('t').onkeydown = (e) => { if (e.key === 'Enter') document.getElementById('go').click(); };
263
+ </script>
264
+ </body>
265
+ </html>
@@ -0,0 +1,35 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
+ <meta name="theme-color" content="#4f46e5" media="(prefers-color-scheme: light)"/>
7
+ <meta name="theme-color" content="#111113" media="(prefers-color-scheme: dark)"/>
8
+ <link rel="icon" type="image/png" href="/icon.png"/>
9
+ <link rel="apple-touch-icon" href="/icon.png"/>
10
+ <title>CodeAgent</title>
11
+ <!--
12
+ This HTML file is assembled at runtime by server.get_app_html().
13
+ The large parts live in sibling files under ./webui/ and are
14
+ inlined below so the browser still receives a single self-contained
15
+ page and no new HTTP routes are needed:
16
+
17
+ CSS files (*.css) -> inlined into <style>
18
+ body.html -> inlined between <body>...</body>
19
+ JS files (*.js) -> concatenated into ONE <script> block
20
+ (they share one global closure)
21
+
22
+ Keeping them concatenated (not separate <script src=>) is deliberate:
23
+ the code relies on hoisted top-level `const`/`let` declarations being
24
+ visible across fragments (e.g. `agentId` defined in 01-core.js is
25
+ used in 11-config.js).
26
+ -->
27
+ <style>/*{{STYLES}}*/</style>
28
+ </head>
29
+ <body>
30
+ {{BODY}}
31
+ <script>
32
+ {{SCRIPTS}}
33
+ </script>
34
+ </body>
35
+ </html>
@@ -0,0 +1,273 @@
1
+ Metadata-Version: 2.4
2
+ Name: tagword-codeagent
3
+ Version: 1.1.6
4
+ Summary: LLM agent with Markdown config, tool loop, Web UI, sessions, memory, and webhooks
5
+ License: MIT
6
+ Requires-Python: >=3.9
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: seed-kernel
10
+ Requires-Dist: seed-model-providers
11
+ Requires-Dist: seed-toolbox[code]
12
+ Requires-Dist: uvicorn[standard]>=0.30.0
13
+ Requires-Dist: starlette>=0.37.0
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest>=7.0; extra == "dev"
16
+ Provides-Extra: lint
17
+ Requires-Dist: pre-commit>=3.0; extra == "lint"
18
+ Provides-Extra: yaml
19
+ Requires-Dist: pyyaml>=6.0; extra == "yaml"
20
+ Provides-Extra: vision
21
+ Requires-Dist: pypdf>=4.0; extra == "vision"
22
+ Provides-Extra: bundle
23
+ Requires-Dist: rumps>=0.4.0; extra == "bundle"
24
+ Requires-Dist: pyinstaller>=6.0; extra == "bundle"
25
+ Requires-Dist: pillow>=10.0; extra == "bundle"
26
+ Dynamic: license-file
27
+
28
+ # CodeAgent
29
+
30
+ 一个**自主全栈开发 Agent** — 用 Markdown 配置文件驱动人格与行为,支持 Web UI,开箱即用。
31
+
32
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
33
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](pyproject.toml)
34
+
35
+ ---
36
+
37
+ ## 概览
38
+
39
+ CodeAgent 是一个**自主全栈开发 Agent** —— 它能独立承接从需求分析到交付维护的完整项目周期。由 Markdown 配置文件(`agent.md`、`soul.md`、`skills.md` 等)定义人格与行为规则,配合强大的工具系统,实现最小人工干预下的自动化开发。
40
+
41
+ ### 架构分层
42
+
43
+ ```
44
+ ┌─────────────────────────────────────────────────┐
45
+ │ CodeAgent(本仓库) │
46
+ │ CLI · HTTP/WebSocket · Web UI · 认证 · Agent 层 │
47
+ ├─────────────────────────────────────────────────┤
48
+ │ seed 核心引擎(LLM/路由/会话) │
49
+ │ seed-tools[code] 内置工具注册与执行 │
50
+ │ seed-model-providers 模型提供商目录(tokenizer)│
51
+ └─────────────────────────────────────────────────┘
52
+ ```
53
+
54
+ ### 核心特性
55
+
56
+ - 🧠 **LLM 驱动** — 支持 OpenAI、Anthropic、DeepSeek、本地模型等多种后端
57
+ - 📜 **人格即配置** — 用 Markdown 定义 Agent 的身份、行为准则、技能,无需改代码
58
+ - 🛠️ **工具系统** — 45+ 内置工具:文件操作、Shell 执行、代码分析、Git 管理、数据库、部署
59
+ - 🌐 **Web UI v2** — 现代化 React + Vite 前端,可视化聊天、工具调用链、会话历史
60
+ - 📋 **项目管控** — 内置待办管理、项目规划(docs/plans 面板)、版本追踪
61
+ - 🔌 **可扩展** — 自定义工具、Webhook、多 Agent 协作(Multi-Agent Hub)
62
+ - 🧩 **多步工作流** — 内置 fix-and-commit、new-feature、audit-project 等自动化流水线
63
+ - 🌍 **国内友好** — 自动检测国内网络,使用 PyPI 镜像(清华源)加速安装
64
+
65
+ ## 快速开始
66
+
67
+ ### ⭐ 一键运行(强烈推荐)
68
+
69
+ ```bash
70
+ # 克隆仓库
71
+ git clone https://github.com/tagword/codeagent.git
72
+ cd codeagent
73
+
74
+ # 一键运行(自动检测环境、安装依赖、启动服务)
75
+ bash run.sh
76
+ ```
77
+
78
+ 脚本会自动:
79
+ 1. 检测 Python(≥ 3.9)和 Git
80
+ 2. **自动识别国内网络** → 使用清华 PyPI 镜像加速
81
+ 3. 创建虚拟环境 `.venv`
82
+ 4. 安装 CodeAgent 及全部依赖(含私有 seed 框架)
83
+ 5. 构建 Web UI v2 前端(如有 Node.js)
84
+ 6. 启动 Web 服务 → 浏览器打开 `http://localhost:8765`
85
+
86
+ > 💡 支持自定义参数:`bash run.sh --port 8766 --host 0.0.0.0`
87
+ > 💡 `run.sh` 内置了网络重试和 tarball 降级机制,网络不稳定时比 `pip install -e .` 更可靠
88
+
89
+ ### 一键安装
90
+
91
+ ```bash
92
+ curl -fsSL https://raw.githubusercontent.com/tagword/codeagent/main/install.sh | bash
93
+ ```
94
+
95
+ 安装完成后:
96
+
97
+ ```bash
98
+ cd ~/codeagent
99
+ bash run.sh
100
+ ```
101
+
102
+ ### 手动安装
103
+
104
+ > ⚠️ CodeAgent 依赖的 `seed` / `seed-model-providers` / `seed-tools` 是**私有包**(不在 PyPI 上),
105
+ > pyproject.toml 使用 `git+https` 自动从 GitHub 拉取。确保已安装 **Git** 且有**网络连接**。
106
+
107
+ ```bash
108
+ # 克隆仓库
109
+ git clone https://github.com/tagword/codeagent.git
110
+ cd codeagent
111
+
112
+ # 创建虚拟环境
113
+ python -m venv .venv
114
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
115
+
116
+ # 安装(自动从 GitHub 拉取 seed 私有依赖)
117
+ pip install -e .
118
+
119
+ # 启动
120
+ codeagent serve
121
+ ```
122
+
123
+ 浏览器打开 `http://localhost:8765` 即可使用。
124
+
125
+ ### 国内用户加速
126
+
127
+ 脚本会自动检测网络环境,如直连 PyPI 超时则自动切换至清华镜像源。也可手动指定:
128
+
129
+ ```bash
130
+ pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple
131
+
132
+ # npm 前端构建(可选)
133
+ cd webui-v2
134
+ npm install --registry=https://registry.npmmirror.com
135
+ npm run build
136
+ ```
137
+
138
+ ### 命令行使用
139
+
140
+ ```bash
141
+ # 查看帮助
142
+ codeagent --help
143
+
144
+ # 启动交互式聊天(LLM + 工具循环)
145
+ codeagent chat --llm
146
+
147
+ # 运行单次任务
148
+ codeagent run "帮我整理当前目录的文件结构"
149
+
150
+ # 管理 Web UI 令牌
151
+ codeagent webui-token init
152
+ codeagent webui-token show
153
+ codeagent webui-token reset
154
+
155
+ # 重启服务
156
+ codeagent restart serve --port 8765
157
+ ```
158
+
159
+ ## 配置
160
+
161
+ ### 首次初始化
162
+
163
+ ```bash
164
+ codeagent config init
165
+ ```
166
+
167
+ 会生成默认配置文件到 `config/` 目录。
168
+
169
+ ### 环境变量
170
+
171
+ 编辑 `config/env`(参考 `config/env.example`),核心配置项:
172
+
173
+ | 配置项 | 说明 |
174
+ |--------|------|
175
+ | `CODEAGENT_PROVIDER` | LLM 提供商(openai / deepseek / anthropic 等) |
176
+ | `CODEAGENT_API_KEY` | API 密钥 |
177
+ | `CODEAGENT_MODEL` | 模型名称 |
178
+ | `CODEAGENT_BASE_URL` | API 端点地址 |
179
+ | `CODEAGENT_AGENT_ID` | 当前 Agent 标识(默认 `default`) |
180
+
181
+ 详细环境变量清单见 [docs/ENV_REFERENCE.md](docs/ENV_REFERENCE.md)。
182
+
183
+ ### Web UI 认证
184
+
185
+ ```bash
186
+ codeagent webui-token init # 生成访问令牌
187
+ codeagent webui-token show # 查看当前令牌
188
+ ```
189
+
190
+ 启动服务后访问 `http://localhost:8765`,输入令牌即可登录。
191
+
192
+ ## 项目结构
193
+
194
+ ```
195
+ codeagent/
196
+ ├── codeagent/ # 核心源码
197
+ │ ├── cli/main.py # 命令行入口
198
+ │ ├── core/ # 核心模块(bootstrap / env / attachments 等)
199
+ │ ├── server/ # HTTP / WebSocket 服务
200
+ │ │ ├── webui_api_app.py # WebUI REST API
201
+ │ │ ├── app_factory.py # Starlette 应用工厂
202
+ │ │ └── ...
203
+ │ ├── web/ # Web 认证与路由
204
+ │ └── webui/ # 内置 Web UI(Vue 版,v1 兼容)
205
+ ├── webui-v2/ # Web UI v2(React + Vite + TypeScript)
206
+ │ ├── src/ # 前端源码
207
+ │ ├── dist/ # 构建产物
208
+ │ └── package.json
209
+ ├── agents/ # Agent 人格配置
210
+ │ ├── default/ # 默认 Agent(agent.md / soul.md / skills.md)
211
+ │ └── test_agent/
212
+ ├── config/ # 运行时配置
213
+ │ ├── env # 环境变量(本地,不提交)
214
+ │ ├── env.example # 环境变量模板
215
+ │ └── codeagent.setup.json
216
+ ├── docs/ # 开发文档与参考
217
+ │ ├── ENV_REFERENCE.md # 完整环境变量手册
218
+ │ ├── AGNES_API.md # API 文档
219
+ │ ├── CONTEXT_COMPACT.md # 上下文压缩机制
220
+ │ └── ...
221
+ ├── skills/ # 可复用的技能定义
222
+ ├── tests/ # 测试
223
+ ├── deploy/ # 部署配置(supervisord)
224
+ ├── run.sh # ★ 一键运行脚本(推荐)
225
+ ├── install.sh # 一键安装脚本
226
+ ├── pyproject.toml # 项目元数据与依赖
227
+ └── README.md
228
+ ```
229
+
230
+ ## Web UI v2
231
+
232
+ 基于 **React 19 + Vite + TypeScript + Tailwind v4** 的现代化前端。
233
+
234
+ ```bash
235
+ cd webui-v2
236
+ npm install
237
+ npm run dev # 开发模式
238
+ npm run build # 生产构建
239
+ ```
240
+
241
+ 也可通过 `run.sh` 或 `codeagent serve` 自动 serve 构建产物。
242
+
243
+ ## 技术栈
244
+
245
+ | 层 | 技术 |
246
+ |----|------|
247
+ | **核心引擎** | seed (LLM 调用 / 路由 / 会话 / 工具运行时) |
248
+ | **后端服务** | Python 3.9+ / Starlette / WebSocket / Uvicorn |
249
+ | **前端 v2** | React 19 / TypeScript / Vite / Tailwind v4 |
250
+ | **前端 v1** | Vanilla JS + CSS(无框架,内置兜底) |
251
+ | **LLM 集成** | OpenAI / Anthropic / DeepSeek / Ollama / 兼容 API |
252
+ | **工具系统** | 异步工具调度 + 安全检查 + 沙箱 |
253
+ | **数据存储** | SQLite(会话 / 记忆 / 项目状态) |
254
+
255
+ ## 开发
256
+
257
+ ```bash
258
+ # 安装开发依赖
259
+ pip install -e '.[dev]'
260
+
261
+ # 运行测试
262
+ pytest
263
+
264
+ # 代码检查
265
+ ruff check codeagent/
266
+
267
+ # 安全审计
268
+ bandit -r codeagent/
269
+ ```
270
+
271
+ ## 许可证
272
+
273
+ [MIT](LICENSE) © 2025 tagword