Merge pull request #39 from giancarloerra/feat/extensions

feat(extension): VS Code and Open VSX extension
This commit is contained in:
Giancarlo Erra
2026-05-04 00:57:55 +01:00
committed by GitHub
31 changed files with 8138 additions and 11 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
{
"name": "socraticode",
"version": "1.4.1",
"description": "Codebase intelligence — semantic search workflows, dependency graph analysis, and context artifact exploration for SocratiCode",
"version": "1.7.2",
"description": "Codebase intelligence: semantic search workflows, dependency graph analysis, and context artifact exploration for SocratiCode",
"author": {
"name": "Giancarlo Erra",
"email": "giancarlo@altaire.com",
@@ -22,7 +22,7 @@
"mcpServers": "./.mcp.json",
"interface": {
"displayName": "SocratiCode",
"shortDescription": "Codebase intelligence — semantic search, dependency graphs, and context artifacts",
"shortDescription": "Codebase intelligence: semantic search, dependency graphs, and context artifacts",
"longDescription": "SocratiCode provides codebase intelligence through semantic search workflows, dependency graph analysis, and context artifact exploration. Index your codebase, search with hybrid semantic + keyword search, visualize module dependencies, and manage context artifacts.",
"developerName": "Giancarlo Erra",
"category": "Development",
+2 -2
View File
@@ -5,13 +5,13 @@
"email": "giancarlo@altaire.com"
},
"metadata": {
"description": "SocratiCode — codebase intelligence plugin"
"description": "SocratiCode: codebase intelligence plugin"
},
"plugins": [
{
"name": "socraticode",
"source": "./",
"description": "Codebase intelligence — semantic search workflows, dependency graph analysis, and context artifact exploration",
"description": "Codebase intelligence: semantic search workflows, dependency graph analysis, and context artifact exploration",
"category": "development"
}
]
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "socraticode",
"version": "1.4.1",
"description": "Codebase intelligence — semantic search workflows, dependency graph analysis, and context artifact exploration for SocratiCode",
"version": "1.7.2",
"description": "Codebase intelligence: semantic search workflows, dependency graph analysis, and context artifact exploration for SocratiCode",
"author": {
"name": "Giancarlo Erra",
"email": "giancarlo@altaire.com"
+58
View File
@@ -0,0 +1,58 @@
name: Extension CI
on:
push:
branches: [main]
paths:
- "extension/**"
- ".github/workflows/extension-ci.yml"
pull_request:
branches: [main]
paths:
- "extension/**"
- ".github/workflows/extension-ci.yml"
permissions:
contents: read
jobs:
lint-build-package:
name: Lint, typecheck, test, build, package
runs-on: ubuntu-latest
defaults:
run:
working-directory: extension
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: extension/package-lock.json
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Typecheck
run: npm run typecheck
- name: Test
run: npm test
- name: Build
run: npm run compile
- name: Package .vsix
run: npm run package
- name: Upload .vsix artefact
uses: actions/upload-artifact@v4
with:
name: socraticode-vsix
path: extension/*.vsix
if-no-files-found: error
retention-days: 7
+63
View File
@@ -0,0 +1,63 @@
name: Extension Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: read
jobs:
publish:
name: Publish .vsix to VS Code Marketplace and Open VSX
runs-on: ubuntu-latest
defaults:
run:
working-directory: extension
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: extension/package-lock.json
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Typecheck
run: npm run typecheck
- name: Test
run: npm test
- name: Build
run: npm run compile
- name: Package .vsix
run: npm run package
- name: Publish to VS Code Marketplace
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: npm run publish:vsce
- name: Publish to Open VSX
env:
OVSX_PAT: ${{ secrets.OVSX_PAT }}
run: npm run publish:ovsx
- name: Upload .vsix to GitHub release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: extension/*.vsix
fail_on_unmatched_files: false
+1 -1
View File
@@ -1,6 +1,6 @@
{
"hooks": {
"after:bump": "node -e \"const fs=require('fs'); const p=JSON.parse(fs.readFileSync('.claude-plugin/plugin.json','utf8')); p.version='${version}'; fs.writeFileSync('.claude-plugin/plugin.json', JSON.stringify(p,null,2)+'\\n');\""
"after:bump": "node scripts/bump-plugin-versions.mjs ${version}"
},
"git": {
"commitMessage": "chore: release v${version}",
+115
View File
@@ -19,6 +19,7 @@ This document covers the internals of **SocratiCode** — architecture, data flo
- [Data Structures](#data-structures)
- [Docker & Infrastructure](#docker--infrastructure)
- [Extending the Indexer](#extending-the-indexer)
- [VS Code / Open VSX Extension](#vs-code--open-vsx-extension)
- [Troubleshooting](#troubleshooting)
---
@@ -1402,6 +1403,120 @@ Edit `DEFAULT_IGNORE_PATTERNS` in `src/services/ignore.ts`.
---
## VS Code / Open VSX Extension
The repo also ships a regular VS Code extension that auto-registers the
SocratiCode MCP server in any MCP-aware host (Copilot agent mode, Cline,
Continue, Roo Code) and adds native UI: sidebar, status bar, interactive
graph webview, walkthrough, and palette commands. The same `.vsix` is
published to both VS Code Marketplace and Open VSX, so it installs in
Cursor, VSCodium, Gitpod, code-server, Theia, Antigravity, and Particle
Workbench in addition to stock VS Code.
Source: [`extension/`](./extension)
### Layout
```text
extension/
├── package.json # extension manifest
├── tsconfig.json # TS strict, ES2022, Node 18 target
├── biome.json # lint config
├── esbuild.config.mjs # bundles src/extension.ts -> dist/extension.js
├── README.md # marketplace landing page
├── CHANGELOG.md # extension-specific changelog
├── images/icon.png # marketplace icon
├── walkthroughs/ # markdown shown in the getting-started walkthrough
└── src/
├── extension.ts # activation entrypoint
├── mcpProvider.ts # registerMcpServerDefinitionProvider
├── sidebar.ts # TreeDataProvider for the activity-bar view
├── graphPanel.ts # webview panel for the interactive graph
├── statusBar.ts # status-bar item
├── commands.ts # command palette commands
├── settings.ts # typed config accessors
├── output.ts # log/output channel
└── __tests__/ # node:test smoke tests for the manifest
```
### Local development
```bash
cd extension
npm install
npm run watch # rebuild dist/extension.js on save
```
To debug the extension live in a real VS Code instance:
1. Open the `extension/` folder in VS Code.
2. `F5` (Run > Start Debugging) launches a new "Extension Development Host"
window with the extension loaded.
3. Open any folder in that host window. The MCP server registration kicks
in on activation; the sidebar appears in the Activity Bar.
4. Output Channel: `View > Output > SocratiCode`.
### Build, lint, test, package
```bash
cd extension
npm run lint # biome check
npm run typecheck # tsc --noEmit
npm run compile # esbuild bundle to dist/
npm test # node:test smoke tests on the manifest
npm run package # produces socraticode-<version>.vsix
```
### Publishing
The extension is published to two registries from the same `.vsix`:
- **VS Code Marketplace** via `vsce publish` (Azure DevOps PAT)
- **Open VSX Registry** via `ovsx publish` (Eclipse PAT)
CI handles this on `v*` tags via `.github/workflows/extension-release.yml`.
The required GitHub Actions secrets are `VSCE_PAT` (Azure DevOps personal
access token with Marketplace Manage scope) and `OVSX_PAT` (Eclipse
access token with Open VSX namespace). Each is set up once per
publisher account. Maintainer notes for the full submission flow live
outside this public repo.
To publish manually:
```bash
cd extension
npm run publish:vsce # Microsoft marketplace
npm run publish:ovsx # Open VSX
# or both at once:
npm run publish:all
```
### Versioning
The extension's version tracks the engine version. The
`scripts/bump-plugin-versions.mjs` `release-it` hook bumps
`extension/package.json` along with every plugin manifest, so an engine
release `vX.Y.Z` automatically bumps the extension to `X.Y.Z`. Patch
drift is allowed for extension-only hotfixes (e.g. release the engine
at `1.7.2` but ship the extension at `1.7.3` for a UI bug fix).
### What the extension does NOT do
- It does **not** re-implement the engine. All search, dependency-graph
analysis, impact analysis and indexing happen in the engine via the
registered MCP server. The extension is a thin distribution and UI
shell.
- It does **not** ship its own copy of the engine. The engine launches
via `npx -y socraticode` (configurable via the `socraticode.command` /
`socraticode.args` settings).
- It does **not** add language-server features (code lenses, hovers,
diagnostics). Those would conflict with the host editor's existing
language servers and aren't aligned with the engine's value
proposition.
---
## Troubleshooting
### "Docker is not available"
+9 -3
View File
@@ -169,13 +169,19 @@ SocratiCode is available as a native plugin on multiple AI coding platforms. Plu
| Platform | Install method |
|:---------|:---------------|
| Claude Code | `claude plugin marketplace add giancarloerra/socraticode && claude plugin install socraticode@socraticode` — [full instructions](#claude-code-plugin-recommended-for-claude-code-users) |
| Cursor | `/add-plugin https://github.com/giancarloerra/socraticode` |
| VS Code Copilot | Command Palette → `Chat: Install Plugin From Source` → `https://github.com/giancarloerra/socraticode` |
| **VS Code / Cursor / VSCodium / Gitpod / code-server / Theia / Antigravity / Particle Workbench** (extension) | Search **SocratiCode** in the Extensions panel (VS Code Marketplace or Open VSX). The extension auto-registers the MCP server in Copilot agent mode, Cline, Continue and Roo Code, and adds a sidebar, interactive graph webview, and onboarding walkthrough. _Source: [`extension/`](./extension)._ |
| Cursor | `/add-plugin https://github.com/giancarloerra/socraticode` (plugin format with skills). Also listed in the Cursor Marketplace at [cursor.com/marketplace](https://cursor.com/marketplace). |
| VS Code Copilot | Command Palette → `Chat: Install Plugin From Source` → `https://github.com/giancarloerra/socraticode` (plugin format with skills) |
| Zed | Add as a custom MCP server in Zed settings — [config example](#zed) |
| Gemini CLI | `gemini extensions install https://github.com/giancarloerra/socraticode` |
| OpenAI Codex | No public plugin directory yet — use the [MCP config](#quick-start) or see **Codex local install** below |
> **VS Code Copilot**: The chat plugins feature is in preview. Enable it with `chat.plugins.enabled: true` in your VS Code settings.
> **Extension vs plugin (what to install in VS Code / Cursor):**
>
> - The **extension** (Marketplace / Open VSX listing) is a regular VS Code-style extension. It auto-registers the MCP server in Copilot agent mode, Cline, Continue, Roo Code, plus adds a sidebar, status-bar item, interactive graph webview, walkthrough and palette commands. Best for most users.
> - The **plugins** (`/add-plugin` for Cursor, `Chat: Install Plugin From Source` for VS Code Copilot) bundle the MCP server **plus skills + agent instructions** that teach the AI to use SocratiCode tools effectively. Best when you want the agent to be opinionated about using SocratiCode.
> - You can install both. The extension only registers the MCP server once, so they don't conflict.
> - **VS Code Copilot note**: the chat plugins feature is in preview. Enable it with `chat.plugins.enabled: true` in your VS Code settings.
> **Codex local plugin install**: Clone the repo and register it in your personal plugin marketplace:
> ```bash
+4
View File
@@ -0,0 +1,4 @@
node_modules/
dist/
*.vsix
.vscode-test/
+13
View File
@@ -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/**
+32
View File
@@ -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.
+684
View File
@@ -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.
-------------------------------------------------------------------------------
+192
View File
@@ -0,0 +1,192 @@
<p align="center">
<img src="https://raw.githubusercontent.com/giancarloerra/socraticode/main/socraticode_logo.png" alt="SocratiCode" width="160">
</p>
<h1 align="center">SocratiCode</h1>
<p align="center"><strong>The codebase context engine for AI assistants.</strong><br>
Same understanding of your code, every assistant, every tool switch.</p>
<p align="center">
<a href="https://marketplace.visualstudio.com/items?itemName=giancarloerra.socraticode"><img src="https://img.shields.io/visual-studio-marketplace/v/giancarloerra.socraticode?style=flat-square&logo=visualstudiocode&logoColor=white&label=VS%20Code%20Marketplace" alt="VS Code Marketplace"></a>
<a href="https://marketplace.visualstudio.com/items?itemName=giancarloerra.socraticode"><img src="https://img.shields.io/visual-studio-marketplace/i/giancarloerra.socraticode?style=flat-square&label=installs" alt="Installs"></a>
<a href="https://open-vsx.org/extension/giancarloerra/socraticode"><img src="https://img.shields.io/open-vsx/v/giancarloerra/socraticode?style=flat-square&label=Open%20VSX" alt="Open VSX"></a>
<a href="https://open-vsx.org/extension/giancarloerra/socraticode"><img src="https://img.shields.io/open-vsx/dt/giancarloerra/socraticode?style=flat-square&label=downloads" alt="Open VSX Downloads"></a>
<a href="https://github.com/giancarloerra/socraticode"><img src="https://img.shields.io/github/stars/giancarloerra/socraticode?style=flat-square&logo=github&label=stars" alt="GitHub stars"></a>
<a href="https://discord.gg/5DrMXfNG"><img src="https://img.shields.io/badge/Discord-Join-5865F2?style=flat-square&logo=discord&logoColor=white" alt="Discord"></a>
<a href="https://www.npmjs.com/package/socraticode"><img src="https://img.shields.io/npm/v/socraticode?style=flat-square&logo=npm&label=engine" alt="npm engine"></a>
<a href="https://github.com/giancarloerra/socraticode/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-AGPL--3.0-blue?style=flat-square" alt="License"></a>
</p>
<p align="center">
<strong><a href="https://github.com/giancarloerra/socraticode#readme">Full documentation, configuration reference, and benchmarks on GitHub →</a></strong>
</p>
---
> **The big number.** On a 2.45M-line codebase, SocratiCode answers the same architectural question with **61% less context burned**, **84% fewer tool calls**, and **37x faster** than a grep-based AI agent. Same model, dramatically better answers. [Full benchmark on GitHub.](https://github.com/giancarloerra/socraticode#real-world-benchmark-vs-code-245m-lines-of-code-with-claude-opus-46)
This extension auto-registers the SocratiCode MCP server in any
MCP-compatible chat or agent in your editor, with no `mcp.json` editing
required.
## What it does
- **Hybrid search** (semantic + BM25, fused via Reciprocal Rank Fusion).
Tested on codebases over 40 million lines.
- **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.
- **Call-flow tracing** from any entry point, so onboarding to a
legacy module takes minutes instead of days.
- **Cross-repo search** across linked workspaces. The bug is in the
API gateway and the AI is looking at the front-end? It sees the
full system in one query.
- **Interactive graph viewer** with blast-radius overlay, search,
click-to-open-file, 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 team
designed, not what it guessed from filenames.
- **Branch-aware indexing**: every branch gets its own index, so PR
reviews see the code actually being reviewed.
## Built for real-world big teams and projects
- **Refactor safety on a monorepo.** Blast-radius analysis surfaces
every file and symbol that calls into a target before any change
goes in. Particularly useful in regulated and legacy contexts.
- **Multi-repo orgs.** Cross-project search treats your microservices
as one searchable surface, not N disconnected repos.
- **Tool-independent.** Move from Cursor to Copilot to Cline to
whatever ships next. The index, dependency graphs and context
artefacts survive every tool switch. No vendor lock-in.
- **Air-gapped friendly.** The default deployment runs entirely on
your machine via Docker (Qdrant + Ollama). Code never leaves the
network unless you explicitly point at an external service via the
`socraticode.env` setting.
- **Open source at the core (AGPL-3.0).** Battle-tested across thousands
of repositories. Every component that touches your code is inspectable.
- **18+ languages out of the box.** TypeScript, JavaScript, Python, Go,
Rust, Java, Kotlin, Scala, C#, C, C++, Ruby, PHP, Swift, Bash, Dart,
Lua, Svelte, Vue, plus 35+ plain-text formats.
## Quick start
1. **Install the extension.** Search **SocratiCode** in your editor's
Extensions panel. The MCP server registers automatically.
2. **Index the workspace.** Open the SocratiCode sidebar (Activity Bar
icon) and click *Index this workspace*. The first index downloads
the embedding model; subsequent updates are incremental.
3. **Ask anything.** Use your AI assistant: "where is auth handled?",
"what breaks if I change `processOrder`?", "trace the nightly cron
job", "what tables does this API touch?".
4. **Open the interactive graph.** Command Palette →
`SocratiCode: Open interactive graph`.
A walkthrough is shown on first install; re-open it any time via
`SocratiCode: Open getting-started walkthrough`.
## Requirements
- An editor on the VS Code 1.99+ API (any of the editors listed above).
- Node.js 18+ on `PATH` (the engine launches via `npx`).
- Docker Desktop running (for the default local engine), OR a
reachable external Qdrant if you'd rather not use Docker (configured
via `socraticode.env`, see Settings).
## Commands
All commands appear under `SocratiCode:` in the Command Palette.
- `SocratiCode: Index current workspace`: kick off a one-time index.
- `SocratiCode: Open interactive graph`: render the dependency / call
graph as an in-editor webview.
- `SocratiCode: Refresh indexed projects`: reload the sidebar tree.
- `SocratiCode: Open getting-started walkthrough`: replay the onboarding.
- `SocratiCode: Show output / logs`: open the SocratiCode output channel.
## Settings
| Setting | Default | Purpose |
|---|---|---|
| `socraticode.command` | `"npx"` | Engine launcher. |
| `socraticode.args` | `["-y", "socraticode"]` | Args for the launcher. |
| `socraticode.env` | `{}` | Environment variables forwarded to the engine. Use this to point at an external Qdrant cluster (`QDRANT_MODE=external`, `QDRANT_URL`, `QDRANT_API_KEY`), pick an embedding provider (`EMBEDDING_PROVIDER`, `OPENAI_API_KEY`, `GOOGLE_API_KEY`), enable branch-aware indexing, link multiple projects, or set any other engine knob from the [engine README](https://github.com/giancarloerra/socraticode#configuration). |
| `socraticode.statusBar` | `true` | Show the status-bar item. |
## Compatibility
**Editors.** This extension installs in any editor that supports the
VS Code 1.99+ extension API:
- Microsoft VS Code (Stable / Insiders)
- Cursor
- VSCodium
- Gitpod
- code-server
- Eclipse Theia-based editors
- Google Antigravity
- Particle Workbench
**AI surfaces.** The MCP server registered by this extension is
discovered automatically by any MCP-compatible chat or agent installed
in your editor:
- GitHub Copilot agent mode
- Cursor's Agent / Composer
- The Gemini chat surface in Antigravity
- [Cline](https://github.com/cline/cline)
- [Continue](https://www.continue.dev/)
- [Roo Code](https://roo.tech/)
- Any other MCP-aware client, including ones not listed here
If your editor or AI surface speaks MCP, SocratiCode shows up.
## SocratiCode Cloud (private beta)
The same engine, hosted by us. Adds managed infrastructure (no Docker
or Qdrant or Ollama on your machine), webhook-driven auto-indexing on
every push and every branch, shared team indexes across your whole
organisation, SSO/SAML, audit logs, and SOC 2 / ISO 27001-aligned
controls. Currently in private beta.
[Request access at socraticode.cloud →](https://socraticode.cloud)
## Privacy and data
- The engine indexes locally by default. Code never leaves your
machine unless you explicitly configure an external service via
`socraticode.env`.
- No telemetry from the extension.
- The engine is open source under AGPL-3.0; every component that
touches your code is inspectable.
## Learn more
The extension is the install surface. The full picture lives in the
project repo:
- **[Full README, configuration reference, and benchmark methodology](https://github.com/giancarloerra/socraticode#readme)**
- [Issues and feature requests](https://github.com/giancarloerra/socraticode/issues)
- [Discord community](https://discord.gg/5DrMXfNG)
## 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 use an existing
Qdrant instance.
- **MCP tools don't appear in your assistant**: 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 the embedding model
the first time. Subsequent runs are fast.
- **Anything else**: `SocratiCode: Show output / logs` from the
command palette has the engine output.
## License
[AGPL-3.0-only](https://github.com/giancarloerra/socraticode/blob/main/LICENSE).
The engine and this extension are open source.
+27
View File
@@ -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"
}
}
}
}
+33
View File
@@ -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

+5691
View File
File diff suppressed because it is too large Load Diff
+221
View File
@@ -0,0 +1,221 @@
{
"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": "giancarloerra",
"license": "AGPL-3.0-only",
"icon": "images/icon.png",
"galleryBanner": {
"color": "#3a3d8c",
"theme": "dark"
},
"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": "Non-secret environment variables forwarded to the engine. Use this for non-sensitive engine config like external Qdrant URL (`QDRANT_MODE=external`, `QDRANT_URL`), embedding provider selection (`EMBEDDING_PROVIDER`), project IDs, branch-aware indexing, and so on. AVOID storing API keys or tokens here: workspace settings can be synced via VS Code Settings Sync and may end up in committed `.vscode/settings.json` files. For secrets, prefer OS environment variables, a local `.env` file outside settings, or a system keychain.",
"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"
}
}
+121
View File
@@ -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}`);
}
});
});
+99
View File
@@ -0,0 +1,99 @@
// 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. Wrapped in try/catch because some VS Code forks
// do not expose `workbench.action.openWalkthrough` and the
// command would otherwise reject silently.
try {
await vscode.commands.executeCommand(
"workbench.action.openWalkthrough",
`${context.extension.id}#socraticode.gettingStarted`,
false,
);
} catch (err) {
log(`Failed to open walkthrough: ${(err as Error).message}`);
vscode.window.showWarningMessage(
"SocratiCode: this editor does not appear to support walkthroughs. See the marketplace listing for getting-started guidance.",
);
}
}),
);
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") {
// `workbench.action.chat.open` is not guaranteed across every
// VS Code-compatible editor (some Theia-based forks omit it). Fall
// back to the output channel if the host doesn't expose the chat
// command, so the user always gets useful feedback.
try {
await vscode.commands.executeCommand("workbench.action.chat.open");
} catch (err) {
log(`Open chat failed: ${(err as Error).message}`);
output().show(true);
vscode.window.showInformationMessage(
"SocratiCode: this editor does not expose a chat command. Opened the SocratiCode output channel instead.",
);
}
} else if (action === "Show output") {
output().show(true);
}
}
+59
View File
@@ -0,0 +1,59 @@
// 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. Persist the
// "shown" flag only AFTER the command resolves, so if the host fails
// to open the walkthrough (some VS Code forks don't expose
// `workbench.action.openWalkthrough`), the user is offered it again
// next session instead of silently skipping it forever.
const shown = context.globalState.get<boolean>(FIRST_RUN_KEY, false);
if (!shown) {
try {
await vscode.commands.executeCommand(
"workbench.action.openWalkthrough",
`${context.extension.id}#socraticode.gettingStarted`,
false,
);
await context.globalState.update(FIRST_RUN_KEY, true);
} catch (err) {
log(`Failed to open first-run walkthrough: ${(err as Error).message}`);
}
}
log("SocratiCode extension activated");
}
export function deactivate(): void {
// Subscriptions are disposed automatically by VS Code via
// context.subscriptions. No additional cleanup needed today.
}
+246
View File
@@ -0,0 +1,246 @@
// 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) => {
void handleWebviewMessage(msg);
});
currentPanel.webview.html = wrapHtml(html, currentPanel.webview);
}
async function loadGraphHtml(projectId?: string): Promise<string | undefined> {
let target: string | undefined;
if (projectId) {
// The `socraticode.openInteractiveGraph` command accepts a projectId
// argument from any caller (palette, sidebar, other extensions). A
// value like `../../etc/passwd` would escape GRAPH_DIR via path.join.
// Resolve and confirm the result stays inside GRAPH_DIR.
const candidate = path.resolve(GRAPH_DIR, `${projectId}.html`);
const dirResolved = path.resolve(GRAPH_DIR);
if (candidate !== dirResolved && !candidate.startsWith(dirResolved + path.sep)) {
log(`Graph panel: rejecting suspicious projectId: ${projectId}`);
return undefined;
}
target = candidate;
} 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") {
// Not all VS Code-compatible editors expose `workbench.action.chat.open`
// (some Theia-based forks omit it). Fall back to a friendlier message
// rather than letting the rejection bubble up unhandled.
try {
await vscode.commands.executeCommand("workbench.action.chat.open");
} catch (err) {
log(`Open chat failed: ${(err as Error).message}`);
vscode.window.showInformationMessage(
"SocratiCode: this editor does not expose a chat command. Open your AI assistant manually and paste the copied prompt.",
);
}
}
}
/**
* 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>`;
}
async function handleWebviewMessage(msg: unknown): Promise<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") return;
const ws = vscode.workspace.workspaceFolders?.[0];
if (!ws) {
vscode.window.showWarningMessage("SocratiCode: open a workspace to navigate from the graph.");
return;
}
// The webview HTML is generated by us, but the boundary is still
// untrusted: anything that crosses `postMessage` could be tampered
// with. Reject absolute paths and any path that escapes the workspace
// root (`..`). Normalise via posix paths so the same validation works
// on Windows, macOS, and Linux.
const normalised = path.posix.normalize(m.path.replace(/\\/g, "/"));
const isAbsolute = normalised.startsWith("/") || /^[A-Za-z]:\//.test(normalised);
const escapesRoot =
normalised === ".." || normalised.startsWith("../") || normalised.includes("/../");
if (isAbsolute || escapesRoot || normalised === "." || normalised === "") {
log(`Graph panel: rejecting suspicious path from webview: ${m.path}`);
vscode.window.showWarningMessage("SocratiCode: invalid file path from graph.");
return;
}
const uri = vscode.Uri.joinPath(ws.uri, ...normalised.split("/"));
// Open the document first, then clamp the requested line number against
// the actual document length. A malformed message with a huge `m.line`
// (e.g. Number.MAX_SAFE_INTEGER) would otherwise build a Range far past
// the end of the file. We only check `m.line > 0` and `Number.isInteger`
// here because the upper bound depends on what we just opened.
let editor: vscode.TextEditor;
try {
editor = await vscode.window.showTextDocument(uri);
} catch (err) {
log(`Graph panel: failed to open ${normalised}: ${(err as Error).message}`);
return;
}
if (typeof m.line === "number" && Number.isInteger(m.line) && m.line > 0) {
const lastLine = Math.max(0, editor.document.lineCount - 1);
const lineIndex = Math.min(m.line - 1, lastLine);
const range = new vscode.Range(lineIndex, 0, lineIndex, 0);
editor.selection = new vscode.Selection(range.start, range.end);
editor.revealRange(range);
}
}
+84
View File
@@ -0,0 +1,84 @@
// 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 | undefined {
const provider = new SocratiCodeMcpProvider();
// The `engines.vscode: ^1.99.0` field in package.json prevents
// installation on hosts without the MCP API, but some VS Code-derived
// editors lie about their reported version. Defensively check that
// the API surface exists before calling it, so activation degrades
// gracefully (sidebar / commands / status bar still work) instead of
// throwing a hard error that disables the entire extension.
if (typeof vscode.lm?.registerMcpServerDefinitionProvider !== "function") {
log(
"vscode.lm.registerMcpServerDefinitionProvider is unavailable in this host; " +
"skipping MCP server registration. Sidebar, commands and status bar still work.",
);
return undefined;
}
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;
}
+30
View File
@@ -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}`);
}
+30
View File
@@ -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),
};
}
+122
View File
@@ -0,0 +1,122 @@
// 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 {
// Clamp to zero so a file mtime slightly ahead of the local clock
// (NTP correction, container clock skew) doesn't render "-5s ago".
const seconds = Math.max(0, 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`;
}
+39
View File
@@ -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();
}
+23
View File
@@ -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/**/*"]
}
+52
View File
@@ -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
(the default is `nomic-embed-text` via the local Docker Ollama, a few
hundred megabytes), 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.
+36
View File
@@ -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).
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env node
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright (C) 2026 Giancarlo Erra - Altaire Limited
//
// release-it `after:bump` hook. Synchronises the version field across
// every plugin / extension manifest in the repo so a single engine
// release also bumps the Claude / Cursor / Codex plugins and the
// VS Code / Open VSX extension. Skips manifests that don't exist.
//
// Usage: node scripts/bump-plugin-versions.mjs <version>
import { existsSync, readFileSync, writeFileSync } from "node:fs";
import { resolve } from "node:path";
const MANIFESTS = [
".claude-plugin/plugin.json",
".cursor-plugin/plugin.json",
".codex-plugin/plugin.json",
"extension/package.json",
];
const version = process.argv[2];
if (!version) {
console.error("Usage: bump-plugin-versions.mjs <version>");
process.exit(1);
}
let touched = 0;
for (const rel of MANIFESTS) {
const path = resolve(process.cwd(), rel);
if (!existsSync(path)) continue;
try {
const json = JSON.parse(readFileSync(path, "utf8"));
if (json.version === version) continue;
json.version = version;
writeFileSync(path, `${JSON.stringify(json, null, 2)}\n`);
console.log(`bumped ${rel} -> ${version}`);
touched += 1;
} catch (err) {
console.error(`failed to bump ${rel}:`, err.message);
process.exit(1);
}
}
if (touched === 0) {
console.log("no manifests needed bumping");
}