mirror of
https://github.com/giancarloerra/socraticode.git
synced 2026-07-03 14:05:21 +02:00
feat(extension): add VS Code and Open VSX extension
A new top-level `extension/` package containing the SocratiCode VS Code extension. The same `.vsix` artefact ships to both VS Code Marketplace and Open VSX, which means it installs cleanly in Cursor, VSCodium, Gitpod, code-server, Eclipse Theia editors, Google Antigravity, and Particle Workbench in addition to stock VS Code. What it does: - Auto-registers the SocratiCode MCP server in VS Code's MCP host via `vscode.lm.registerMcpServerDefinitionProvider` (VS Code 1.99+). Copilot agent mode, Cline, Continue, Roo Code and any other MCP-aware client see SocratiCode's tools without the user editing any `.vscode/mcp.json`. - Forwards the user's `socraticode.env` setting to the engine subprocess unchanged. Power users point at an external Qdrant (`QDRANT_MODE=external` + `QDRANT_URL` + `QDRANT_API_KEY`), pick an embedding provider, or set any other engine knob exactly as documented in the engine README. - Activity Bar sidebar with "Indexed projects" tree view and welcome content. Discovers projects by listing graph artefacts the engine writes to `os.tmpdir()/socraticode-graph/`. - Webview panel for the interactive graph (`graphPanel.ts`). Reads the engine's self-contained HTML, wraps it with a tight CSP, injects a bridge script so node-clicks can `postMessage` back to the extension and open files in the editor. - Status-bar item showing "SocratiCode" with click-to-open-sidebar. Honours the `socraticode.statusBar` setting. - Two-step getting-started walkthrough (index your project, try search and the interactive graph). Shown automatically on first install; re-openable via the command palette. - Command palette commands: index workspace, open graph, refresh projects, open walkthrough, show output. - Output channel for engine logs. Build: esbuild bundles `src/extension.ts` to `dist/extension.js` (CJS, node18, sourcemap), `vscode` external. Biome lint and `tsc` strict mode both clean. Manifest smoke tests via Node's built-in test runner catch package.json regressions before activation. Packaged size: ~215 KB `.vsix`. Versioning: extension version tracks the engine version (currently `1.7.2`). Patch drift is allowed for extension-only hotfixes. The `scripts/bump-plugin-versions.mjs` hook from the previous commit already includes `extension/package.json` in its bump list, so future engine releases keep the extension in lockstep automatically.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
node_modules/
|
||||
dist/
|
||||
*.vsix
|
||||
.vscode-test/
|
||||
@@ -0,0 +1,13 @@
|
||||
.vscode/**
|
||||
.vscode-test/**
|
||||
src/**
|
||||
**/*.ts
|
||||
**/*.map
|
||||
.gitignore
|
||||
.eslintrc.json
|
||||
biome.json
|
||||
esbuild.config.mjs
|
||||
tsconfig.json
|
||||
**/*.test.ts
|
||||
**/__tests__/**
|
||||
node_modules/**
|
||||
@@ -0,0 +1,32 @@
|
||||
# SocratiCode VS Code / Open VSX extension changelog
|
||||
|
||||
All notable changes to the extension are documented here. The extension
|
||||
version tracks the engine version where possible.
|
||||
|
||||
## 1.7.2
|
||||
|
||||
Initial release.
|
||||
|
||||
### Features
|
||||
|
||||
- Auto-registers the SocratiCode MCP server in VS Code's MCP host (Copilot
|
||||
agent mode, Cline, Continue, Roo Code) via
|
||||
`vscode.lm.registerMcpServerDefinitionProvider`. No `mcp.json` editing
|
||||
required.
|
||||
- Activity-bar sidebar with "Indexed projects" tree view and welcome
|
||||
content.
|
||||
- Status-bar item with click-to-open-sidebar.
|
||||
- Webview-based interactive graph viewer (reads the HTML produced by the
|
||||
engine's `codebase_graph_visualize` tool).
|
||||
- Getting-started walkthrough (index your project, try search and the
|
||||
interactive graph).
|
||||
- Commands palette entries:
|
||||
- SocratiCode: Index current workspace
|
||||
- SocratiCode: Open interactive graph
|
||||
- SocratiCode: Refresh indexed projects
|
||||
- SocratiCode: Open getting-started walkthrough
|
||||
- SocratiCode: Show output / logs
|
||||
- Output channel for engine logs.
|
||||
- Engine env-var passthrough via `socraticode.env`, so external Qdrant,
|
||||
alternate embedding providers, project IDs and other engine knobs all
|
||||
work out of the box.
|
||||
@@ -0,0 +1,684 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
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
|
||||
them 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.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey 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;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If 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 convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero 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 that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
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.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
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.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
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
|
||||
state 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 Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
SocratiCode
|
||||
Copyright (C) 2026 Giancarlo Erra - Altaire Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, version 3 of the License.
|
||||
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing options, see LICENSE-COMMERCIAL or contact
|
||||
giancarlo@altaire.com.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
# SocratiCode for VS Code (and Cursor, VSCodium, Gitpod, code-server, Antigravity, Theia, ...)
|
||||
|
||||
**Codebase context engine for AI assistants.** SocratiCode indexes your
|
||||
repositories: code, dependency and call graphs, database schemas, API
|
||||
specs, architecture docs. It hands that understanding to whichever AI
|
||||
assistant you use, so the same understanding survives every tool switch.
|
||||
|
||||
This extension auto-registers the SocratiCode MCP server in VS Code's MCP
|
||||
host so it works out of the box with **Copilot agent mode**, **Cline**,
|
||||
**Continue**, **Roo Code**, and any other MCP-compatible chat or agent
|
||||
extension. No `mcp.json` editing required.
|
||||
|
||||
## What it does
|
||||
|
||||
- **Hybrid search** (semantic + BM25, RRF-fused) across your codebase.
|
||||
- **File-level dependency graphs** across 18+ languages with circular-
|
||||
dependency detection.
|
||||
- **Symbol-level call graph and impact analysis**: answers "what breaks if
|
||||
I change function X?" before the AI changes it.
|
||||
- **Cross-repo search** across multiple linked projects.
|
||||
- **Interactive graph viewer** with blast-radius overlay, search, and PNG
|
||||
export. Opens directly inside the editor as a webview panel.
|
||||
- **Context artefacts**: index database schemas, API specs and architecture
|
||||
docs alongside code. The AI sees the schema your developer team did, not
|
||||
what it guessed from filenames.
|
||||
|
||||
## Requirements
|
||||
|
||||
- VS Code 1.99 or newer (for native MCP support)
|
||||
- Node.js 18+ on PATH (for `npx` to launch the engine)
|
||||
- Docker Desktop running (the engine uses Docker for Qdrant + Ollama
|
||||
containers; alternatively you can point at an external Qdrant via
|
||||
the `socraticode.env` setting).
|
||||
|
||||
## Quick start
|
||||
|
||||
1. Install the extension.
|
||||
2. The MCP server registers automatically. Ask Copilot agent mode (or any
|
||||
MCP-aware assistant) a question about your codebase.
|
||||
3. Open the SocratiCode sidebar (Activity Bar → SocratiCode icon) and click
|
||||
**Index this workspace** to run the first index.
|
||||
4. Open the interactive graph from the Command Palette: `SocratiCode: Open
|
||||
interactive graph`.
|
||||
|
||||
A walkthrough is shown on first install. Re-open it any time with
|
||||
`SocratiCode: Open getting-started walkthrough`.
|
||||
|
||||
## Commands
|
||||
|
||||
All commands are also available under `SocratiCode:` in the Command Palette.
|
||||
|
||||
- **Index current workspace**: kick off a one-time index.
|
||||
- **Open interactive graph**: render the dependency / call graph as an
|
||||
in-editor webview.
|
||||
- **Refresh indexed projects**: reload the sidebar tree.
|
||||
- **Open getting-started walkthrough**: replay the onboarding.
|
||||
- **Show output / logs**: open the SocratiCode output channel.
|
||||
|
||||
## Settings
|
||||
|
||||
| Setting | Default | Description |
|
||||
|---|---|---|
|
||||
| `socraticode.command` | `"npx"` | Engine launcher. |
|
||||
| `socraticode.args` | `["-y", "socraticode"]` | Args for the launcher. |
|
||||
| `socraticode.env` | `{}` | Environment variables forwarded to the engine. Use this for external Qdrant (`QDRANT_MODE=external`, `QDRANT_URL`, `QDRANT_API_KEY`), embedding provider (`EMBEDDING_PROVIDER`, `OPENAI_API_KEY`, `GOOGLE_API_KEY`), or any other engine setting documented in the engine README. |
|
||||
| `socraticode.statusBar` | `true` | Show the status-bar item. |
|
||||
|
||||
## Privacy and data
|
||||
|
||||
- The engine indexes locally. Code never leaves your machine unless you
|
||||
explicitly point it at an external service via `socraticode.env`.
|
||||
- No telemetry from the extension.
|
||||
|
||||
## Open source
|
||||
|
||||
The engine is open source under AGPL-3.0 and battle-tested across
|
||||
thousands of indexed repositories. That openness is your guarantee of
|
||||
transparency, security and engineering quality.
|
||||
|
||||
- Repository: https://github.com/giancarloerra/socraticode
|
||||
- Issues / questions: https://github.com/giancarloerra/socraticode/issues
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **"Cannot find Docker"**: install Docker Desktop from
|
||||
https://docker.com/products/docker-desktop, or set `socraticode.env`
|
||||
with `QDRANT_MODE=external` plus `QDRANT_URL` to point at an existing
|
||||
Qdrant.
|
||||
- **MCP tools don't appear in Copilot agent mode**: restart the chat
|
||||
after install, or run `MCP: List Servers` from the command palette and
|
||||
confirm `SocratiCode` is listed and started.
|
||||
- **First index is slow**: the engine downloads Ollama models the first
|
||||
time. Subsequent runs are fast.
|
||||
- See `SocratiCode: Show output / logs` in the command palette for engine
|
||||
output.
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
|
||||
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": true },
|
||||
"files": { "ignoreUnknown": true },
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"indentStyle": "space",
|
||||
"indentWidth": 2,
|
||||
"lineWidth": 100
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"recommended": true,
|
||||
"style": {
|
||||
"noParameterAssign": "error",
|
||||
"useConst": "error"
|
||||
},
|
||||
"suspicious": {
|
||||
"noExplicitAny": "warn"
|
||||
},
|
||||
"complexity": {
|
||||
"noBannedTypes": "warn"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Giancarlo Erra - Altaire Limited
|
||||
//
|
||||
// esbuild bundle for the VS Code / Open VSX extension. The extension is
|
||||
// shipped as a single CommonJS bundle (VS Code's runtime requirement),
|
||||
// with `vscode` marked external. We avoid `node_modules` in the .vsix
|
||||
// because everything we need either resolves at runtime via VS Code's
|
||||
// host (`vscode`) or is part of the Node 18+ stdlib.
|
||||
|
||||
import { build, context } from "esbuild";
|
||||
|
||||
const watch = process.argv.includes("--watch");
|
||||
|
||||
const options = {
|
||||
entryPoints: ["src/extension.ts"],
|
||||
bundle: true,
|
||||
outfile: "dist/extension.js",
|
||||
external: ["vscode"],
|
||||
format: "cjs",
|
||||
platform: "node",
|
||||
target: "node18",
|
||||
sourcemap: true,
|
||||
minify: !watch,
|
||||
logLevel: "info",
|
||||
};
|
||||
|
||||
if (watch) {
|
||||
const ctx = await context(options);
|
||||
await ctx.watch();
|
||||
console.log("[esbuild] watching for changes...");
|
||||
} else {
|
||||
await build(options);
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 191 KiB |
Generated
+5691
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,217 @@
|
||||
{
|
||||
"name": "socraticode",
|
||||
"displayName": "SocratiCode",
|
||||
"description": "Codebase context engine for AI assistants. Hybrid search, dependency and call graphs, symbol-level impact analysis (blast radius), interactive graph explorer, and searchable architecture artefacts. Works with Copilot agent mode, Cline, Continue, Roo Code, and any MCP-compatible host.",
|
||||
"version": "1.7.2",
|
||||
"publisher": "altaire",
|
||||
"license": "AGPL-3.0-only",
|
||||
"icon": "images/icon.png",
|
||||
"engines": {
|
||||
"vscode": "^1.99.0",
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"categories": [
|
||||
"AI",
|
||||
"Programming Languages",
|
||||
"Visualization",
|
||||
"Other"
|
||||
],
|
||||
"keywords": [
|
||||
"ai",
|
||||
"mcp",
|
||||
"codebase",
|
||||
"context",
|
||||
"search",
|
||||
"semantic search",
|
||||
"dependency graph",
|
||||
"call graph",
|
||||
"impact analysis",
|
||||
"blast radius",
|
||||
"qdrant",
|
||||
"ollama",
|
||||
"copilot"
|
||||
],
|
||||
"homepage": "https://github.com/giancarloerra/socraticode",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/giancarloerra/socraticode.git",
|
||||
"directory": "extension"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/giancarloerra/socraticode/issues"
|
||||
},
|
||||
"qna": "https://github.com/giancarloerra/socraticode/discussions",
|
||||
"sponsor": {
|
||||
"url": "https://altaire.com"
|
||||
},
|
||||
"main": "./dist/extension.js",
|
||||
"activationEvents": [
|
||||
"onStartupFinished"
|
||||
],
|
||||
"contributes": {
|
||||
"mcpServerDefinitionProviders": [
|
||||
{
|
||||
"id": "socraticode.mcp",
|
||||
"label": "SocratiCode"
|
||||
}
|
||||
],
|
||||
"viewsContainers": {
|
||||
"activitybar": [
|
||||
{
|
||||
"id": "socraticode",
|
||||
"title": "SocratiCode",
|
||||
"icon": "images/icon.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"views": {
|
||||
"socraticode": [
|
||||
{
|
||||
"id": "socraticode.projects",
|
||||
"name": "Indexed projects",
|
||||
"icon": "images/icon.png",
|
||||
"contextualTitle": "SocratiCode"
|
||||
}
|
||||
]
|
||||
},
|
||||
"viewsWelcome": [
|
||||
{
|
||||
"view": "socraticode.projects",
|
||||
"contents": "SocratiCode indexes your codebase so AI assistants can search, trace dependencies and run impact analysis on it.\n\n[Index this workspace](command:socraticode.indexCurrentWorkspace)\n\nAsk your AI assistant (Copilot agent mode, Cline, Continue, Roo Code) to call any SocratiCode tool. The MCP server registers automatically on activation.\n\n[Open the getting-started walkthrough](command:socraticode.openWalkthrough)\n\n[Read the docs](https://github.com/giancarloerra/socraticode#readme)"
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
{
|
||||
"command": "socraticode.indexCurrentWorkspace",
|
||||
"title": "SocratiCode: Index current workspace",
|
||||
"category": "SocratiCode"
|
||||
},
|
||||
{
|
||||
"command": "socraticode.openInteractiveGraph",
|
||||
"title": "SocratiCode: Open interactive graph",
|
||||
"category": "SocratiCode"
|
||||
},
|
||||
{
|
||||
"command": "socraticode.refreshProjects",
|
||||
"title": "SocratiCode: Refresh indexed projects",
|
||||
"category": "SocratiCode",
|
||||
"icon": "$(refresh)"
|
||||
},
|
||||
{
|
||||
"command": "socraticode.openWalkthrough",
|
||||
"title": "SocratiCode: Open getting-started walkthrough",
|
||||
"category": "SocratiCode"
|
||||
},
|
||||
{
|
||||
"command": "socraticode.openOutput",
|
||||
"title": "SocratiCode: Show output / logs",
|
||||
"category": "SocratiCode"
|
||||
}
|
||||
],
|
||||
"menus": {
|
||||
"view/title": [
|
||||
{
|
||||
"command": "socraticode.refreshProjects",
|
||||
"when": "view == socraticode.projects",
|
||||
"group": "navigation"
|
||||
}
|
||||
],
|
||||
"commandPalette": [
|
||||
{
|
||||
"command": "socraticode.refreshProjects"
|
||||
}
|
||||
]
|
||||
},
|
||||
"configuration": {
|
||||
"title": "SocratiCode",
|
||||
"properties": {
|
||||
"socraticode.command": {
|
||||
"type": "string",
|
||||
"default": "npx",
|
||||
"description": "Command used to launch the engine. Defaults to `npx -y socraticode`. Override only if you have a custom install.",
|
||||
"scope": "window"
|
||||
},
|
||||
"socraticode.args": {
|
||||
"type": "array",
|
||||
"default": [
|
||||
"-y",
|
||||
"socraticode"
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Arguments passed to `socraticode.command`.",
|
||||
"scope": "window"
|
||||
},
|
||||
"socraticode.env": {
|
||||
"type": "object",
|
||||
"default": {},
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Environment variables forwarded to the engine. Use this to point at an external Qdrant (`QDRANT_MODE=external`, `QDRANT_URL`, `QDRANT_API_KEY`), select an embedding provider (`EMBEDDING_PROVIDER`, `OPENAI_API_KEY`, etc.), or any other engine setting documented in the engine README.",
|
||||
"scope": "window"
|
||||
},
|
||||
"socraticode.statusBar": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Show the SocratiCode status bar item.",
|
||||
"scope": "window"
|
||||
}
|
||||
}
|
||||
},
|
||||
"walkthroughs": [
|
||||
{
|
||||
"id": "socraticode.gettingStarted",
|
||||
"title": "Get started with SocratiCode",
|
||||
"description": "Index your first project and try the interactive graph.",
|
||||
"steps": [
|
||||
{
|
||||
"id": "index-project",
|
||||
"title": "Index your first project",
|
||||
"description": "Run a one-time index of your current workspace. Subsequent updates are incremental.",
|
||||
"media": {
|
||||
"markdown": "walkthroughs/first-index.md"
|
||||
},
|
||||
"completionEvents": [
|
||||
"onCommand:socraticode.indexCurrentWorkspace"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "try-search",
|
||||
"title": "Search and explore the graph",
|
||||
"description": "Open the interactive graph or ask your AI assistant a search question grounded in the codebase.",
|
||||
"media": {
|
||||
"markdown": "walkthroughs/first-search.md"
|
||||
},
|
||||
"completionEvents": [
|
||||
"onCommand:socraticode.openInteractiveGraph"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"compile": "node esbuild.config.mjs",
|
||||
"watch": "node esbuild.config.mjs --watch",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"lint": "biome check src",
|
||||
"test": "node --test --import tsx src/__tests__/*.test.ts",
|
||||
"package": "vsce package --no-dependencies",
|
||||
"publish:vsce": "vsce publish --no-dependencies",
|
||||
"publish:ovsx": "ovsx publish --no-dependencies",
|
||||
"publish:all": "npm run publish:vsce && npm run publish:ovsx",
|
||||
"vscode:prepublish": "npm run compile"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^2.0.0",
|
||||
"@types/node": "^20.0.0",
|
||||
"@types/vscode": "^1.99.0",
|
||||
"@vscode/vsce": "^3.2.0",
|
||||
"esbuild": "^0.24.0",
|
||||
"ovsx": "^0.10.0",
|
||||
"tsx": "^4.19.0",
|
||||
"typescript": "^5.6.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Giancarlo Erra - Altaire Limited
|
||||
|
||||
/**
|
||||
* Smoke tests for the extension manifest. These don't exercise extension
|
||||
* code that imports `vscode` (that requires `@vscode/test-electron`), but
|
||||
* they do catch the most common ways an extension breaks before it ever
|
||||
* loads: a missing or malformed `package.json` field, a contribution
|
||||
* point that disappeared in a refactor, an icon that no longer exists.
|
||||
*
|
||||
* Run with: `npm test` from `extension/`.
|
||||
*/
|
||||
|
||||
import { strict as assert } from "node:assert";
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { join, resolve } from "node:path";
|
||||
import { describe, test } from "node:test";
|
||||
|
||||
// __dirname works because tsx loads these tests as CommonJS (the extension's
|
||||
// package.json has no `"type": "module"` field). Avoiding `import.meta.url`
|
||||
// keeps the tests compatible with the same `module: Node16` tsconfig the
|
||||
// runtime code uses.
|
||||
const extensionRoot = resolve(__dirname, "..", "..");
|
||||
const manifestPath = join(extensionRoot, "package.json");
|
||||
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
||||
|
||||
describe("extension manifest", () => {
|
||||
test("declares a valid publisher and name", () => {
|
||||
assert.equal(typeof manifest.publisher, "string");
|
||||
assert.match(manifest.publisher, /^[a-z0-9][a-z0-9-]*$/i);
|
||||
assert.equal(typeof manifest.name, "string");
|
||||
assert.match(manifest.name, /^[a-z0-9][a-z0-9-]*$/i);
|
||||
});
|
||||
|
||||
test("targets VS Code 1.99+ (required for native MCP API)", () => {
|
||||
assert.ok(manifest.engines?.vscode, "engines.vscode missing");
|
||||
assert.match(manifest.engines.vscode, /\^1\.(99|\d{3,})/);
|
||||
});
|
||||
|
||||
test("declares the SocratiCode MCP provider", () => {
|
||||
const providers = manifest.contributes?.mcpServerDefinitionProviders;
|
||||
assert.ok(Array.isArray(providers), "mcpServerDefinitionProviders missing");
|
||||
assert.equal(providers.length, 1);
|
||||
assert.equal(providers[0].id, "socraticode.mcp");
|
||||
});
|
||||
|
||||
test("registers all expected commands", () => {
|
||||
const commands = manifest.contributes?.commands ?? [];
|
||||
const ids = commands.map((c: { command: string }) => c.command);
|
||||
for (const expected of [
|
||||
"socraticode.indexCurrentWorkspace",
|
||||
"socraticode.openInteractiveGraph",
|
||||
"socraticode.refreshProjects",
|
||||
"socraticode.openWalkthrough",
|
||||
"socraticode.openOutput",
|
||||
]) {
|
||||
assert.ok(ids.includes(expected), `missing command: ${expected}`);
|
||||
}
|
||||
});
|
||||
|
||||
test("declares the activity bar container and projects view", () => {
|
||||
const containers = manifest.contributes?.viewsContainers?.activitybar;
|
||||
assert.ok(Array.isArray(containers));
|
||||
assert.ok(containers.some((c: { id: string }) => c.id === "socraticode"));
|
||||
const views = manifest.contributes?.views?.socraticode;
|
||||
assert.ok(Array.isArray(views));
|
||||
assert.ok(views.some((v: { id: string }) => v.id === "socraticode.projects"));
|
||||
});
|
||||
|
||||
test("ships the configured icon and walkthrough media files", () => {
|
||||
assert.ok(manifest.icon, "icon path missing");
|
||||
assert.ok(
|
||||
existsSync(join(extensionRoot, manifest.icon)),
|
||||
`icon file not found at ${manifest.icon}`,
|
||||
);
|
||||
const walkthroughs = manifest.contributes?.walkthroughs ?? [];
|
||||
for (const wt of walkthroughs) {
|
||||
for (const step of wt.steps ?? []) {
|
||||
const md = step.media?.markdown;
|
||||
if (md) {
|
||||
assert.ok(existsSync(join(extensionRoot, md)), `walkthrough markdown missing: ${md}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("declares the settings the runtime reads", () => {
|
||||
const props = manifest.contributes?.configuration?.properties ?? {};
|
||||
for (const key of [
|
||||
"socraticode.command",
|
||||
"socraticode.args",
|
||||
"socraticode.env",
|
||||
"socraticode.statusBar",
|
||||
]) {
|
||||
assert.ok(props[key], `missing settings property: ${key}`);
|
||||
}
|
||||
});
|
||||
|
||||
test("uses an MCP-host-compatible activation event", () => {
|
||||
const events = manifest.activationEvents ?? [];
|
||||
assert.ok(
|
||||
events.includes("onStartupFinished"),
|
||||
"extension must activate on startup so the MCP provider is ready before chat",
|
||||
);
|
||||
});
|
||||
|
||||
test("declares scripts the CI release workflow expects", () => {
|
||||
const scripts = manifest.scripts ?? {};
|
||||
for (const key of [
|
||||
"compile",
|
||||
"typecheck",
|
||||
"lint",
|
||||
"test",
|
||||
"package",
|
||||
"publish:vsce",
|
||||
"publish:ovsx",
|
||||
]) {
|
||||
assert.ok(scripts[key], `missing script: ${key}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,78 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Giancarlo Erra - Altaire Limited
|
||||
|
||||
import * as vscode from "vscode";
|
||||
import { openInteractiveGraph } from "./graphPanel.js";
|
||||
import { log, output } from "./output.js";
|
||||
import type { ProjectsTreeProvider } from "./sidebar.js";
|
||||
|
||||
export function registerCommands(
|
||||
context: vscode.ExtensionContext,
|
||||
sidebar: ProjectsTreeProvider,
|
||||
): void {
|
||||
const subs = context.subscriptions;
|
||||
|
||||
subs.push(
|
||||
vscode.commands.registerCommand(
|
||||
"socraticode.indexCurrentWorkspace",
|
||||
indexCurrentWorkspaceCommand,
|
||||
),
|
||||
);
|
||||
|
||||
subs.push(
|
||||
vscode.commands.registerCommand(
|
||||
"socraticode.openInteractiveGraph",
|
||||
async (projectId?: string) => {
|
||||
await openInteractiveGraph(projectId);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
subs.push(
|
||||
vscode.commands.registerCommand("socraticode.refreshProjects", () => {
|
||||
sidebar.refresh();
|
||||
}),
|
||||
);
|
||||
|
||||
subs.push(
|
||||
vscode.commands.registerCommand("socraticode.openWalkthrough", async () => {
|
||||
// Use context.extension.id so this keeps working if the publisher
|
||||
// namespace changes. Same pattern as the first-run trigger in
|
||||
// extension.ts.
|
||||
await vscode.commands.executeCommand(
|
||||
"workbench.action.openWalkthrough",
|
||||
`${context.extension.id}#socraticode.gettingStarted`,
|
||||
false,
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
subs.push(
|
||||
vscode.commands.registerCommand("socraticode.openOutput", () => {
|
||||
output().show(true);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
async function indexCurrentWorkspaceCommand(): Promise<void> {
|
||||
const ws = vscode.workspace.workspaceFolders?.[0];
|
||||
if (!ws) {
|
||||
vscode.window.showWarningMessage("SocratiCode: open a folder or workspace before indexing.");
|
||||
return;
|
||||
}
|
||||
// The engine is the authority on indexing. Surface a clear instruction
|
||||
// the AI assistant can act on and copy the prompt to the clipboard.
|
||||
const prompt = `Use SocratiCode to index this project: call codebase_index for ${ws.uri.fsPath}.`;
|
||||
await vscode.env.clipboard.writeText(prompt);
|
||||
log(`indexCurrentWorkspace: prompt copied for ${ws.uri.fsPath}`);
|
||||
const action = await vscode.window.showInformationMessage(
|
||||
"Prompt copied to clipboard. Paste it into your AI assistant chat to index this workspace.",
|
||||
"Open chat",
|
||||
"Show output",
|
||||
);
|
||||
if (action === "Open chat") {
|
||||
await vscode.commands.executeCommand("workbench.action.chat.open");
|
||||
} else if (action === "Show output") {
|
||||
output().show(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Giancarlo Erra - Altaire Limited
|
||||
|
||||
import * as vscode from "vscode";
|
||||
import { registerCommands } from "./commands.js";
|
||||
import { registerMcpProvider } from "./mcpProvider.js";
|
||||
import { initOutput, log } from "./output.js";
|
||||
import { registerSidebar } from "./sidebar.js";
|
||||
import { registerStatusBar } from "./statusBar.js";
|
||||
|
||||
const FIRST_RUN_KEY = "socraticode.firstRunWalkthroughShown";
|
||||
|
||||
/**
|
||||
* Extension entry point. Wires up all the building blocks in the order
|
||||
* they need: output channel first (so other modules can log during their
|
||||
* own setup), then MCP provider (the most important contribution), then
|
||||
* sidebar / status bar / commands (UI), then the first-run walkthrough.
|
||||
*
|
||||
* Note: the entire activation function should stay synchronous from
|
||||
* VS Code's point of view (it returns a Promise but every step is fast).
|
||||
* Anything slow (network, disk reads) is deferred to when the user
|
||||
* actually triggers it via a command.
|
||||
*/
|
||||
export async function activate(context: vscode.ExtensionContext): Promise<void> {
|
||||
initOutput(context);
|
||||
log("SocratiCode extension activating");
|
||||
|
||||
registerMcpProvider(context);
|
||||
const sidebar = registerSidebar(context);
|
||||
registerStatusBar(context);
|
||||
registerCommands(context, sidebar);
|
||||
|
||||
// Show the walkthrough on first install. We use globalState rather than
|
||||
// a setting so it's per-machine, not per-workspace.
|
||||
const shown = context.globalState.get<boolean>(FIRST_RUN_KEY, false);
|
||||
if (!shown) {
|
||||
void context.globalState.update(FIRST_RUN_KEY, true);
|
||||
void vscode.commands.executeCommand(
|
||||
"workbench.action.openWalkthrough",
|
||||
`${context.extension.id}#socraticode.gettingStarted`,
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
log("SocratiCode extension activated");
|
||||
}
|
||||
|
||||
export function deactivate(): void {
|
||||
// Subscriptions are disposed automatically by VS Code via
|
||||
// context.subscriptions. No additional cleanup needed today.
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Giancarlo Erra - Altaire Limited
|
||||
|
||||
import * as fs from "node:fs/promises";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import * as vscode from "vscode";
|
||||
import { log } from "./output.js";
|
||||
|
||||
/**
|
||||
* Webview panel that renders the engine's interactive graph HTML inside
|
||||
* VS Code, so users don't have to bounce out to a browser tab.
|
||||
*
|
||||
* The engine's `codebase_graph_visualize` tool writes a self-contained
|
||||
* HTML file (vendored Cytoscape + Dagre, no external scripts) to
|
||||
* `os.tmpdir()/socraticode-graph/<projectId>.html`. We read the file
|
||||
* directly and inject it into a webview.
|
||||
*
|
||||
* Why this design:
|
||||
*
|
||||
* - The engine already produces a usable artefact. Re-implementing a
|
||||
* native graph view would mean duplicating the pipeline, which we
|
||||
* explicitly want to avoid.
|
||||
* - Reading from a known temp path avoids any IPC dance with the running
|
||||
* MCP server and works whether the user generated the graph from chat,
|
||||
* from the command palette, or from a CLI invocation of the engine.
|
||||
* - A webview is sandboxed: scripts the engine writes can't reach the
|
||||
* workspace. The CSP we set only allows inline scripts (the vendored
|
||||
* Cytoscape) and webview-relative resources.
|
||||
*/
|
||||
|
||||
const GRAPH_DIR = path.join(os.tmpdir(), "socraticode-graph");
|
||||
|
||||
let currentPanel: vscode.WebviewPanel | undefined;
|
||||
|
||||
export async function openInteractiveGraph(projectId?: string): Promise<void> {
|
||||
const html = await loadGraphHtml(projectId);
|
||||
if (!html) return;
|
||||
|
||||
if (currentPanel) {
|
||||
currentPanel.webview.html = wrapHtml(html, currentPanel.webview);
|
||||
currentPanel.reveal();
|
||||
return;
|
||||
}
|
||||
|
||||
currentPanel = vscode.window.createWebviewPanel(
|
||||
"socraticode.graph",
|
||||
"SocratiCode: interactive graph",
|
||||
vscode.ViewColumn.Active,
|
||||
{
|
||||
enableScripts: true,
|
||||
retainContextWhenHidden: true,
|
||||
localResourceRoots: [vscode.Uri.file(GRAPH_DIR)],
|
||||
},
|
||||
);
|
||||
currentPanel.iconPath = vscode.Uri.file(path.join(__dirname, "..", "images", "icon.png"));
|
||||
currentPanel.onDidDispose(() => {
|
||||
currentPanel = undefined;
|
||||
});
|
||||
currentPanel.webview.onDidReceiveMessage((msg: unknown) => {
|
||||
handleWebviewMessage(msg);
|
||||
});
|
||||
currentPanel.webview.html = wrapHtml(html, currentPanel.webview);
|
||||
}
|
||||
|
||||
async function loadGraphHtml(projectId?: string): Promise<string | undefined> {
|
||||
let target: string | undefined;
|
||||
if (projectId) {
|
||||
target = path.join(GRAPH_DIR, `${projectId}.html`);
|
||||
} else {
|
||||
// Pick the most recently modified graph file.
|
||||
try {
|
||||
const entries = await fs.readdir(GRAPH_DIR, { withFileTypes: true });
|
||||
let latestPath: string | undefined;
|
||||
let latestMtime = 0;
|
||||
for (const entry of entries) {
|
||||
if (!entry.isFile() || !entry.name.endsWith(".html")) continue;
|
||||
const p = path.join(GRAPH_DIR, entry.name);
|
||||
const stat = await fs.stat(p);
|
||||
if (stat.mtimeMs > latestMtime) {
|
||||
latestMtime = stat.mtimeMs;
|
||||
latestPath = p;
|
||||
}
|
||||
}
|
||||
target = latestPath;
|
||||
} catch {
|
||||
// Directory doesn't exist; fall through to the "no graph yet" path.
|
||||
}
|
||||
}
|
||||
|
||||
if (!target) {
|
||||
await offerToGenerate();
|
||||
return undefined;
|
||||
}
|
||||
|
||||
try {
|
||||
return await fs.readFile(target, "utf-8");
|
||||
} catch (err) {
|
||||
const e = err as Error;
|
||||
log(`Graph panel: failed to read ${target}: ${e.message}`);
|
||||
if ((err as NodeJS.ErrnoException).code === "ENOENT") {
|
||||
await offerToGenerate();
|
||||
return undefined;
|
||||
}
|
||||
vscode.window.showErrorMessage(`SocratiCode: ${e.message}`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async function offerToGenerate(): Promise<void> {
|
||||
const action = await vscode.window.showInformationMessage(
|
||||
'No interactive graph has been generated yet. Ask your AI assistant to call the SocratiCode tool `codebase_graph_visualize` with `mode="interactive"`, then re-run this command.',
|
||||
"Copy prompt to clipboard",
|
||||
"Open chat",
|
||||
);
|
||||
if (action === "Copy prompt to clipboard") {
|
||||
const prompt =
|
||||
'Please use SocratiCode to build an interactive graph of this project: call codebase_graph_visualize with mode="interactive".';
|
||||
await vscode.env.clipboard.writeText(prompt);
|
||||
vscode.window.showInformationMessage("SocratiCode: prompt copied.");
|
||||
} else if (action === "Open chat") {
|
||||
await vscode.commands.executeCommand("workbench.action.chat.open");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the engine HTML so it works inside a webview:
|
||||
*
|
||||
* 1. Inject a CSP that allows inline scripts/styles (the vendored
|
||||
* Cytoscape) but blocks remote loads. The engine HTML is generated
|
||||
* locally and self-contained, so this doesn't break anything.
|
||||
* 2. Replace any local `file://` references with `webview.asWebviewUri()`.
|
||||
* Today the engine inlines all its assets, so this is a defensive
|
||||
* no-op, but worth keeping for forward compatibility.
|
||||
* 3. Inject a small bridge script so node-click events in the graph can
|
||||
* `postMessage` back to the extension and we can `vscode.commands.executeCommand`
|
||||
* to open files.
|
||||
*/
|
||||
function wrapHtml(html: string, webview: vscode.Webview): string {
|
||||
const cspSource = webview.cspSource;
|
||||
const csp = [
|
||||
"default-src 'none'",
|
||||
`img-src ${cspSource} data: blob:`,
|
||||
`style-src ${cspSource} 'unsafe-inline'`,
|
||||
`script-src ${cspSource} 'unsafe-inline'`,
|
||||
`font-src ${cspSource} data:`,
|
||||
"connect-src 'none'",
|
||||
].join("; ");
|
||||
|
||||
// The engine template already includes <html>...</html>. We inject the
|
||||
// CSP meta tag right after <head>. If <head> is missing for some reason,
|
||||
// we fall back to prepending a minimal head.
|
||||
const cspMeta = `<meta http-equiv="Content-Security-Policy" content="${csp}">`;
|
||||
const bridge = `
|
||||
<script>
|
||||
(function() {
|
||||
const vscode = acquireVsCodeApi();
|
||||
window.addEventListener('socraticode:openFile', (e) => {
|
||||
vscode.postMessage({ type: 'openFile', path: e.detail?.path, line: e.detail?.line });
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
`;
|
||||
|
||||
if (html.includes("<head>")) {
|
||||
return html.replace("<head>", `<head>${cspMeta}${bridge}`);
|
||||
}
|
||||
// If the document has <html> but no <head>, splice a <head> in right
|
||||
// after the opening <html ...> tag. Wrapping in a fresh <html>...</html>
|
||||
// here would nest two <html> elements, which most browsers tolerate
|
||||
// but is invalid markup.
|
||||
if (/<html[^>]*>/i.test(html)) {
|
||||
return html.replace(/(<html[^>]*>)/i, `$1<head>${cspMeta}${bridge}</head>`);
|
||||
}
|
||||
return `<!DOCTYPE html><html><head>${cspMeta}${bridge}</head><body>${html}</body></html>`;
|
||||
}
|
||||
|
||||
function handleWebviewMessage(msg: unknown): void {
|
||||
if (typeof msg !== "object" || msg === null) return;
|
||||
const m = msg as { type?: string; path?: string; line?: number };
|
||||
if (m.type === "openFile" && typeof m.path === "string") {
|
||||
const ws = vscode.workspace.workspaceFolders?.[0];
|
||||
if (!ws) {
|
||||
vscode.window.showWarningMessage("SocratiCode: open a workspace to navigate from the graph.");
|
||||
return;
|
||||
}
|
||||
const uri = vscode.Uri.joinPath(ws.uri, m.path);
|
||||
const range =
|
||||
typeof m.line === "number" ? new vscode.Range(m.line - 1, 0, m.line - 1, 0) : undefined;
|
||||
vscode.window.showTextDocument(uri, range ? { selection: range } : {});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Giancarlo Erra - Altaire Limited
|
||||
|
||||
import * as vscode from "vscode";
|
||||
import { log } from "./output.js";
|
||||
import { getSettings } from "./settings.js";
|
||||
|
||||
/**
|
||||
* Registers the SocratiCode MCP server with VS Code's MCP host (Copilot
|
||||
* agent mode, Cline, Continue, Roo Code, ...) via the
|
||||
* `vscode.lm.registerMcpServerDefinitionProvider` API (VS Code 1.99+).
|
||||
*
|
||||
* This is the single most important thing the extension does. Once this
|
||||
* provider is registered, every MCP-aware chat / agent in the editor sees
|
||||
* SocratiCode's tools without the user editing any `.vscode/mcp.json`.
|
||||
*
|
||||
* The provider returns a single stdio definition that launches the engine
|
||||
* via `npx -y socraticode` (overridable via `socraticode.command` /
|
||||
* `socraticode.args`). The engine's environment is the user-configured
|
||||
* `socraticode.env` object passed through unchanged, which is how power
|
||||
* users point at an external Qdrant (`QDRANT_MODE=external`, `QDRANT_URL`,
|
||||
* `QDRANT_API_KEY`) or pick an embedding provider.
|
||||
*/
|
||||
|
||||
export class SocratiCodeMcpProvider implements vscode.McpServerDefinitionProvider {
|
||||
private readonly _onDidChange = new vscode.EventEmitter<void>();
|
||||
readonly onDidChangeMcpServerDefinitions = this._onDidChange.event;
|
||||
|
||||
/** Trigger VS Code to re-fetch the server definition (e.g. after a setting change). */
|
||||
refresh(): void {
|
||||
this._onDidChange.fire();
|
||||
}
|
||||
|
||||
async provideMcpServerDefinitions(): Promise<vscode.McpServerDefinition[]> {
|
||||
const settings = getSettings();
|
||||
const def = new vscode.McpStdioServerDefinition(
|
||||
"SocratiCode",
|
||||
settings.command,
|
||||
settings.args,
|
||||
settings.env,
|
||||
);
|
||||
return [def];
|
||||
}
|
||||
}
|
||||
|
||||
export function registerMcpProvider(context: vscode.ExtensionContext): SocratiCodeMcpProvider {
|
||||
const provider = new SocratiCodeMcpProvider();
|
||||
const disposable = vscode.lm.registerMcpServerDefinitionProvider("socraticode.mcp", provider);
|
||||
context.subscriptions.push(disposable);
|
||||
log("Registered SocratiCode MCP server provider");
|
||||
|
||||
// Refresh the provider when relevant settings change so VS Code re-reads
|
||||
// the definition (e.g. user changed the engine command or env vars).
|
||||
const watch = vscode.workspace.onDidChangeConfiguration((e) => {
|
||||
if (
|
||||
e.affectsConfiguration("socraticode.command") ||
|
||||
e.affectsConfiguration("socraticode.args") ||
|
||||
e.affectsConfiguration("socraticode.env")
|
||||
) {
|
||||
log("Settings changed, refreshing MCP server definition");
|
||||
provider.refresh();
|
||||
}
|
||||
});
|
||||
context.subscriptions.push(watch);
|
||||
|
||||
return provider;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Giancarlo Erra - Altaire Limited
|
||||
|
||||
import * as vscode from "vscode";
|
||||
|
||||
/**
|
||||
* Shared output channel for the extension. Created once on activation,
|
||||
* disposed on deactivation. Use `output()` everywhere instead of
|
||||
* `console.log` so users can see logs via the "SocratiCode: Show output /
|
||||
* logs" command.
|
||||
*/
|
||||
let channel: vscode.OutputChannel | undefined;
|
||||
|
||||
export function initOutput(context: vscode.ExtensionContext): void {
|
||||
channel = vscode.window.createOutputChannel("SocratiCode");
|
||||
context.subscriptions.push(channel);
|
||||
}
|
||||
|
||||
export function output(): vscode.OutputChannel {
|
||||
if (!channel) {
|
||||
// Defensive fallback for tests or unexpected ordering.
|
||||
channel = vscode.window.createOutputChannel("SocratiCode");
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
|
||||
export function log(message: string): void {
|
||||
const ts = new Date().toISOString();
|
||||
output().appendLine(`[${ts}] ${message}`);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Giancarlo Erra - Altaire Limited
|
||||
|
||||
import * as vscode from "vscode";
|
||||
|
||||
/**
|
||||
* Strongly-typed access to the `socraticode.*` configuration namespace.
|
||||
* Read settings via `getSettings()` rather than
|
||||
* `vscode.workspace.getConfiguration` directly so all keys are listed in
|
||||
* one place and tracked by TypeScript.
|
||||
*/
|
||||
|
||||
export interface SocratiCodeSettings {
|
||||
command: string;
|
||||
args: string[];
|
||||
env: Record<string, string>;
|
||||
showStatusBar: boolean;
|
||||
}
|
||||
|
||||
const SECTION = "socraticode";
|
||||
|
||||
export function getSettings(): SocratiCodeSettings {
|
||||
const c = vscode.workspace.getConfiguration(SECTION);
|
||||
return {
|
||||
command: c.get<string>("command", "npx"),
|
||||
args: c.get<string[]>("args", ["-y", "socraticode"]),
|
||||
env: c.get<Record<string, string>>("env", {}),
|
||||
showStatusBar: c.get<boolean>("statusBar", true),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Giancarlo Erra - Altaire Limited
|
||||
|
||||
import * as fs from "node:fs/promises";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import * as vscode from "vscode";
|
||||
import { log } from "./output.js";
|
||||
|
||||
/**
|
||||
* Sidebar TreeView showing indexed projects discovered from the engine's
|
||||
* temp directory. The engine writes interactive graph HTML to
|
||||
* `os.tmpdir()/socraticode-graph/<projectId>.html` whenever the user (or
|
||||
* their AI assistant) calls `codebase_graph_visualize`. Listing those
|
||||
* files gives a low-cost, no-IPC view of "what has SocratiCode worked on
|
||||
* recently".
|
||||
*
|
||||
* For richer state (current index size, embedding count, freshness) the
|
||||
* view will eventually call into the running engine via `vscode.lm.tools`,
|
||||
* but that requires a stable invokeTool API across MCP hosts. Until then,
|
||||
* the welcome view + the file listing are enough to get users oriented.
|
||||
*/
|
||||
|
||||
interface ProjectItem {
|
||||
projectId: string;
|
||||
graphPath?: string;
|
||||
mtime?: Date;
|
||||
}
|
||||
|
||||
const GRAPH_DIR = path.join(os.tmpdir(), "socraticode-graph");
|
||||
|
||||
export class ProjectsTreeProvider implements vscode.TreeDataProvider<ProjectItem> {
|
||||
private readonly _onDidChange = new vscode.EventEmitter<ProjectItem | undefined>();
|
||||
readonly onDidChangeTreeData = this._onDidChange.event;
|
||||
|
||||
refresh(): void {
|
||||
this._onDidChange.fire(undefined);
|
||||
}
|
||||
|
||||
getTreeItem(element: ProjectItem): vscode.TreeItem {
|
||||
const item = new vscode.TreeItem(element.projectId, vscode.TreeItemCollapsibleState.None);
|
||||
item.iconPath = new vscode.ThemeIcon("symbol-namespace");
|
||||
if (element.mtime) {
|
||||
item.description = `graph generated ${formatRelative(element.mtime)}`;
|
||||
} else {
|
||||
item.description = "no graph yet";
|
||||
}
|
||||
item.tooltip = element.graphPath
|
||||
? `Click to open the interactive graph for ${element.projectId}.\nFile: ${element.graphPath}`
|
||||
: `No interactive graph cached for ${element.projectId}.`;
|
||||
if (element.graphPath) {
|
||||
item.command = {
|
||||
command: "socraticode.openInteractiveGraph",
|
||||
title: "Open interactive graph",
|
||||
arguments: [element.projectId],
|
||||
};
|
||||
}
|
||||
item.contextValue = element.graphPath ? "project.withGraph" : "project";
|
||||
return item;
|
||||
}
|
||||
|
||||
async getChildren(): Promise<ProjectItem[]> {
|
||||
try {
|
||||
const entries = await fs.readdir(GRAPH_DIR, { withFileTypes: true });
|
||||
const items: ProjectItem[] = [];
|
||||
for (const entry of entries) {
|
||||
if (!entry.isFile() || !entry.name.endsWith(".html")) continue;
|
||||
const projectId = entry.name.replace(/\.html$/, "");
|
||||
const graphPath = path.join(GRAPH_DIR, entry.name);
|
||||
try {
|
||||
const stat = await fs.stat(graphPath);
|
||||
items.push({ projectId, graphPath, mtime: stat.mtime });
|
||||
} catch {
|
||||
items.push({ projectId, graphPath });
|
||||
}
|
||||
}
|
||||
// Most recently generated first. When mtime is missing on a side,
|
||||
// push that side to the end. When both are missing, fall back to
|
||||
// a stable lexicographic tiebreak on projectId so the ordering is
|
||||
// deterministic regardless of fs.readdir() traversal order.
|
||||
items.sort((a, b) => {
|
||||
if (!a.mtime && !b.mtime) return a.projectId.localeCompare(b.projectId);
|
||||
if (!a.mtime) return 1;
|
||||
if (!b.mtime) return -1;
|
||||
return b.mtime.getTime() - a.mtime.getTime();
|
||||
});
|
||||
return items;
|
||||
} catch (err) {
|
||||
const e = err as NodeJS.ErrnoException;
|
||||
if (e.code === "ENOENT") {
|
||||
// Engine has never generated a graph yet. The welcome view in
|
||||
// package.json handles the empty state.
|
||||
return [];
|
||||
}
|
||||
log(`Sidebar: failed to read ${GRAPH_DIR}: ${e.message}`);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function registerSidebar(context: vscode.ExtensionContext): ProjectsTreeProvider {
|
||||
const provider = new ProjectsTreeProvider();
|
||||
const view = vscode.window.createTreeView("socraticode.projects", {
|
||||
treeDataProvider: provider,
|
||||
showCollapseAll: false,
|
||||
});
|
||||
context.subscriptions.push(view);
|
||||
return provider;
|
||||
}
|
||||
|
||||
function formatRelative(date: Date): string {
|
||||
const seconds = Math.round((Date.now() - date.getTime()) / 1000);
|
||||
if (seconds < 60) return `${seconds}s ago`;
|
||||
const minutes = Math.round(seconds / 60);
|
||||
if (minutes < 60) return `${minutes}m ago`;
|
||||
const hours = Math.round(minutes / 60);
|
||||
if (hours < 24) return `${hours}h ago`;
|
||||
const days = Math.round(hours / 24);
|
||||
return `${days}d ago`;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Giancarlo Erra - Altaire Limited
|
||||
|
||||
import * as vscode from "vscode";
|
||||
import { getSettings } from "./settings.js";
|
||||
|
||||
/**
|
||||
* Status-bar item that opens the SocratiCode sidebar on click.
|
||||
* Honours the `socraticode.statusBar` setting.
|
||||
*/
|
||||
|
||||
let item: vscode.StatusBarItem | undefined;
|
||||
|
||||
export function registerStatusBar(context: vscode.ExtensionContext): void {
|
||||
item = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 50);
|
||||
item.command = "workbench.view.extension.socraticode";
|
||||
context.subscriptions.push(item);
|
||||
|
||||
refresh();
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.workspace.onDidChangeConfiguration((e) => {
|
||||
if (e.affectsConfiguration("socraticode.statusBar")) {
|
||||
refresh();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
function refresh(): void {
|
||||
if (!item) return;
|
||||
if (!getSettings().showStatusBar) {
|
||||
item.hide();
|
||||
return;
|
||||
}
|
||||
item.text = "$(server) SocratiCode";
|
||||
item.tooltip = "Click to open the SocratiCode sidebar.";
|
||||
item.show();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "Node16",
|
||||
"moduleResolution": "Node16",
|
||||
"lib": ["ES2022"],
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"strict": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"sourceMap": true,
|
||||
"declaration": false
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
# Index your first project
|
||||
|
||||
Index the workspace:
|
||||
|
||||
1. Open the SocratiCode sidebar (Activity Bar → SocratiCode icon).
|
||||
2. Click **Index this workspace** in the welcome view, or run **SocratiCode:
|
||||
Index current workspace** from the command palette.
|
||||
|
||||
The first index downloads the embedding model if it's not already cached
|
||||
(roughly 700 MB for the default `mxbai-embed-large`), then walks the
|
||||
workspace. Subsequent updates are incremental and triggered automatically
|
||||
when files change.
|
||||
|
||||
## What gets indexed
|
||||
|
||||
- All source files in 18+ languages (TypeScript, JavaScript, Python, Go,
|
||||
Rust, Java, Kotlin, Scala, C#, C, C++, Ruby, PHP, Swift, Bash, Dart, Lua,
|
||||
Svelte, Vue, plus 35+ plain-text formats).
|
||||
- Files matching `EXTRA_EXTENSIONS` (configurable).
|
||||
- Context artefacts declared in `.socraticodecontextartifacts.json` if
|
||||
present (database schemas, API specs, infra configs, architecture docs).
|
||||
|
||||
## What gets skipped
|
||||
|
||||
- Anything in `.gitignore` (unless `RESPECT_GITIGNORE` is `false`).
|
||||
- Files larger than `MAX_FILE_SIZE_MB` (default 5 MB).
|
||||
- Dot directories like `.git`, `.next` (unless `INCLUDE_DOT_FILES` is `true`).
|
||||
|
||||
## Requirements
|
||||
|
||||
The local engine spins up Docker containers for Qdrant (vector database)
|
||||
and Ollama (embeddings) on first use. Make sure Docker Desktop is running.
|
||||
|
||||
## Advanced configuration
|
||||
|
||||
Need to point at an existing Qdrant cluster, use OpenAI or Google
|
||||
embeddings, change ports or paths? The engine reads these from environment
|
||||
variables. Set them via the `socraticode.env` setting (Settings UI or
|
||||
`settings.json`):
|
||||
|
||||
```json
|
||||
"socraticode.env": {
|
||||
"QDRANT_MODE": "external",
|
||||
"QDRANT_URL": "https://your-cluster.example",
|
||||
"QDRANT_API_KEY": "...",
|
||||
"EMBEDDING_PROVIDER": "openai",
|
||||
"OPENAI_API_KEY": "..."
|
||||
}
|
||||
```
|
||||
|
||||
See the [engine README](https://github.com/giancarloerra/socraticode#configuration)
|
||||
for the full list.
|
||||
@@ -0,0 +1,36 @@
|
||||
# Try a search and the interactive graph
|
||||
|
||||
Now your codebase is indexed, two things to try.
|
||||
|
||||
## Ask your AI assistant
|
||||
|
||||
In Copilot agent mode, Cline, Continue or Roo Code, ask any of:
|
||||
|
||||
- "Where is authentication handled in this project?"
|
||||
- "What breaks if I change the function `processOrder`?"
|
||||
- "Trace the execution flow of the cron job that runs nightly."
|
||||
- "Show me every place that talks to the `users` table."
|
||||
|
||||
The assistant will call SocratiCode's MCP tools (`codebase_search`,
|
||||
`codebase_impact`, `codebase_flow`, `codebase_symbol`, etc.) automatically.
|
||||
|
||||
## Open the interactive graph
|
||||
|
||||
Run **SocratiCode: Open interactive graph** from the command palette. The
|
||||
graph opens as a webview panel inside VS Code with:
|
||||
|
||||
- File and symbol views (toggle between them).
|
||||
- Blast-radius overlay (click a node to highlight its impact set).
|
||||
- Search by name.
|
||||
- PNG export for architects, security reviewers and slide decks.
|
||||
|
||||
If no graph has been generated yet, the extension will prompt your AI
|
||||
assistant to run `codebase_graph_visualize mode="interactive"` first.
|
||||
|
||||
## Next steps
|
||||
|
||||
- Check **SocratiCode: Show output / logs** if anything looks off.
|
||||
- Re-open this walkthrough any time via the command palette.
|
||||
- See the [engine README](https://github.com/giancarloerra/socraticode#readme)
|
||||
for configuration knobs (embedding provider, Qdrant mode, project IDs,
|
||||
branch-aware indexing, linked projects for cross-repo search).
|
||||
Reference in New Issue
Block a user