Home · Developers · Guides · Workspace

Workspace

Workspace

Roots, files and project state

The Workspace subsystem gives Nova Coder an understanding of the project it is working on. The indexing pipeline lives in novacoder/indexing/ and is consumed by WorkspaceService to scan directories, detect languages, parse ASTs, extract symbols, and build indexes.

Pipeline

Project Directory
       ↓
Directory Walker
       ↓
Language Detection
       ↓
AST Parser
       ↓
Symbol Extraction
       ↓
Dependency Graph
       ↓
Symbol Index
       ↓
Database

ProjectScanner

ProjectScanner recursively discovers files and produces metadata:

from novacoder.workspace.scanner import ProjectScanner

scanner = ProjectScanner("/path/to/project")
files = scanner.scan()

for path, entry in files.items():
    print(entry.language, entry.size, entry.hash)

print(scanner.summary())

# Incremental scan
changed = scanner.scan(incremental=True)
deleted = scanner.last_deleted

Exclusion Patterns

The scanner skips directories and files matching configured patterns:

workspace:
  exclude_patterns:
    - .git
    - __pycache__
    - node_modules
    - .venv
    - "*.pyc"
    - "test_*.py"
    - "**/*.log"

Language Detection

LanguageDetector maps file extensions to languages:

from novacoder.workspace.languages import LanguageDetector

print(LanguageDetector.detect("main.py"))      # python
print(LanguageDetector.detect("app.js"))         # javascript
print(LanguageDetector.detect("README.md"))      # markdown

Supported languages include Python, JavaScript, TypeScript, Rust, Go, C, C++, Java, C#, PHP, Ruby, Lua, Swift, Kotlin, and more.

Symbol Extraction

SymbolExtractor dispatches to a language-specific extractor. It currently supports Python, JavaScript, and TypeScript (with a regex-based extractor), plus a generic fallback for unsupported languages.

from novacoder.workspace.symbols import SymbolExtractor

extractor = SymbolExtractor()
result = extractor.extract("main.py")

print(result["classes"])
print(result["functions"])
print(result["imports"])

Python extraction uses the ast module with an O(n) parent map to correctly identify methods. JavaScript and TypeScript extractors use regex to capture imports, classes, interfaces, and functions.

SymbolIndex

SymbolIndex stores extracted symbols for fast lookup:

from novacoder.workspace.symbols import SymbolIndex

index = SymbolIndex()
index.add(result["symbols"])

classes = index.find(kind="class")
methods = index.find(name="my_method")

WorkspaceService

WorkspaceService is the kernel service that orchestrates scanning and indexing:

from novacoder.workspace.service import WorkspaceService
from novacoder.config.settings import AppConfig

service = WorkspaceService(config=AppConfig())
service.initialize()
service.start()  # scans if index_on_start is true and not already scanned

print(service.summary())

# Public API
entry = service.get_file("main.py")
files = service.list_files(language="python")
symbols = service.get_symbols(kind="class")
graph = service.import_graph
print(graph.dependents_of("main.py"))

File Entry Format

{
  "path": "src/main.py",
  "language": "python",
  "size": 1024,
  "hash": "a1b2c3d4",
  "imports": ["os", "sys"],
  "classes": ["MyClass"],
  "functions": ["main"],
  "summary": "",
  "dependencies": []
}

Incremental Indexing

ProjectScanner.scan(incremental=True) only re-reads and returns files whose hashes have changed. WorkspaceService uses this to update the SymbolIndex and ImportGraph without rebuilding the entire index. Files read once per scan are reused for symbol extraction, eliminating the previous double-read.

Workspace Events

WorkspaceService publishes events through the EventBus when available:

  • WorkspaceScanned, a scan completed
  • WorkspaceFileChanged, a file was added, modified, or deleted
  • WorkspaceSymbolsUpdated, the symbol index was refreshed

Import Graph

WorkspaceService builds an ImportGraph from file imports. It supports dependency/dependent queries and cycle detection:

from novacoder.graphs import ImportGraph

graph = ImportGraph()
graph.add_imports("main", ["helper"])
print(graph.dependents_of("helper"))  # {'main'}
print(graph.cycle_free())  # True

CLI and TUI Integration

Workspace features are exposed through the CLI and the terminal UI:

# Scan from the command line
python -m novacoder.cli.main scan /path/to/project

In the TUI (novacoder gui or python -m novacoder.cli.main gui), the Workspace page shows the project root, total files, language breakdown, and a searchable symbol table. Clicking Re-scan triggers WorkspaceService.scan() and refreshes the symbol list.

Development Instructions

Adding a New Language Detector Mapping

