Skip to content

Commit a350f10

Browse files
authored
Merge branch 'main' into agent/jackdaw/implement-batch-operations-for-spec-sync-mnt0y5p5-14a32a
2 parents 64c0fcb + 1270132 commit a350f10

13 files changed

Lines changed: 1333 additions & 25 deletions

File tree

Cargo.lock

Lines changed: 59 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ walkdir = "2"
2525
colored = "3"
2626
notify = "7"
2727
notify-debouncer-full = "0.4"
28+
tree-sitter = "0.24"
29+
tree-sitter-typescript = "0.23"
30+
tree-sitter-python = "0.23"
31+
tree-sitter-rust = "0.23"
2832
sha2 = "0.10"
2933
ureq = { version = "3", features = ["json"] }
3034
dialoguer = "0.11"

specs/exports/exports.spec.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ files:
1515
- src/exports/csharp.rs
1616
- src/exports/php.rs
1717
- src/exports/ruby.rs
18+
- src/exports/ast/mod.rs
19+
- src/exports/ast/typescript.rs
20+
- src/exports/ast/python.rs
21+
- src/exports/ast/rust_lang.rs
1822
db_tables: []
1923
tracks: [60]
2024
depends_on:
@@ -25,7 +29,7 @@ depends_on:
2529

2630
## Purpose
2731

28-
Language-aware export extraction from source files. Auto-detects the programming language from file extension and extracts public/exported symbol names using regex-based parsing (no AST required). Supports 11 languages: TypeScript/JS, Rust, Go, Python, Swift, Kotlin, Java, C#, Dart, PHP, and Ruby.
32+
Language-aware export extraction from source files. Auto-detects the programming language from file extension and extracts public/exported symbol names using regex-based parsing or tree-sitter AST analysis. Supports 11 languages: TypeScript/JS, Rust, Go, Python, Swift, Kotlin, Java, C#, Dart, PHP, and Ruby.
2933

3034
## Public API
3135

@@ -40,6 +44,23 @@ Language-aware export extraction from source files. Auto-detects the programming
4044
| `has_extension` | `file_path: &Path, extensions: &[String]` | `bool` | Check if file matches specific extensions, or any supported language if extensions is empty |
4145
| `extract_exports` | `content: &str` | `Vec<String>` | Per-language backend function that parses source text and returns exported symbol names (one per backend file) |
4246
| `extract_exports_with_resolver` | `content: &str, resolver: Option<&ImportResolver>` | `Vec<String>` | TypeScript-specific: extract exports with optional wildcard re-export resolution via file resolver callback |
47+
| `get_exported_symbols_full` | `file_path: &Path, level: ExportLevel, parse_mode: ParseMode` | `Vec<String>` | Extract exports with full control over granularity and parse mode (Regex or Ast) |
48+
49+
### Exported Modules
50+
51+
| Module | Source | Description |
52+
|--------|--------|-------------|
53+
| `ast` | `src/exports/mod.rs` | Tree-sitter based AST export extraction backends |
54+
55+
### Exported AST Sub-modules
56+
57+
Tree-sitter based export extraction backends for TypeScript, Python, and Rust. Used when `ParseMode::Ast` is selected. Falls back to regex extraction for unsupported languages or when AST parsing fails.
58+
59+
| Sub-module | File | Description |
60+
|------------|------|-------------|
61+
| `typescript` | `ast/typescript.rs` | Tree-sitter based TypeScript/JS export extraction with wildcard resolver support |
62+
| `python` | `ast/python.rs` | Tree-sitter based Python export extraction using `__all__` and top-level definitions |
63+
| `rust_lang` | `ast/rust_lang.rs` | Tree-sitter based Rust `pub` item extraction |
4364

4465
### Language Backend Functions
4566

specs/types/types.spec.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Core data structures and enums shared across the entire spec-sync codebase. Defi
2727
| `ExportLevel` | Export extraction granularity: Type (top-level declarations only) or Member (all public symbols, default) |
2828
| `SpecStatus` | Spec lifecycle status: draft, stable, deprecated. Parsed from frontmatter `status` field |
2929
| `EnforcementMode` | Graduated enforcement level: Warn (always exit 0), EnforceNew (exit 1 for unspecced files), Strict (exit 1 on any error) |
30+
| `ParseMode` | Export parsing strategy: Regex (default, all languages) or Ast (tree-sitter, supports TypeScript/Python/Rust with regex fallback) |
3031

3132
### Exported Structs
3233

src/commands/check.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ fn fix_near_miss_headers(content: &mut String) -> bool {
542542
}
543543

544544
fn auto_fix_specs(root: &Path, spec_files: &[PathBuf], config: &types::SpecSyncConfig) -> usize {
545-
use crate::exports::get_exported_symbols_with_level;
545+
use crate::exports::get_exported_symbols_full;
546546
use crate::parser::{get_spec_symbols, parse_frontmatter};
547547

548548
let mut fixed_count = 0;
@@ -577,9 +577,10 @@ fn auto_fix_specs(root: &Path, spec_files: &[PathBuf], config: &types::SpecSyncC
577577
let mut all_exports: Vec<String> = Vec::new();
578578
for file in &parsed.frontmatter.files {
579579
let full_path = root.join(file);
580-
all_exports.extend(get_exported_symbols_with_level(
580+
all_exports.extend(get_exported_symbols_full(
581581
&full_path,
582582
config.export_level,
583+
config.parse_mode,
583584
));
584585
}
585586
let mut seen = std::collections::HashSet::new();

src/exports/ast/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pub mod python;
2+
pub mod rust_lang;
3+
#[cfg(test)]
4+
mod tests;
5+
pub mod typescript;

0 commit comments

Comments
 (0)