krnl-code 1.0.4__tar.gz

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 (69) hide show
  1. krnl_code-1.0.4/LICENSE +147 -0
  2. krnl_code-1.0.4/NOTICE +4 -0
  3. krnl_code-1.0.4/PKG-INFO +214 -0
  4. krnl_code-1.0.4/README.md +174 -0
  5. krnl_code-1.0.4/krnl_agent/__init__.py +9 -0
  6. krnl_code-1.0.4/krnl_agent/__main__.py +7 -0
  7. krnl_code-1.0.4/krnl_agent/agent_registry.py +95 -0
  8. krnl_code-1.0.4/krnl_agent/agent_selector.py +69 -0
  9. krnl_code-1.0.4/krnl_agent/audit_log.py +155 -0
  10. krnl_code-1.0.4/krnl_agent/background.py +94 -0
  11. krnl_code-1.0.4/krnl_agent/checkpoints.py +67 -0
  12. krnl_code-1.0.4/krnl_agent/ci.py +73 -0
  13. krnl_code-1.0.4/krnl_agent/cli.py +1458 -0
  14. krnl_code-1.0.4/krnl_agent/commands.py +42 -0
  15. krnl_code-1.0.4/krnl_agent/config.py +425 -0
  16. krnl_code-1.0.4/krnl_agent/context.py +352 -0
  17. krnl_code-1.0.4/krnl_agent/depaudit.py +63 -0
  18. krnl_code-1.0.4/krnl_agent/deploy.py +245 -0
  19. krnl_code-1.0.4/krnl_agent/doctor.py +106 -0
  20. krnl_code-1.0.4/krnl_agent/events.py +141 -0
  21. krnl_code-1.0.4/krnl_agent/gitignore.py +47 -0
  22. krnl_code-1.0.4/krnl_agent/graph.py +928 -0
  23. krnl_code-1.0.4/krnl_agent/guardrails.py +70 -0
  24. krnl_code-1.0.4/krnl_agent/headless.py +60 -0
  25. krnl_code-1.0.4/krnl_agent/history.py +49 -0
  26. krnl_code-1.0.4/krnl_agent/hooks.py +72 -0
  27. krnl_code-1.0.4/krnl_agent/ingest.py +129 -0
  28. krnl_code-1.0.4/krnl_agent/llm.py +456 -0
  29. krnl_code-1.0.4/krnl_agent/loop.py +779 -0
  30. krnl_code-1.0.4/krnl_agent/mcp_client.py +128 -0
  31. krnl_code-1.0.4/krnl_agent/memory.py +61 -0
  32. krnl_code-1.0.4/krnl_agent/modelrouter.py +151 -0
  33. krnl_code-1.0.4/krnl_agent/monitor.py +112 -0
  34. krnl_code-1.0.4/krnl_agent/notify.py +119 -0
  35. krnl_code-1.0.4/krnl_agent/parallel_executor.py +139 -0
  36. krnl_code-1.0.4/krnl_agent/permissions.py +128 -0
  37. krnl_code-1.0.4/krnl_agent/plugins.py +105 -0
  38. krnl_code-1.0.4/krnl_agent/pricing.py +85 -0
  39. krnl_code-1.0.4/krnl_agent/prompts.py +60 -0
  40. krnl_code-1.0.4/krnl_agent/repomap.py +133 -0
  41. krnl_code-1.0.4/krnl_agent/sandbox.py +69 -0
  42. krnl_code-1.0.4/krnl_agent/scaffold.py +167 -0
  43. krnl_code-1.0.4/krnl_agent/schedules.py +137 -0
  44. krnl_code-1.0.4/krnl_agent/secrets.py +100 -0
  45. krnl_code-1.0.4/krnl_agent/selfheal.py +87 -0
  46. krnl_code-1.0.4/krnl_agent/server.py +302 -0
  47. krnl_code-1.0.4/krnl_agent/sessions.py +258 -0
  48. krnl_code-1.0.4/krnl_agent/settings.py +59 -0
  49. krnl_code-1.0.4/krnl_agent/skills.py +73 -0
  50. krnl_code-1.0.4/krnl_agent/teams.py +38 -0
  51. krnl_code-1.0.4/krnl_agent/tool_schemas.py +431 -0
  52. krnl_code-1.0.4/krnl_agent/tools.py +694 -0
  53. krnl_code-1.0.4/krnl_agent/webtools.py +139 -0
  54. krnl_code-1.0.4/krnl_code.egg-info/PKG-INFO +214 -0
  55. krnl_code-1.0.4/krnl_code.egg-info/SOURCES.txt +67 -0
  56. krnl_code-1.0.4/krnl_code.egg-info/dependency_links.txt +1 -0
  57. krnl_code-1.0.4/krnl_code.egg-info/entry_points.txt +2 -0
  58. krnl_code-1.0.4/krnl_code.egg-info/requires.txt +26 -0
  59. krnl_code-1.0.4/krnl_code.egg-info/top_level.txt +1 -0
  60. krnl_code-1.0.4/pyproject.toml +48 -0
  61. krnl_code-1.0.4/setup.cfg +4 -0
  62. krnl_code-1.0.4/tests/test_agent.py +1185 -0
  63. krnl_code-1.0.4/tests/test_agent_selector.py +204 -0
  64. krnl_code-1.0.4/tests/test_capabilities.py +670 -0
  65. krnl_code-1.0.4/tests/test_context_phase2.py +248 -0
  66. krnl_code-1.0.4/tests/test_graph.py +478 -0
  67. krnl_code-1.0.4/tests/test_integration.py +138 -0
  68. krnl_code-1.0.4/tests/test_parallel_executor.py +226 -0
  69. krnl_code-1.0.4/tests/test_sessions_phase3.py +228 -0