Edit LanguageDetector.EXTENSIONS in novacoder/workspace/languages.py. If the language needs special handling beyond extension matching, update detect().

Adding a New Symbol Extractor

  1. Create a new extractor class in novacoder/indexing/extractors/ extending LanguageExtractor.
  2. Register it in novacoder/indexing/extractors/__init__.py under EXTRACTORS.
  3. SymbolExtractor will dispatch to it automatically based on LanguageDetector.
  4. Add tests in tests/test_workspace.py.

Testing the Scanner

def test_scanner_finds_files(tmp_path):
    (tmp_path / "main.py").write_text("pass")
    scanner = ProjectScanner(tmp_path)
    files = scanner.scan()
    assert len(files) == 1
    assert files[tmp_path / "main.py"].language == "python"

Testing Symbol Extraction

def test_symbol_extractor(tmp_path):
    file = tmp_path / "module.py"
    file.write_text("class Foo:\n    def bar(self): pass\n")
    result = SymbolExtractor().extract(file)
    assert "Foo" in result["classes"]
    assert "bar" in result["functions"]

Adding Exclusion Patterns

Add patterns to WorkspaceConfig.exclude_patterns in novacoder/config/settings.py and to config/defaults.yaml.

Future Enhancements

  • tree-sitter based multi-language AST parsing
  • Call graph and inheritance graph (implemented)
  • Knowledge graph integration (implemented)
  • Vector embeddings for semantic search (implemented)
  • File watcher for live updates (implemented)
  • Code search capabilities (implemented)
  • Code security analysis (implemented)
  • Code navigation features (implemented)
  • Code refactoring (implemented)
  • Remote workspace support (implemented)
  • Code metrics collection (implemented)
  • Dependency analysis (implemented)
  • Testing integration (implemented)
  • Workspace analytics (implemented)
  • Code documentation generation (implemented)
  • Code formatting (implemented)
  • Code visualization (implemented)
  • Multi-workspace support (implemented)
  • Parallel processing (implemented)

New Workspace Enhancement Systems

The workspace now includes a powerful code search engine with full-text and regex support:

from novacoder.workspace import CodeSearchEngine, SearchQuery

engine = ws_service.search_engine
query = SearchQuery(query="function_name", search_type="text")
results = engine.search(query)

for result in results:
    print(f"{result.file_path}:{result.line_number} - {result.line_content}")

Code Security Analysis

Static application security testing (SAST) with secret detection:

from novacoder.workspace import CodeSecurityAnalyzer

analyzer = ws_service.security_analyzer
vulnerabilities = analyzer.analyze()

for vuln in vulnerabilities:
    print(f"{vuln.severity}: {vuln.vulnerability_type} in {vuln.file_path}:{vuln.line_number}")

Code Navigation

Go-to-definition and find-references capabilities:

from novacoder.workspace import CodeNavigator

navigator = ws_service.code_navigator
location = navigator.go_to_definition("file.py", 10, 5)
references = navigator.find_references("my_function")

Code Refactoring

Safe code refactoring with validation:

from novacoder.workspace import CodeRefactorer

refactorer = ws_service.code_refactorer
result = refactorer.rename_symbol("old_name", "new_name")

Remote Workspace

Git repository cloning and remote repository management:

from novacoder.workspace import RemoteWorkspaceManager, RemoteRepository

manager = ws_service.remote_manager
repo = RemoteRepository(url="https://github.com/user/repo", provider="github")
manager.clone_repository(repo)

Code Metrics

Cyclomatic complexity and maintainability analysis:

from novacoder.workspace import CodeMetricsCollector

collector = ws_service.metrics_collector
metrics = collector.collect("file.py")
print(f"Complexity: {metrics.cyclomatic_complexity}")
print(f"Maintainability: {metrics.maintainability_index}")

Dependency Analysis

Package dependency analysis and vulnerability scanning:

from novacoder.workspace import DependencyAnalyzer

analyzer = ws_service.dependency_analyzer
dependencies = analyzer.analyze()
vulnerabilities = analyzer.check_vulnerabilities()

Testing Integration

Test discovery and coverage analysis:

from novacoder.workspace import TestingIntegration

testing = ws_service.testing_integration
test_files = testing.discover_tests()
coverage = testing.analyze_coverage()

Workspace Analytics

Code growth tracking and contributor activity analysis:

from novacoder.workspace import WorkspaceAnalytics

analytics = ws_service.workspace_analytics
growth = analytics.track_code_growth()
activity = analytics.analyze_contributor_activity()
hot_spots = analytics.detect_hot_spots()

Source: wiki/workspace.md · rendered 2026-11-10