agentleFS
MicrosoftKnown publishermicrosoft/tscodesearch/vscode-codesearch/AGENTS.md

tscodesearch / vscode-codesearch

AGENTS.md5 starsChanged 7 months agoMITView on GitHub

VS Code extension that provides a real-time search panel backed by the local Tantivy index managed by the codesearch/ daemon. As the user types, it issues queries against the daemon's HTTP API and renders results with file metadata, highlights, and one-click file opening. The split between client.ts and extension.ts is intentional: client.ts imports nothing from vscode, so it can be unit-tested with plain Node.js. Defined in client.ts MODES array. Each entry has key, label, queryBy, weights, desc, and optionally astMode/uses_kind.…

  • Installs packages
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository2 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All error notifications include an Open Settings button.

    line 95
  2. Very specific:

    After install, reload the VS Code window.

    line 124

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

vscode-codesearch -- developer notes

VS Code extension that provides a real-time search panel backed by the local Tantivy index managed by the codesearch/ daemon. As the user types, it issues queries against the daemon's HTTP API and renders results with file metadata, highlights, and one-click file opening.

Architecture

----------------------------------------------------------
  WEBVIEW (HTML + inline JS, runs in isolated iframe)
  search input | mode selector | filters | results list
  communicates via postMessage
----------------------------------------------------------
                           | vscode.postMessage / onDidReceiveMessage
----------------------------------------------------------
  EXTENSION HOST (Node.js, src/extension.ts)
  command registration | panel lifecycle
  config discovery | message routing
       | imports
  src/client.ts (pure logic, no vscode dependency)
----------------------------------------------------------
                           | HTTP localhost:{port}
                  codesearch daemon (indexserver/daemon.py)
                  (in-process Tantivy backend per root)

The split between client.ts and extension.ts is intentional: client.ts imports nothing from vscode, so it can be unit-tested with plain Node.js.

Module map

FileResponsibility
src/client.tsAll VS Code-free logic. MODES constant, CodesearchConfig type, loadConfig, getRoots, sanitizeName, collectionForRoot, doQueryCodebase, doQuerySingleFile, runSearchPipeline, renderTextTree, resolveFilePath. Exported for tests.
src/server.tsServerManager -- daemon lifecycle wrapper. Spawns node ts.mjs for start/stop/restart, manages roots in config.json.
src/extension.tsVS Code wiring only. Config discovery, view and command registration, and activate / deactivate.
src/status.tsStatus bar item. Polls the daemon's /status and /verify/status every 5 s and renders state.
src/treeview.ts"Roots" tree view in the activity bar.
src/watcher.tsThin HTTP helper used by the status bar.
src/test/client.test.ts~65 unit tests. No daemon required. Covers config parsing, root/collection resolution, every search mode, path resolution, HTTP behaviour against a mock server.
src/test/pipeline.test.tsPipeline integration tests. Skip when daemon is not running.
src/test/status.test.tsStatus-bar formatting tests.
package.jsonExtension manifest. Registers codesearch.openPanel (Ctrl+Shift+F1), settings, build/test scripts.
tsconfig.jsonCommonJS target, esModuleInterop: true, strict. Output to out/.
.vscodeignoreExcludes src/, node_modules/, maps from the packaged VSIX.
.vscode/launch.jsonF5 launches the Extension Development Host with this folder loaded.
.vscode/tasks.jsonDefault build task runs npm run compile; background task runs npm run watch.

Search modes

Defined in client.ts MODES array. Each entry has key, label, queryBy, weights, desc, and optionally astMode/uses_kind. The daemon's /query-codebase does an index pre-filter (Tantivy) followed by tree-sitter AST post-processing for line-level matches.

The queryBy/weights fields on MODES are not sent to the daemon -- /query-codebase resolves them server-side from astMode + uses_kind (see _resolve_query_params in indexserver/daemon.py). They survive on the client only as labels for the panel UI and may go away in a future cleanup. The intent column below describes what the user sees; the actual field set queried is determined by the server.

Mode names are canonical and match the MCP query_codebase modes. The text entry (which used to send the unrecognized mode text to the daemon and silently fail) has been removed; use all_refs for broad identifier search.

KeyastMode sent to daemonuses_kindIntent
declarationsdeclarations--Method/type signature search [T1]
implementsimplements--Interface implementors [T1]
callscalls--Call sites of a method [T1]
usesuses--Type reference search (default type_refs,cast_types) [T2]
castscasts--Explicit (T)expr / as T cast sites [T1]
attrsattrs--[Attribute] / @decorator / #[attribute] [T1]
all_refsall_refs--All identifier occurrences -- broadest
accesses_onaccesses_on--.Member accesses on instances of a type
uses_fieldusesfieldFields/properties declared as a given type
uses_paramusesparamMethod/ctor parameters typed as a given type

The server-side field-set mapping (one source of truth) lives in indexserver.daemon._resolve_query_params; see ../AGENTS.md for the full mode -> query-by table.

Config

The extension reads tscodesearch/config.json -- the same file used by the daemon.

{
  "api_key": "codesearch-local",
  "port": 8108,
  "roots": { "default": { "path": "C:/myproject/src" } }
}

Discovery order:

  1. VS Code setting tscodesearch.repoPath (must point to the tscodesearch repository root)
  2. Auto-detect: looks for config.json in each workspace folder and validates that it contains api_key

findConfigPath() in extension.ts resolves config.json beneath the discovered repository root and validates its JSON.

All error notifications include an Open Settings button.

Build

cd vscode-codesearch
npm install          # first time only
npm run compile      # one-shot build -> out/
npm run watch        # incremental rebuild on save
npm test             # all tests (skip pipeline if daemon not up)

The out/ directory must exist before VS Code loads the extension. If you see "command 'codesearch.openPanel' not found", run npm run compile and reload the window.

Install / run

Development (F5): Open vscode-codesearch/ as a VS Code workspace, press F5. A new Extension Development Host opens with the extension loaded.

Install from folder (no packaging): F1 -> Developer: Install Extension from Location... -> select vscode-codesearch/.

Package and install:

npm install -g @vscode/vsce
npm run package -- -o codesearch.vsix
code --install-extension codesearch.vsix

After install, reload the VS Code window. The panel opens with Ctrl+Shift+F1 or F1 -> TsCodeSearch: Open Panel.

Testing

npm test                                                # all tests
node --require tsx/cjs --test src/test/client.test.ts   # unit tests only

Pipeline tests need the daemon running (ts start); they skip with a clear message otherwise.

Webview message protocol

DirectionMessageFields
Webview -> Hostsearchquery, mode, ext, sub, root, limit
Webview -> HostopenFilerelativePath, root
Host -> Webviewresultshits, found, elapsed, query, mode
Host -> Webviewerrormessage
Host -> WebviewconfigErrormessage

Key gotchas

Must compile before loading. VS Code loads out/extension.js. If out/ is missing, the command is registered but activation fails silently -> "command not found". Always run npm run compile (or use npm run watch during development).

Schema is fixed at index creation time. Indexed fields are populated by the AST extractors, which pre-split compound forms into individual identifiers (e.g. Task<Widget> -> Task, Widget). After any schema change, ts recreate is the way to rebuild.

repoPath must point to the repository root. The extension resolves config.json, ts.mjs, and the local daemon from that directory.

Webview HTML is a TypeScript template literal. The entire HTML including inline JS is built as a backtick string in buildWebviewHtml(). The inline JS must use regular quote strings ('...', "..."), not template literals, to avoid ambiguity with TypeScript's own ${} interpolation. The nonce and initial data (MODES, ROOTS, DEFAULT_ROOT) are the only TypeScript interpolations.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.