@@ -0,0 +1,147 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work; and
103
+
104
+ (d) If the Work includes a "NOTICE" text file as part of its
105
+ distribution, then any Derivative Works that You distribute must
106
+ include a readable copy of the attribution notices contained
107
+ within such NOTICE file.
108
+
109
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
110
+ any Contribution intentionally submitted for inclusion in the Work
111
+ by You to the Licensor shall be under the terms and conditions of
112
+ this License, without any additional terms or conditions.
113
+
114
+ 6. Trademarks. This License does not grant permission to use the trade
115
+ names, trademarks, service marks, or product names of the Licensor.
116
+
117
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed
118
+ to in writing, Licensor provides the Work (and each Contributor
119
+ provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES
120
+ OR CONDITIONS OF ANY KIND, either express or implied.
121
+
122
+ 8. Limitation of Liability. In no event and under no legal theory shall
123
+ any Contributor be liable to You for damages, including any direct,
124
+ indirect, special, incidental, or consequential damages of any
125
+ character arising as a result of this License or out of the use or
126
+ inability to use the Work.
127
+
128
+ 9. Accepting Warranty or Additional Liability. While redistributing the
129
+ Work or Derivative Works thereof, You may choose to offer, and charge
130
+ a fee for, acceptance of support, warranty, indemnity, or other
131
+ liability obligations and/or rights consistent with this License.
132
+
133
+ END OF TERMS AND CONDITIONS
134
+
135
+ Copyright 2026 Krnl Engage Sphere Technology Private Limited
136
+
137
+ Licensed under the Apache License, Version 2.0 (the "License");
138
+ you may not use this file except in compliance with the License.
139
+ You may obtain a copy of the License at
140
+
141
+ http://www.apache.org/licenses/LICENSE-2.0
142
+
143
+ Unless required by applicable law or agreed to in writing, software
144
+ distributed under the License is distributed on an "AS IS" BASIS,
145
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
146
+ See the License for the specific language governing permissions and
147
+ limitations under the License.
krnl_code-1.0.4/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ Krnl Coding Agent
2
+ Copyright 2026 Krnl Engage Sphere Technology Private Limited
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
@@ -0,0 +1,214 @@
1
+ Metadata-Version: 2.4
2
+ Name: krnl-code
3
+ Version: 1.0.4
4
+ Summary: Lightweight provider-agnostic agentic coding backend (CLI + server) for the Krnl VS Code extension.
5
+ Author: Krnl Agent contributors
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/Saurabh7Goku/Krnl-Coding-Agent
8
+ Project-URL: Issues, https://github.com/Saurabh7Goku/Krnl-Coding-Agent/issues
9
+ Keywords: ai,agent,coding,llm,cli,vscode
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Environment :: Console
14
+ Requires-Python: >=3.9
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ License-File: NOTICE
18
+ Requires-Dist: fastapi>=0.110
19
+ Requires-Dist: uvicorn[standard]>=0.29
20
+ Requires-Dist: pydantic>=2.6
21
+ Requires-Dist: python-dotenv>=1.0
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: openai>=1.30
24
+ Requires-Dist: httpx>=0.27
25
+ Requires-Dist: rich>=13.7
26
+ Requires-Dist: prompt_toolkit>=3.0
27
+ Requires-Dist: networkx>=3.0
28
+ Provides-Extra: anthropic
29
+ Requires-Dist: anthropic>=0.34; extra == "anthropic"
30
+ Provides-Extra: mcp
31
+ Requires-Dist: mcp>=1.0; extra == "mcp"
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest>=8.0; extra == "dev"
34
+ Provides-Extra: graph
35
+ Requires-Dist: tree-sitter>=0.21; extra == "graph"
36
+ Requires-Dist: tree-sitter-python>=0.21; extra == "graph"
37
+ Provides-Extra: all
38
+ Requires-Dist: krnl-code[anthropic,graph,mcp]; extra == "all"
39
+ Dynamic: license-file
40
+
41
+ # krnl-coding-agent
42
+
43
+ The Python agent backend and standalone CLI behind the Krnl Coding Agent VS Code
44
+ extension. An open-source, model-agnostic agentic coding assistant that plans,
45
+ edits code, runs commands, searches the web, reviews diffs, coordinates teams of
46
+ sub-agents, and runs on cron schedules - with your approval at every step.
47
+
48
+ Provider-agnostic: works with Anthropic, OpenAI, Google Gemini, OpenRouter, Groq,
49
+ Cerebras, DeepSeek, Together, Mistral, xAI, Vercel AI Gateway, Krnl,
50
+ Ollama, LM Studio, or any OpenAI-compatible / self-hosted endpoint.
51
+
52
+ ## Install
53
+
54
+ pip install krnl-coding-agent
55
+ krnl-agent update # update to the latest anytime
56
+ # optional extras:
57
+ pip install "krnl-coding-agent[anthropic]" # native Anthropic client
58
+ pip install "krnl-coding-agent[mcp]" # Model Context Protocol servers
59
+
60
+ Tip: install into a virtual environment for isolation. The client auto-adapts to
61
+ each provider's API (e.g. models needing max_completion_tokens instead of
62
+ max_tokens, or rejecting a custom temperature) - no model-specific config needed.
63
+
64
+ ## Quick start (CLI)
65
+
66
+ krnl-agent # interactive chat in the current folder
67
+ krnl-agent run "add a /health route to app.py"
68
+ krnl-agent run "summarize the repo" --json # headless JSON output for CI/scripts
69
+ krnl-agent serve --host 0.0.0.0 --port 8000 # self-host with bearer-token auth
70
+
71
+ Set a provider and key right inside the chat (no files needed):
72
+
73
+ you: /provider openai # or gemini, anthropic, groq, ollama, ...
74
+ you: /key # paste your API key (stored in ~/.krnl-agent)
75
+ you: create a FastAPI hello-world app with a test
76
+
77
+ Or use environment variables (OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY,
78
+ KRL_API_KEY, ...) or a config.yaml. Built-in provider profiles mean no config
79
+ file is required - just pick a provider and supply a key.
80
+
81
+ ## CLI commands
82
+
83
+ krnl-agent interactive chat (remembers provider/key)
84
+ krnl-agent run "<task>" one-shot task ( --yes to auto-approve, --json headless )
85
+ krnl-agent providers list configured providers
86
+ krnl-agent models show the multi-model routing table (per-phase model + price)
87
+ krnl-agent init scaffold config.yaml + .env
88
+ krnl-agent serve run the API / WebSocket server ( --port 0 = auto )
89
+ krnl-agent --team-name <name> "<task>" multi-agent team (coordinator + specialists)
90
+ krnl-agent team list multi-agent teams
91
+ krnl-agent schedule create "<name>" --cron "0 9 * * MON-FRI" --prompt "<task>"
92
+ krnl-agent schedule list | run <id> | remove <id> | daemon
93
+ krnl-agent plugin add <dir|zip-url> | list | remove <name>
94
+ krnl-agent security run a security audit of the codebase
95
+ krnl-agent scan fast secret + dependency vulnerability scan
96
+ krnl-agent secfix autonomous security remediation (audit→fix→verify)
97
+ krnl-agent test [--all] write + run tests (--all = whole-project suite)
98
+ krnl-agent ship "<what>" plan→build→test→scan→deploy→monitor, end to end
99
+ krnl-agent deploy [--check] deploy to a live URL (or list target readiness)
100
+ krnl-agent monitor monitoring status (errors/uptime/providers)
101
+ krnl-agent heal [<url>] self-heal: health-check, auto-rollback, error→PR
102
+ krnl-agent doctor environment self-check
103
+ krnl-agent audit [--lines N] show & verify the tamper-evident action log
104
+ krnl-agent init-ci scaffold a GitHub Actions workflow
105
+ krnl-agent sessions list saved sessions (dashboard)
106
+ krnl-agent chat --session <id> | --resume resume a past session
107
+
108
+ In-chat commands: /provider /key /model /effort /plan /execute /review /security
109
+ /scan /secfix /test /testall /audit /doctor /compact /init /skills /search /usage
110
+ /undo /reset /yes /help /exit, plus any custom command in .krnl/commands/.
111
+
112
+ ## What's new (1.4.0)
113
+
114
+ - **The full loop — one sentence to a live, monitored, self-healing app.**
115
+ `krnl-agent ship "build a FastAPI todo API with a Neon DB and put it live"` runs
116
+ plan → build → test → security-scan → **deploy** → **monitor**.
117
+ - **Auto-deploy** headless to Cloud Run, Cloudflare/Pages, Vercel, Netlify, Render,
118
+ Fly, Railway, Docker, Kubernetes/Helm, AWS (SAM/App Runner), Azure Container Apps,
119
+ plus Neon/Supabase databases — each via its CLI + a credential env var.
120
+ - **Spend gate:** free-tier targets deploy directly; billable ones are blocked unless
121
+ you set `deploy.allow_billable`. Secrets are read from env, never printed, and every
122
+ deploy/rollback is recorded in the audit log.
123
+ - **Monitoring** (`krnl-agent monitor`): wires Sentry / OpenTelemetry / uptime and
124
+ reports current errors + uptime.
125
+ - **Self-healing** (`krnl-agent heal`): auto-rollback to the last known-good release
126
+ on a failed health check; production errors become a fix + regression test in a PR
127
+ (never auto-merged). See docs/DEPLOY.md.
128
+
129
+ ## What's new (1.3.0)
130
+
131
+ - **Multi-model routing**: assign a different model (from any provider) to each
132
+ phase — `planner`, `executor`, `cheap` (sub-agents), `verifier` — via `models:` +
133
+ `routing:` in config.yaml. Cost-aware `strategy: auto` runs cheap models where safe
134
+ and **auto-escalates** to a stronger model when the cheaper one keeps failing, so
135
+ you spend the least that still gets the job done. No provider lock-in.
136
+ - `krnl-agent models` / `/models`: see which model + price runs each phase.
137
+ - Cost is now tracked per model actually used. See docs/MULTI_MODEL.md.
138
+
139
+ ## What's new (1.2.0)
140
+
141
+ - **repo_map** tool: a compact symbol/outline map of the codebase so the agent
142
+ reads outlines first and full file bodies only on demand (token-saving).
143
+ - **secret_scan** + **dependency_audit** tools, and **/scan** / **/secfix**
144
+ commands — find hard-coded credentials and vulnerable deps, then remediate in an
145
+ autonomous audit → fix → verify loop.
146
+ - **Tamper-evident audit log** (`.krnl/audit/`) — SHA-256 hash-chained record of
147
+ every action; `krnl-agent audit` / `/audit` verifies the chain.
148
+ - **Sandbox / egress policy** (`sandbox:`): deny-by-default command rules, allowlist,
149
+ and `block_network`, enforced before every shell command (even in dangerous mode).
150
+ - **Agent-of-agent budgets** (`subagent_max_calls`, `subagent_token_budget`),
151
+ **model routing** (`router: {cheap, heavy}`), an opt-in **verifier** sub-agent
152
+ (`verify_edits`), and **self-heal** (`self_heal: N`).
153
+ - **krnl-agent doctor** (environment self-check), **init-ci** (GitHub Actions),
154
+ and **Anthropic prompt caching** of the static system prompt.
155
+
156
+ ## What's new (1.1.0)
157
+
158
+ - Drag-and-drop context: reference or drop a **file, folder, or image** path into
159
+ chat and it is read and used automatically. Files of any reasonable length
160
+ (smart head+tail truncation), folders read recursively, and images sent as
161
+ multimodal blocks so vision models can actually see them. No special syntax -
162
+ quoted paths, absolute/relative paths, bare filenames, and `@mentions` all work.
163
+ - Built-in **security audit** (`/security`, `krnl-agent security`): vulnerability
164
+ review with severity-ranked findings and concrete fixes.
165
+ - **Autonomous testing**: `/test [target]` writes and runs tests for a file/module;
166
+ `/testall` (or `krnl-agent test --all`) builds and runs a comprehensive test
167
+ suite for the whole project and reports coverage gaps.
168
+ - **Plan mode and execute mode**, switchable mid-session with `/plan` and
169
+ `/execute` (execute is the default).
170
+ - Earlier: auto-onboarding (`.krnl/` memory + skill + project doc), live status
171
+ line + completion summary, dangerous (YOLO) mode, `/` command autocomplete,
172
+ accurate per-model cost, and memory/context optimization.
173
+
174
+ ## Features
175
+
176
+ - Auto-onboarding (.krnl/ memory + skill + project doc, created automatically).
177
+ - Agentic tool-calling loop: plan, read, search, edit, run, verify.
178
+ - 28 sandboxed tools: read/write/edit/multi_edit/create/delete files, glob,
179
+ search, run_command (streaming), background processes, git status/diff/commit/
180
+ branch/push, open_pr, git worktrees, web_search, web_fetch.
181
+ - Plan mode and execute mode, sub-agents, and multi-agent teams with persistent state.
182
+ - Drag-and-drop context: read files (any length), whole folders, and images.
183
+ - Full loop: one sentence → build → test → scan → deploy to a live URL → monitor → self-heal.
184
+ - Auto-deploy to 13+ targets (Cloud Run/Cloudflare/Vercel/Netlify/Fly/Railway/Render/Docker/K8s/AWS/Azure + Neon/Supabase) with a free-tier-first spend gate.
185
+ - Multi-model routing: a different model per phase across providers, cost-aware with auto-escalation.
186
+ - Token-friendly code intelligence: `repo_map` outline tool, model routing, prompt caching.
187
+ - Security suite: `/security`, `/scan`, `/secfix`, secret_scan + dependency_audit tools.
188
+ - Tamper-evident audit log + sandbox/egress policy; sub-agent budgets, verifier, self-heal.
189
+ - Autonomous test writing/running (`/test`, `/testall`); `doctor` + `init-ci` helpers.
190
+ - Scheduled agents on cron schedules (independent of any terminal).
191
+ - MCP servers, plugins, skills, project memory (AGENTS.md), and custom commands.
192
+ - Permissions (allow/ask/deny), hooks, approvals with diffs, checkpoints, undo.
193
+ - Web search/fetch, multimodal image input, token and cost tracking, extended
194
+ thinking, model fallback chains.
195
+ - Messaging notifications: Slack, Discord, Telegram, Google Chat, WhatsApp, Linear.
196
+ - Headless JSON mode and a self-hostable server with bearer-token auth.
197
+
198
+ ## Server
199
+
200
+ - GET /health liveness.
201
+ - GET /providers configured providers.
202
+ - POST /agent/run one-shot, non-interactive (set "auto_approve": true).
203
+ - WS /ws streaming agent with per-action approval (used by the extension).
204
+
205
+ The WebSocket init message accepts provider, model, api_key, and base_url so
206
+ secrets never need to live on disk. Set KRNL_AGENT_TOKEN (or serve --token) to
207
+ require bearer auth.
208
+
209
+ See the project README at https://github.com/krnl-tech/Krnl-coding-agent for the
210
+ full architecture and the VS Code extension.
211
+
212
+ ## License
213
+
214
+ Apache License 2.0. Copyright 2026 Krnl Engage Sphere Technology Private Limited.
@@ -0,0 +1,174 @@
1
+ # krnl-coding-agent
2
+
3
+ The Python agent backend and standalone CLI behind the Krnl Coding Agent VS Code
4
+ extension. An open-source, model-agnostic agentic coding assistant that plans,
5
+ edits code, runs commands, searches the web, reviews diffs, coordinates teams of
6
+ sub-agents, and runs on cron schedules - with your approval at every step.
7
+
8
+ Provider-agnostic: works with Anthropic, OpenAI, Google Gemini, OpenRouter, Groq,
9
+ Cerebras, DeepSeek, Together, Mistral, xAI, Vercel AI Gateway, Krnl,
10
+ Ollama, LM Studio, or any OpenAI-compatible / self-hosted endpoint.
11
+
12
+ ## Install
13
+
14
+ pip install krnl-coding-agent
15
+ krnl-agent update # update to the latest anytime
16
+ # optional extras:
17
+ pip install "krnl-coding-agent[anthropic]" # native Anthropic client
18
+ pip install "krnl-coding-agent[mcp]" # Model Context Protocol servers
19
+
20
+ Tip: install into a virtual environment for isolation. The client auto-adapts to
21
+ each provider's API (e.g. models needing max_completion_tokens instead of
22
+ max_tokens, or rejecting a custom temperature) - no model-specific config needed.
23
+
24
+ ## Quick start (CLI)
25
+
26
+ krnl-agent # interactive chat in the current folder
27
+ krnl-agent run "add a /health route to app.py"
28
+ krnl-agent run "summarize the repo" --json # headless JSON output for CI/scripts
29
+ krnl-agent serve --host 0.0.0.0 --port 8000 # self-host with bearer-token auth
30
+
31
+ Set a provider and key right inside the chat (no files needed):
32
+
33
+ you: /provider openai # or gemini, anthropic, groq, ollama, ...
34
+ you: /key # paste your API key (stored in ~/.krnl-agent)
35
+ you: create a FastAPI hello-world app with a test
36
+
37
+ Or use environment variables (OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY,
38
+ KRL_API_KEY, ...) or a config.yaml. Built-in provider profiles mean no config
39
+ file is required - just pick a provider and supply a key.
40
+
41
+ ## CLI commands
42
+
43
+ krnl-agent interactive chat (remembers provider/key)
44
+ krnl-agent run "<task>" one-shot task ( --yes to auto-approve, --json headless )
45
+ krnl-agent providers list configured providers
46
+ krnl-agent models show the multi-model routing table (per-phase model + price)
47
+ krnl-agent init scaffold config.yaml + .env
48
+ krnl-agent serve run the API / WebSocket server ( --port 0 = auto )
49
+ krnl-agent --team-name <name> "<task>" multi-agent team (coordinator + specialists)
50
+ krnl-agent team list multi-agent teams
51
+ krnl-agent schedule create "<name>" --cron "0 9 * * MON-FRI" --prompt "<task>"
52
+ krnl-agent schedule list | run <id> | remove <id> | daemon
53
+ krnl-agent plugin add <dir|zip-url> | list | remove <name>
54
+ krnl-agent security run a security audit of the codebase
55
+ krnl-agent scan fast secret + dependency vulnerability scan
56
+ krnl-agent secfix autonomous security remediation (audit→fix→verify)
57
+ krnl-agent test [--all] write + run tests (--all = whole-project suite)
58
+ krnl-agent ship "<what>" plan→build→test→scan→deploy→monitor, end to end
59
+ krnl-agent deploy [--check] deploy to a live URL (or list target readiness)
60
+ krnl-agent monitor monitoring status (errors/uptime/providers)
61
+ krnl-agent heal [<url>] self-heal: health-check, auto-rollback, error→PR
62
+ krnl-agent doctor environment self-check
63
+ krnl-agent audit [--lines N] show & verify the tamper-evident action log
64
+ krnl-agent init-ci scaffold a GitHub Actions workflow
65
+ krnl-agent sessions list saved sessions (dashboard)
66
+ krnl-agent chat --session <id> | --resume resume a past session
67
+
68
+ In-chat commands: /provider /key /model /effort /plan /execute /review /security
69
+ /scan /secfix /test /testall /audit /doctor /compact /init /skills /search /usage
70
+ /undo /reset /yes /help /exit, plus any custom command in .krnl/commands/.
71
+
72
+ ## What's new (1.4.0)
73
+
74
+ - **The full loop — one sentence to a live, monitored, self-healing app.**
75
+ `krnl-agent ship "build a FastAPI todo API with a Neon DB and put it live"` runs
76
+ plan → build → test → security-scan → **deploy** → **monitor**.
77
+ - **Auto-deploy** headless to Cloud Run, Cloudflare/Pages, Vercel, Netlify, Render,
78
+ Fly, Railway, Docker, Kubernetes/Helm, AWS (SAM/App Runner), Azure Container Apps,
79
+ plus Neon/Supabase databases — each via its CLI + a credential env var.
80
+ - **Spend gate:** free-tier targets deploy directly; billable ones are blocked unless
81
+ you set `deploy.allow_billable`. Secrets are read from env, never printed, and every
82
+ deploy/rollback is recorded in the audit log.
83
+ - **Monitoring** (`krnl-agent monitor`): wires Sentry / OpenTelemetry / uptime and
84
+ reports current errors + uptime.
85
+ - **Self-healing** (`krnl-agent heal`): auto-rollback to the last known-good release
86
+ on a failed health check; production errors become a fix + regression test in a PR
87
+ (never auto-merged). See docs/DEPLOY.md.
88
+
89
+ ## What's new (1.3.0)
90
+
91
+ - **Multi-model routing**: assign a different model (from any provider) to each
92
+ phase — `planner`, `executor`, `cheap` (sub-agents), `verifier` — via `models:` +
93
+ `routing:` in config.yaml. Cost-aware `strategy: auto` runs cheap models where safe
94
+ and **auto-escalates** to a stronger model when the cheaper one keeps failing, so
95
+ you spend the least that still gets the job done. No provider lock-in.
96
+ - `krnl-agent models` / `/models`: see which model + price runs each phase.
97
+ - Cost is now tracked per model actually used. See docs/MULTI_MODEL.md.
98
+
99
+ ## What's new (1.2.0)
100
+
101
+ - **repo_map** tool: a compact symbol/outline map of the codebase so the agent
102
+ reads outlines first and full file bodies only on demand (token-saving).
103
+ - **secret_scan** + **dependency_audit** tools, and **/scan** / **/secfix**
104
+ commands — find hard-coded credentials and vulnerable deps, then remediate in an
105
+ autonomous audit → fix → verify loop.
106
+ - **Tamper-evident audit log** (`.krnl/audit/`) — SHA-256 hash-chained record of
107
+ every action; `krnl-agent audit` / `/audit` verifies the chain.
108
+ - **Sandbox / egress policy** (`sandbox:`): deny-by-default command rules, allowlist,
109
+ and `block_network`, enforced before every shell command (even in dangerous mode).
110
+ - **Agent-of-agent budgets** (`subagent_max_calls`, `subagent_token_budget`),
111
+ **model routing** (`router: {cheap, heavy}`), an opt-in **verifier** sub-agent
112
+ (`verify_edits`), and **self-heal** (`self_heal: N`).
113
+ - **krnl-agent doctor** (environment self-check), **init-ci** (GitHub Actions),
114
+ and **Anthropic prompt caching** of the static system prompt.
115
+
116
+ ## What's new (1.1.0)
117
+
118
+ - Drag-and-drop context: reference or drop a **file, folder, or image** path into
119
+ chat and it is read and used automatically. Files of any reasonable length
120
+ (smart head+tail truncation), folders read recursively, and images sent as
121
+ multimodal blocks so vision models can actually see them. No special syntax -
122
+ quoted paths, absolute/relative paths, bare filenames, and `@mentions` all work.
123
+ - Built-in **security audit** (`/security`, `krnl-agent security`): vulnerability
124
+ review with severity-ranked findings and concrete fixes.
125
+ - **Autonomous testing**: `/test [target]` writes and runs tests for a file/module;
126
+ `/testall` (or `krnl-agent test --all`) builds and runs a comprehensive test
127
+ suite for the whole project and reports coverage gaps.
128
+ - **Plan mode and execute mode**, switchable mid-session with `/plan` and
129
+ `/execute` (execute is the default).
130
+ - Earlier: auto-onboarding (`.krnl/` memory + skill + project doc), live status
131
+ line + completion summary, dangerous (YOLO) mode, `/` command autocomplete,
132
+ accurate per-model cost, and memory/context optimization.
133
+
134
+ ## Features
135
+
136
+ - Auto-onboarding (.krnl/ memory + skill + project doc, created automatically).
137
+ - Agentic tool-calling loop: plan, read, search, edit, run, verify.
138
+ - 28 sandboxed tools: read/write/edit/multi_edit/create/delete files, glob,
139
+ search, run_command (streaming), background processes, git status/diff/commit/
140
+ branch/push, open_pr, git worktrees, web_search, web_fetch.
141
+ - Plan mode and execute mode, sub-agents, and multi-agent teams with persistent state.
142
+ - Drag-and-drop context: read files (any length), whole folders, and images.
143
+ - Full loop: one sentence → build → test → scan → deploy to a live URL → monitor → self-heal.
144
+ - Auto-deploy to 13+ targets (Cloud Run/Cloudflare/Vercel/Netlify/Fly/Railway/Render/Docker/K8s/AWS/Azure + Neon/Supabase) with a free-tier-first spend gate.
145
+ - Multi-model routing: a different model per phase across providers, cost-aware with auto-escalation.
146
+ - Token-friendly code intelligence: `repo_map` outline tool, model routing, prompt caching.
147
+ - Security suite: `/security`, `/scan`, `/secfix`, secret_scan + dependency_audit tools.
148
+ - Tamper-evident audit log + sandbox/egress policy; sub-agent budgets, verifier, self-heal.
149
+ - Autonomous test writing/running (`/test`, `/testall`); `doctor` + `init-ci` helpers.
150
+ - Scheduled agents on cron schedules (independent of any terminal).
151
+ - MCP servers, plugins, skills, project memory (AGENTS.md), and custom commands.
152
+ - Permissions (allow/ask/deny), hooks, approvals with diffs, checkpoints, undo.
153
+ - Web search/fetch, multimodal image input, token and cost tracking, extended
154
+ thinking, model fallback chains.
155
+ - Messaging notifications: Slack, Discord, Telegram, Google Chat, WhatsApp, Linear.
156
+ - Headless JSON mode and a self-hostable server with bearer-token auth.
157
+
158
+ ## Server
159
+
160
+ - GET /health liveness.
161
+ - GET /providers configured providers.
162
+ - POST /agent/run one-shot, non-interactive (set "auto_approve": true).
163
+ - WS /ws streaming agent with per-action approval (used by the extension).
164
+
165
+ The WebSocket init message accepts provider, model, api_key, and base_url so
166
+ secrets never need to live on disk. Set KRNL_AGENT_TOKEN (or serve --token) to
167
+ require bearer auth.
168
+
169
+ See the project README at https://github.com/krnl-tech/Krnl-coding-agent for the
170
+ full architecture and the VS Code extension.
171
+
172
+ ## License
173
+
174
+ Apache License 2.0. Copyright 2026 Krnl Engage Sphere Technology Private Limited.
@@ -0,0 +1,9 @@
1
+ """Krnl Agent — a lightweight, provider-agnostic agentic coding backend.
2
+
3
+ Public surface:
4
+ from krnl_agent.config import load_config
5
+ from krnl_agent.llm import build_client
6
+ from krnl_agent.loop import AgentSession
7
+ """
8
+
9
+ __version__ = "1.4.0"
@@ -0,0 +1,7 @@
1
+ """Enable `python -m krnl_agent ...` (used by the VS Code auto-start)."""
2
+ import sys
3
+
4
+ from .cli import main
5
+
6
+ if __name__ == "__main__":
7
+ sys.exit(main())
@@ -0,0 +1,95 @@
1
+ """Agent Registry for Phase 4: Agent Specialization.
2
+
3
+ Defines specialized agents for different tasks (frontend, backend, testing, docs)
4
+ with routing criteria based on keywords and file patterns.
5
+ """
6
+ from __future__ import annotations
7
+
8
+ from dataclasses import dataclass, field
9
+ from typing import Optional
10
+
11
+
12
+ @dataclass
13
+ class AgentDefinition:
14
+ """Definition of a specialized agent."""
15
+ name: str
16
+ keywords: list[str] = field(default_factory=list)
17
+ file_patterns: list[str] = field(default_factory=list)
18
+ description: str = ""
19
+
20
+
21
+ # Default agent registry
22
+ DEFAULT_AGENTS = [
23
+ AgentDefinition(
24
+ name="frontend",
25
+ keywords=["css", "html", "react", "vue", "frontend", "ui", "component"],
26
+ file_patterns=["*.css", "*.html", "*.jsx", "*.tsx", "*.vue"],
27
+ description="Specializes in frontend development, UI components, and styling.",
28
+ ),
29
+ AgentDefinition(
30
+ name="backend",
31
+ keywords=["api", "server", "backend", "endpoint", "service"],
32
+ file_patterns=["*.py", "*.js", "*.go", "*.rs", "*.java"],
33
+ description="Specializes in backend development, APIs, and server-side logic.",
34
+ ),
35
+ AgentDefinition(
36
+ name="testing",
37
+ keywords=["test", "spec", "pytest", "jest", "unit", "integration"],
38
+ file_patterns=["*test*.py", "test_*.py", "*.spec.js", "*.test.js"],
39
+ description="Specializes in writing and debugging tests.",
40
+ ),
41
+ AgentDefinition(
42
+ name="docs",
43
+ keywords=["doc", "readme", "markdown", "documentation"],
44
+ file_patterns=["*.md", "*.rst", "*.txt"],
45
+ description="Specializes in documentation and README files.",
46
+ ),
47
+ AgentDefinition(
48
+ name="database",
49
+ keywords=["sql", "schema", "migrate", "postgres", "db", "table", "query", "database"],
50
+ file_patterns=["*.sql", "*migrate*.py", "*schema*.py"],
51
+ description="Specializes in database schema design, migrations, and query performance.",
52
+ ),
53
+ AgentDefinition(
54
+ name="devops",
55
+ keywords=["docker", "kubernetes", "k8s", "ci", "cd", "workflow", "actions", "deployment", "terraform"],
56
+ file_patterns=["Dockerfile", "docker-compose.yml", "*.yaml", "*.yml", "*.tf"],
57
+ description="Specializes in CI/CD pipelines, containerization, deployment, and infrastructure.",
58
+ ),
59
+ AgentDefinition(
60
+ name="security",
61
+ keywords=["security", "auth", "login", "encrypt", "decrypt", "scan", "audit", "secrets"],
62
+ file_patterns=["*auth*.py", "*security*.py", "jwt*.py"],
63
+ description="Specializes in secure authentication, authorization, vulnerability scanning, and credentials handling.",
64
+ ),
65
+ ]
66
+
67
+
68
+ class AgentRegistry:
69
+ """Registry of specialized agents."""
70
+
71
+ def __init__(self, agents: Optional[list[AgentDefinition]] = None):
72
+ self.agents = agents or [AgentDefinition(**a.__dict__) for a in DEFAULT_AGENTS]
73
+
74
+ def get_agent(self, name: str) -> Optional[AgentDefinition]:
75
+ """Get an agent definition by name."""
76
+ for agent in self.agents:
77
+ if agent.name == name:
78
+ return agent
79
+ return None
80
+
81
+ def list_agents(self) -> list[AgentDefinition]:
82
+ """List all registered agents."""
83
+ return self.agents.copy()
84
+
85
+ def add_agent(self, agent: AgentDefinition) -> None:
86
+ """Add a new agent to the registry."""
87
+ self.agents.append(agent)
88
+
89
+ def remove_agent(self, name: str) -> bool:
90
+ """Remove an agent from the registry. Returns True if removed."""
91
+ for i, agent in enumerate(self.agents):
92
+ if agent.name == name:
93
+ self.agents.pop(i)
94
+ return True
95
+ return False