mirror of
https://github.com/tiennm99/serena.git
synced 2026-09-03 20:22:54 +00:00
Merge branch 'main' of github.com:oraios/serena
This commit is contained in:
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
* :rocket: Serena is a powerful, fully-featured **coding agent that works directly on your codebase**.
|
||||
* :wrench: Serena **integrates with existing LLMs**, providing them with essential **semantic code retrieval and editing tools!**
|
||||
* :free: Serena is **free to use**. No additional API keys or subscriptions required!
|
||||
* :free: Serena is **free to use**. No API keys or subscriptions required!
|
||||
|
||||
Q: Can I have a state-of-the-art coding agent without paying (enormous) API costs
|
||||
or constantly purchasing tokens?
|
||||
@@ -13,15 +13,29 @@ A: Yes, you can!
|
||||
By integrating Serena with your favourite (even free) LLM and thereby enabling it
|
||||
to perform coding tasks directly on your codebase.
|
||||
|
||||
### Demonstration
|
||||
|
||||
Here is a demonstration of Serena implementing a small feature for itself (a better log GUI) with Claude Desktop.
|
||||
Note how Serena's tools enable Claude to find and edit the right symbols.
|
||||
|
||||
https://github.com/user-attachments/assets/6eaa9aa1-610d-4723-a2d6-bf1e487ba753
|
||||
|
||||
### LLM Integration
|
||||
|
||||
Serena provides the necessary [tools](#full-list-of-tools) for coding workflows, but an LLM is required to do the actual work,
|
||||
orchestrating tool use.
|
||||
|
||||
Serena can be integrated with an LLM in several ways:
|
||||
* by using the **model context protocol (MCP)**.
|
||||
Serena provides an MCP server which integrates with Claude (and [soon also ChatGPT](https://x.com/OpenAIDevs/status/1904957755829481737)).
|
||||
* by using **Agno – the model-agnostic agent framework**.
|
||||
* by using **Agno – the model-agnostic agent framework**.
|
||||
Serena's Agno-based agent allows you to turn virtually any LLM into a coding agent, whether it's provided by Google, OpenAI or DeepSeek (with a paid API key)
|
||||
or a free model provided by Ollama, Together or Anyscale.
|
||||
* by incorporating Serena's tools into an agent framework of your choice.
|
||||
Serena's tool implementation is decoupled from the framework-specific code and can thus easily be adapted to any agent framework.
|
||||
|
||||
### Programming Language Support & Semantic Analysis
|
||||
|
||||
Serena's semantic code analysis capabilities build on **language servers** using the widely implemented
|
||||
language server protocol (LSP). The LSP provides a set of versatile code querying
|
||||
and editing functionalities based on symbolic understanding of the code.
|
||||
@@ -41,9 +55,14 @@ With Serena, we provide
|
||||
* Ruby (untested)
|
||||
* Go (untested)
|
||||
* C# (untested)
|
||||
Further languages can easily be supported by providing a shallow adapter for a new language server
|
||||
These languages are supported by the language server library [multilspy](https://github.com/microsoft/multilspy), which Serena uses under the hood.
|
||||
But we did not explicitly test whether the support for these languages actually works.
|
||||
|
||||
Further languages can, in principle, easily be supported by providing a shallow adapter for a new language server
|
||||
implementation.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
<!-- Created with markdown-toc -i README.md -->
|
||||
<!-- Install it with npm install -g markdown-toc -->
|
||||
<!-- toc -->
|
||||
@@ -93,9 +112,9 @@ We thus built Serena with the prospect of being able to cancel most other subscr
|
||||
|
||||
## What Can I Use Serena For?
|
||||
|
||||
You can use Serena for any coding tasks - analyzing, planning, editing and so on.
|
||||
You can use Serena for any coding tasks – analyzing, planning, editing and so on.
|
||||
Serena can read, write and execute code, read logs and the terminal output.
|
||||
Vibe coding is possible, and if you want to almost feel like "the code no longer exists"
|
||||
"Vibe coding" is possible, and if you want to almost feel like "the code no longer exists",
|
||||
you may find Serena even more adequate for vibing than an agent inside an IDE
|
||||
(since you will have a separate GUI that really lets you forget).
|
||||
|
||||
@@ -107,27 +126,35 @@ Vibe coding is possible, and if you want to almost feel like "the code no longer
|
||||
2. Clone the repository to `/path/to/serena`.
|
||||
3. Create a configuration file for your project, say `myproject.yml` based on the template in [myproject.demo.yml](myproject.demo.yml).
|
||||
4. Configure the MCP server in your client.
|
||||
For Claude Desktop, go to File / Settings / Developer / MCP Servers / Edit Config,
|
||||
which will let you open the json file `claude_desktop_config.json`. Add the following (with adjusted paths) to enable Serena:
|
||||
For [Claude Desktop](https://claude.ai/download) (available for Windows and macOS), go to File / Settings / Developer / MCP Servers / Edit Config,
|
||||
which will let you open the JSON file `claude_desktop_config.json`. Add the following (with adjusted paths) to enable Serena:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"serena": {
|
||||
"command": "/abs/path/to/uv",
|
||||
"args": ["run", "--directory", "/abs/path/to/serena", "serena-mcp-server", "/abs/path/to/myproject.yml"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"serena": {
|
||||
"command": "/abs/path/to/uv",
|
||||
"args": ["run", "--directory", "/abs/path/to/serena", "serena-mcp-server", "/abs/path/to/myproject.yml"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
When using paths containing backslashes on Windows, be sure to escape them correctly (`\\`).
|
||||
When using paths containing backslashes on Windows, be sure to escape them correctly (`\\`).
|
||||
|
||||
That's it! Save the config and then restart Claude Desktop (be sure to fully quit the application, as closing Claude will just minimize it to the system tray).
|
||||
You should then see the Serena MCP tools in your chat interface (notice the small hammer icon).
|
||||
That's it! Save the config and then restart Claude Desktop.
|
||||
|
||||
Note that Serena is always configured *for a single project*. To use it for another, you will have to
|
||||
write a new configuration file and adjust the config in the MCP client.
|
||||
⚠️ Be sure to fully quit the Claude Desktop application, as closing Claude will just minimize it to the system tray – at least on Windows.
|
||||
|
||||
After restarting, you should Serena's tools in your chat interface (notice the small hammer icon).
|
||||
|
||||
ℹ️ Note that MCP servers which use stdio as a protocol are somewhat unusual as far as client/server architectures go, as the server
|
||||
necessarily has to be started by the client in order for communication to take place via the server's standard input/output stream.
|
||||
In other words, you do not need to start the server yourself. The client application (e.g. Claude Desktop) takes care of this and
|
||||
therefore needs to be configured with a launch command.
|
||||
|
||||
ℹ️ Furthermore note that Serena is always configured *for a single project*. To use it for another, you will have to
|
||||
write a new configuration file, adjust the configuration to point to it and then restart the client.
|
||||
|
||||
For more information on MCP servers with Claude Desktop, see [the official quick start guide](https://modelcontextprotocol.io/quickstart/user).
|
||||
|
||||
@@ -136,7 +163,7 @@ For more information on MCP servers with Claude Desktop, see [the official quick
|
||||
Agno is a model-agnostic agent framework that allows you to use Serena with a large number of underlying LLMs.
|
||||
|
||||
While Agno is not yet entirely stable, we chose it, because it comes with its own open-source UI,
|
||||
making it easy to directly use the agent.
|
||||
making it easy to directly use the agent using a chat interface.
|
||||
|
||||
Here's how it works (see also [Agno's documentation](https://docs.agno.com/introduction/playground)):
|
||||
|
||||
@@ -176,16 +203,23 @@ Here's how it works (see also [Agno's documentation](https://docs.agno.com/intro
|
||||
Connect the UI to the agent you started above and start chatting. You will have
|
||||
the same tools as in the MCP server version.
|
||||
|
||||
IMPORTANT: Contrary to the MCP server approach, tool execution in the Agno UI does
|
||||
not ask for the user's permission. Note that the shell
|
||||
tool can perform arbitrary code execution. While we have never encountered any issues with
|
||||
this in our testing with Claude, this may not be entirely safe.
|
||||
|
||||
Here is a short demo of Serena performing a small analysis task with the newest Gemini model:
|
||||
|
||||
https://github.com/user-attachments/assets/ccfcb968-277d-4ca9-af7f-b84578858c62
|
||||
|
||||
|
||||
⚠️ IMPORTANT: In contrast to the MCP server approach, tool execution in the Agno UI does
|
||||
not ask for the user's permission. The shell tool is particularly critical, as it can perform arbitrary code execution.
|
||||
While we have never encountered any issues with
|
||||
this in our testing with Claude, allowing this may not be entirely safe.
|
||||
You may choose to disable certain tools for your setup in your Serena project's
|
||||
configuration file (`myproject.yml`).
|
||||
configuration file (`.yml`).
|
||||
|
||||
## Serena's Tools and Configuration
|
||||
|
||||
Serena combines tools for semantic code retrieval with editing capabilities and shell execution.
|
||||
Find the complete list of tools [below](#serenas-tools-and-configuration).
|
||||
|
||||
The use of all tools is generally recommended, as this allows Serena to provide the most value:
|
||||
Only by executing shell commands (in particular, tests) can Serena identify and correct mistakes
|
||||
@@ -210,8 +244,6 @@ without modifying the codebase, you can consider disabling the editing tools in
|
||||
In general, be sure to back up your work and use a version control system in order to avoid
|
||||
losing any work.
|
||||
|
||||
Find the complete list of tools [here](#serenas-tools-and-configuration).
|
||||
|
||||
|
||||
## Comparison with Other Coding Agents
|
||||
|
||||
@@ -219,7 +251,6 @@ To our knowledge, Serena is the first fully-featured coding agent where the
|
||||
entire functionality
|
||||
is available through an MCP server, thus not requiring API keys or
|
||||
subscriptions.
|
||||
Here a brief comparison with other tools:
|
||||
|
||||
### Subscription-Based Coding Agents
|
||||
|
||||
@@ -268,8 +299,7 @@ an API key and bypassing the API costs. This is a unique feature of Serena.
|
||||
|
||||
### Other MCP-Based Coding Agents
|
||||
|
||||
There are other MCP servers meant for coding, like for
|
||||
example [DesktopCommander](https://github.com/wonderwhy-er/DesktopCommanderMCP) and
|
||||
There are other MCP servers designed for coding, like [DesktopCommander](https://github.com/wonderwhy-er/DesktopCommanderMCP) and
|
||||
[codemcp](https://github.com/ezyang/codemcp).
|
||||
However, to the best of our knowledge, none of them provide semantic code
|
||||
retrieval and editing tools; they rely purely on text-based analysis.
|
||||
@@ -277,37 +307,40 @@ It is the integration of language servers and the MCP that makes Serena unique
|
||||
and so powerful for challenging coding tasks, especially in the context of
|
||||
larger codebases.
|
||||
|
||||
## Limitations of MCP Servers
|
||||
## Stability Issues in MCP Client-Server Interactions
|
||||
|
||||
The support for MCP Servers in Claude Desktop and the various MCP Server SDKs are relatively new technologies,
|
||||
and we found them to be flaky. Sometimes Claude Desktop will crash on a tool execution (with an asyncio error or
|
||||
something else of this kind). It can show error messages which have no effect, and on the contrary, fail to
|
||||
show error messages when things go wrong. The working configuration of an MCP server may vary from platform to
|
||||
platform and from client to client (we recommend always using absolute paths, as relative paths may be sources of
|
||||
errors). The language server is running in a separate thread and is called with asyncio - sometimes
|
||||
Claude Desktop lets it crash.
|
||||
We expect these stability issues to improve over time.
|
||||
The support for MCP Servers in Claude Desktop and the various MCP Server SDKs are relatively new developments,
|
||||
and we found them to be somewhat unstable. Sometimes, Claude Desktop will crash on a tool execution (with an asyncio error or
|
||||
something else of this kind). On the one hand, it can display show error messages that are no of consequence, and on the other, it can fail to
|
||||
show error messages when things fail irrecoverably.
|
||||
Yet we expect these stability issues to improve over time.
|
||||
|
||||
For now, you may have to restart Claude Desktop multiple times, may have to manually cleanup python processes,
|
||||
The working configuration of an MCP server may vary from platform to
|
||||
platform and from client to client. We recommend always using absolute paths, as relative paths may be sources of
|
||||
errors. The language server is running in a separate sub-process and is called with asyncio – sometimes
|
||||
Claude Desktop lets it crash. If you have Serena's log window enabled, and it disappears, you'll know what happened.
|
||||
|
||||
For now, you may have to restart Claude Desktop multiple times, may have to manually cleanup lingering processes,
|
||||
and you may experiences freezes in conversations.
|
||||
Just try again in the latter case. You can also switch to the API-key based agent mode if you are willing to pay for a potentially
|
||||
smoother experience (see [section on Agno](#agno)).
|
||||
Just try again in the latter case.
|
||||
Feel free to open issues if you encounter setup problems that you cannot solve.
|
||||
|
||||
### Serena Logging
|
||||
|
||||
To help with troubleshooting, we have written a small GUI utility for logging. We recommend that you enable it
|
||||
through the `myproject.yml` if you encounter problems. For Claude Desktop, there are also the MCP logs that can help
|
||||
through the project configuration (`myproject.yml`) if you encounter problems. For Claude Desktop, there are also the MCP logs that can help
|
||||
identify issues.
|
||||
|
||||
## Onboarding and Memories
|
||||
|
||||
By default, Serena will perform an onboarding process when
|
||||
it is started for the first time for a project. It will save some information
|
||||
as memories to `.serena/memories/` in the project directory.
|
||||
it is started for the first time for a project.
|
||||
The goal of the process is for Serena to get familiar with the project
|
||||
and to store memories, which it can then draw upon in future interactions.
|
||||
|
||||
The memories are human-readable and will be used as references for further tasks.
|
||||
Feel free to read and adjust them as needed, you can also add new ones manually.
|
||||
Memroies are files stored in `.serena/memories/` in the project directory,
|
||||
which the agent can choose to read.
|
||||
Feel free to read and adjust them as needed; you can also add new ones manually.
|
||||
Every file in the `.serena/memories/` directory is a memory file.
|
||||
|
||||
We found the memories to significantly improve the user experience with Serena.
|
||||
@@ -344,8 +377,8 @@ up the context. We recommend that you switch to another conversation
|
||||
once the onboarding is performed in order to not run out of tokens. The onboarding will
|
||||
only be performed once, unless you explicitly trigger it.
|
||||
|
||||
After the onboarding we recommend that you have a quick look at the memories and
|
||||
if desired edit them or add new ones.
|
||||
After the onboarding, we recommend that you have a quick look at the memories and,
|
||||
if necessary, edit them or add additional ones.
|
||||
|
||||
### Before Editing Code
|
||||
|
||||
@@ -354,11 +387,11 @@ this make it easier for you to inspect the changes, but also the model itself wi
|
||||
have a chance of seeing what it has changed by calling `git diff` and thereby
|
||||
correct itself or continue working in a followup conversation if needed.
|
||||
|
||||
**Important**: since Serena will write to files using the system-native line endings
|
||||
:warning: **Important**: since Serena will write to files using the system-native line endings
|
||||
and it might want to look at the git diff, it is important to
|
||||
set `git config core.autocrlf` to `true` on Windows.
|
||||
With `git config core.autocrlf` set to `false` on Windows you may end up with huge diffs
|
||||
only due to line endings. It is generally a good idea to do this on Windows
|
||||
With `git config core.autocrlf` set to `false` on Windows, you may end up with huge diffs
|
||||
only due to line endings. It is generally a good idea to enable this git setting on Windows:
|
||||
|
||||
```shell
|
||||
git config --global core.autocrlf true
|
||||
@@ -366,10 +399,10 @@ git config --global core.autocrlf true
|
||||
|
||||
### Potential Issues in Code Editing
|
||||
|
||||
In our experience, LLMs are really bad at counting, which means they have problems
|
||||
inserting blocks of code at the right place. Most editing operations can be performed
|
||||
on a symbolic level, through which this problem is overcome. However, sometimes
|
||||
insertions beyond that are useful.
|
||||
In our experience, LLMs are really bad at counting, i.e. they have problems
|
||||
inserting blocks of code in the right place. Most editing operations can be performed
|
||||
on a symbolic level, allowing this problem is overcome. However, sometimes,
|
||||
line-level insertions are useful.
|
||||
|
||||
Serena is instructed to double-check the line numbers and any code blocks that it will
|
||||
edit, but you may find it useful to explicitly tell it how to edit code if you run into
|
||||
@@ -378,7 +411,7 @@ problems.
|
||||
### Running Out of Context
|
||||
|
||||
For long and complicated tasks, or tasks where Serena has read a lot of content, you
|
||||
may come close to the limits of context tokens. In that case it is often a good idea to continue
|
||||
may come close to the limits of context tokens. In that case, it is often a good idea to continue
|
||||
in a new conversation. Serena has a dedicated tool to create a summary of the current state
|
||||
of the progress and all relevant info for continuing it. You can request to create this summary and
|
||||
write it to a memory. Then, in a new conversation, you can just ask Serena to read the memory and
|
||||
@@ -410,14 +443,13 @@ typed code - it will not only help you but also help your AI ;).
|
||||
|
||||
### Logging, Linting, and Testing
|
||||
|
||||
Serena cannot debug (no coding assistant can do that at the moment, to our knowledge). This means
|
||||
that for improving the results within an "agent-loop", Serena needs to acquire information by
|
||||
executing tests, running scripts, linting and so on. It is often very helpful to include many log
|
||||
messages with explicit information and to have good tests. Especially the latter often help the agent
|
||||
Serena cannot debug (no coding assistant can do this at the moment, to our knowledge). This means
|
||||
that for improving the results within an _agent loop_, Serena needs to acquire information by
|
||||
executing tests, running scripts, performing linting and so on. It is often very helpful to include many log
|
||||
messages with explicit information and to have meaningful tests. Especially the latter often help the agent
|
||||
to self-correct.
|
||||
|
||||
We generally recommend to start an editing task from a state where all linting checks and tests pass, this
|
||||
way the info extracted from running these commands is of most use to the agent.
|
||||
We generally recommend to start an editing task from a state where all linting checks and tests pass.
|
||||
|
||||
### General Advice
|
||||
|
||||
@@ -430,10 +462,9 @@ and then continue with the implementation in another (potentially after creating
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
We built Serena on top of multiple existing open-source technologies, to which we are very grateful.
|
||||
Here a short list of the most important ones:
|
||||
We built Serena on top of multiple existing open-source technologies, the most important ones being:
|
||||
|
||||
1. [Multilspy](https://github.com/microsoft/multilspy).
|
||||
1. [multilspy](https://github.com/microsoft/multilspy).
|
||||
A beautifully designed wrapper around language servers following the LSP. It
|
||||
was not easily extendable with the symbolic
|
||||
logic that Serena required, so instead of incorporating it as dependency, we
|
||||
@@ -441,12 +472,12 @@ Here a short list of the most important ones:
|
||||
and adapted it to our needs.
|
||||
2. [Python MCP SDK](https://github.com/modelcontextprotocol/python-sdk)
|
||||
3. [Agno](https://github.com/agno-agi/agno) and
|
||||
agno's [agent-ui](https://github.com/agno-agi/agent-ui),
|
||||
which we use to allow Serena to work with any model, not just those that
|
||||
support the MCP.
|
||||
the associated [agent-ui](https://github.com/agno-agi/agent-ui),
|
||||
which we use to allow Serena to work with any model, beyond the ones
|
||||
supporting the MCP.
|
||||
4. All the language servers that we use through multilspy.
|
||||
|
||||
Without these projects, Serena would not have been possible, or would at least much more difficult to build.
|
||||
Without these projects, Serena would not have been possible (or would have been significantly more difficult to build).
|
||||
|
||||
|
||||
## Customizing Serena
|
||||
@@ -459,7 +490,6 @@ to seeing what the community will come up with! For details on contributing, see
|
||||
|
||||
Here the full list of Serena's default tools with a short description (the output of `uv run serena-list-tools`)
|
||||
|
||||
```
|
||||
* `check_onboarding_performed`: Checks whether the onboarding was already performed.
|
||||
* `create_text_file`: Creates/overwrites a file in the project directory.
|
||||
* `delete_lines`: Deletes a range of lines within a file.
|
||||
@@ -485,4 +515,4 @@ Here the full list of Serena's default tools with a short description (the outpu
|
||||
* `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
|
||||
* `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
|
||||
* `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
|
||||
```
|
||||
|
||||
|
||||
+2
-1
@@ -37,7 +37,7 @@ serena-mcp-server = "serena.mcp:start_mcp_server"
|
||||
serena-list-tools = "serena.agent:print_tool_overview"
|
||||
|
||||
[project.license]
|
||||
text = "MIT"
|
||||
text = "GPL-2.0"
|
||||
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
@@ -55,6 +55,7 @@ dev = [
|
||||
agno = [
|
||||
"agno>=1.2.6",
|
||||
"fastapi>=0.115.12",
|
||||
"sqlalchemy>=2.0.40",
|
||||
]
|
||||
anthropic = [
|
||||
"anthropic>=0.49.0",
|
||||
|
||||
+50
-43
@@ -1,7 +1,8 @@
|
||||
import argparse
|
||||
import os
|
||||
from logging import Logger
|
||||
from pathlib import Path
|
||||
|
||||
import click
|
||||
from agno.agent.agent import Agent
|
||||
from agno.memory.agent import AgentMemory
|
||||
from agno.models.anthropic.claude import Claude
|
||||
@@ -10,7 +11,6 @@ from agno.playground.playground import Playground
|
||||
from agno.playground.serve import serve_playground_app
|
||||
from agno.storage.sqlite import SqliteStorage
|
||||
from dotenv import load_dotenv
|
||||
from fastapi import FastAPI
|
||||
from sensai.util import logging
|
||||
from sensai.util.helper import mark_used
|
||||
|
||||
@@ -19,57 +19,64 @@ from serena.agno import SerenaAgnoToolkit
|
||||
|
||||
mark_used(Gemini, Claude)
|
||||
|
||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||
os.chdir(Path(__file__).parent)
|
||||
Logger.root.setLevel(logging.INFO)
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# The app object must be in the module scope so that the server can access it for hot reloading
|
||||
app: FastAPI | None = None
|
||||
|
||||
parser = argparse.ArgumentParser(description="Serena coding assistant")
|
||||
parser.add_argument("--project-file", required=True, help="Path to the project file, either absolute or relative to the root directory")
|
||||
args = parser.parse_args()
|
||||
|
||||
project_file = Path(args.project_file).resolve()
|
||||
# If project file path is relative, make it absolute by joining with project root
|
||||
if not project_file.is_absolute():
|
||||
# Get the project root directory (parent of scripts directory)
|
||||
project_root = Path(__file__).parent.parent
|
||||
project_file = project_root / args.project_file
|
||||
|
||||
# Ensure the path is normalized and absolute
|
||||
project_file = project_file.resolve()
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option("--project-file", default="../myproject.yml", help="Path to the project configuration YAML file")
|
||||
def main(project_file):
|
||||
global app # noqa: PLW0603
|
||||
serena_agent = SerenaAgent(project_file, start_language_server=True)
|
||||
serena_agent = SerenaAgent(str(project_file), start_language_server=True)
|
||||
|
||||
# Even though we don't want to keep history between sessions,
|
||||
# for the agno ui to work as a conversation, we a persistent storage on disk
|
||||
# This storage should be deleted between sessions.
|
||||
# Note that this might collide with custom options for the agent, like adding vector-search based tools.
|
||||
# See here for an explanation: https://www.reddit.com/r/agno/comments/1jk6qea/regarding_the_built_in_memory/
|
||||
sql_db_path = os.path.join("tmp", "agent_storage.db")
|
||||
os.makedirs(os.path.dirname(sql_db_path), exist_ok=True)
|
||||
# delete the db file if it exists
|
||||
if os.path.exists(sql_db_path):
|
||||
os.remove(sql_db_path)
|
||||
# Even though we don't want to keep history between sessions,
|
||||
# for the agno ui to work as a conversation, we a persistent storage on disk
|
||||
# This storage should be deleted between sessions.
|
||||
# Note that this might collide with custom options for the agent, like adding vector-search based tools.
|
||||
# See here for an explanation: https://www.reddit.com/r/agno/comments/1jk6qea/regarding_the_built_in_memory/
|
||||
sql_db_path = Path("tmp") / "agent_storage.db"
|
||||
sql_db_path.parent.mkdir(exist_ok=True)
|
||||
# delete the db file if it exists
|
||||
if sql_db_path.exists():
|
||||
sql_db_path.unlink()
|
||||
|
||||
model = Claude(id="claude-3-7-sonnet-20250219")
|
||||
# Or use any other model supported by agno, e.g. the newest Gemini:
|
||||
# model = Gemini(id="gemini-2.5-pro-exp-03-25")
|
||||
# model = Claude(id="claude-3-7-sonnet-20250219")
|
||||
# Or use any other model supported by agno, e.g. the newest Gemini:
|
||||
model = Gemini(id="gemini-2.5-pro-exp-03-25")
|
||||
|
||||
agno_agent = Agent(
|
||||
name="Serena",
|
||||
model=model,
|
||||
# See explanation above on why storage is needed
|
||||
storage=SqliteStorage(table_name="serena_agent_sessions", db_file=sql_db_path),
|
||||
description="A fully-featured coding assistant",
|
||||
tools=[SerenaAgnoToolkit(serena_agent)], # type: ignore
|
||||
# The tool calls will be shown in the UI anyway since whether to show them is configurable per tool
|
||||
# To see detailed logs, you should use the serena logger (configure it in the project file path)
|
||||
show_tool_calls=False,
|
||||
markdown=True,
|
||||
system_message=serena_agent.prompt_factory.create_system_prompt(),
|
||||
telemetry=False,
|
||||
memory=AgentMemory(),
|
||||
add_history_to_messages=True,
|
||||
num_history_responses=100, # you might want to adjust this (expense vs. history awareness)
|
||||
)
|
||||
agno_agent = Agent(
|
||||
name="Serena",
|
||||
model=model,
|
||||
# See explanation above on why storage is needed
|
||||
storage=SqliteStorage(table_name="serena_agent_sessions", db_file=str(sql_db_path)),
|
||||
description="A fully-featured coding assistant",
|
||||
tools=[SerenaAgnoToolkit(serena_agent)], # type: ignore
|
||||
# The tool calls will be shown in the UI anyway since whether to show them is configurable per tool
|
||||
# To see detailed logs, you should use the serena logger (configure it in the project file path)
|
||||
show_tool_calls=False,
|
||||
markdown=True,
|
||||
system_message=serena_agent.prompt_factory.create_system_prompt(),
|
||||
telemetry=False,
|
||||
memory=AgentMemory(),
|
||||
add_history_to_messages=True,
|
||||
num_history_responses=100, # you might want to adjust this (expense vs. history awareness)
|
||||
)
|
||||
|
||||
app = Playground(agents=[agno_agent]).get_app()
|
||||
serve_playground_app("agno_agent:app", reload=False)
|
||||
app = Playground(agents=[agno_agent]).get_app()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
serve_playground_app("agno_agent:app", reload=False)
|
||||
|
||||
@@ -907,7 +907,7 @@ class LanguageServer:
|
||||
async def request_document_overview(self, relative_file_path: str) -> list[tuple[str, multilspy_types.SymbolKind, int, int]]:
|
||||
"""
|
||||
An overview of the given file.
|
||||
Returns the the list of tuples (name, kind, line, column) of all top-level symbols in the file.
|
||||
Returns the list of tuples (name, kind, line, column) of all top-level symbols in the file.
|
||||
"""
|
||||
_, document_roots = await self.request_document_symbols(relative_file_path)
|
||||
return [
|
||||
@@ -1617,7 +1617,7 @@ class SyncLanguageServer:
|
||||
"""
|
||||
An overview of the given file.
|
||||
|
||||
Returns the the list of tuples (name, kind, line, column) of all top-level symbols in the file.
|
||||
Returns the list of tuples (name, kind, line, column) of all top-level symbols in the file.
|
||||
"""
|
||||
assert self.loop
|
||||
result = asyncio.run_coroutine_threadsafe(
|
||||
|
||||
+1
-1
@@ -501,7 +501,7 @@ class FindReferencingSymbolsTool(Tool):
|
||||
:param include_body: whether to include the body of the symbols in the result.
|
||||
Note that this might lead to a very long output, so you should only use this if you actually need the body
|
||||
of the referencing symbols for the task at hand. Usually it is a better idea to find
|
||||
the referencing symbols without the body and then use the find_symbol tool to get the body of
|
||||
the referencing symbols without the body and then use the find_symbol tool to get the body of
|
||||
specific symbols if needed.
|
||||
:param include_kinds: an optional list of integers representing the LSP symbol kinds to include.
|
||||
If provided, only symbols of the given kinds will be included in the result.
|
||||
|
||||
Reference in New Issue
Block a user