@c4a/extract-ts 0.5.29-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -0
- package/index.js +14757 -0
- package/package.json +9 -0
- package/wasm/tree-sitter-tsx.wasm +0 -0
- package/wasm/tree-sitter-typescript.wasm +0 -0
- package/wasm/tree-sitter.wasm +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# @c4a/extract-ts
|
|
2
|
+
|
|
3
|
+
TypeScript/TSX extraction plugin for C4A. Implements the `ExtractionPlugin` protocol from `@c4a/extract`.
|
|
4
|
+
|
|
5
|
+
## Role in the monorepo
|
|
6
|
+
|
|
7
|
+
Parses TypeScript/TSX projects: detects package entries from `package.json`, traces re-export chains via Tree-sitter AST, and produces `ExtractionResult` v2 with `SymbolInfo[]` + `RelationInfo[]`.
|
|
8
|
+
|
|
9
|
+
**Depends on:** `extract` (protocol + parser), `web-tree-sitter`
|
|
10
|
+
**Depended on by:** `daemon`
|
|
11
|
+
|
|
12
|
+
## What it does
|
|
13
|
+
|
|
14
|
+
### Layer 0: Entry detection (`detectEntries`)
|
|
15
|
+
|
|
16
|
+
- Parses `package.json` fields: `exports` (with condition mapping), `main`, `bin`, `workspaces`
|
|
17
|
+
- Maps `dist/` paths back to `src/` (e.g., `dist/index.js` -> `src/index.ts`)
|
|
18
|
+
- Determines package kind: `lib` / `cli` / `app` / `service`
|
|
19
|
+
- Recursively detects monorepo sub-packages via `workspaces` globs
|
|
20
|
+
|
|
21
|
+
### Layer 1: Symbol extraction (`extractSymbols`)
|
|
22
|
+
|
|
23
|
+
- Traces re-export chains from entry files (`export * from`, `export { A } from`, `export function/class/type`)
|
|
24
|
+
- Handles circular re-exports (cycle detection via `inFlight` set)
|
|
25
|
+
- Extracts symbols: function, class, interface, type, enum, variable, component, hook
|
|
26
|
+
- Extracts class/interface members (props, methods) as nested `SymbolInfo`
|
|
27
|
+
- Marks visibility: `exported` (reachable from entry) vs `internal`
|
|
28
|
+
- Extracts relations: `imports`, `imports_type`, `extends`, `implements`, `param_type`, `return_type`, `of_type`
|
|
29
|
+
- All relations: `grounding=code`, `source=ast`, `confidence=1.0`
|
|
30
|
+
|
|
31
|
+
## Key exports
|
|
32
|
+
|
|
33
|
+
- `TypeScriptPlugin` — the plugin class, implements `ExtractionPlugin`
|
|
34
|
+
|
|
35
|
+
## Internal modules
|
|
36
|
+
|
|
37
|
+
| File | Purpose |
|
|
38
|
+
|------|---------|
|
|
39
|
+
| `plugin.ts` | Plugin class, wires detectEntries + extractSymbols |
|
|
40
|
+
| `entryDetector.ts` | package.json parsing, exports condition mapping, dist->src, workspaces |
|
|
41
|
+
| `symbolExtractor.ts` | Tree-sitter AST extraction, symbol/relation collection |
|
|
42
|
+
| `exportTracer.ts` | Re-export chain tracing with cycle detection |
|
|
43
|
+
| `pathUtils.ts` | Module path resolution, relative import handling |
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { ExtractionPluginRegistry } from "@c4a/extract";
|
|
49
|
+
import { TypeScriptPlugin } from "@c4a/extract-ts";
|
|
50
|
+
|
|
51
|
+
const registry = new ExtractionPluginRegistry();
|
|
52
|
+
registry.register(new TypeScriptPlugin());
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The daemon registers this plugin statically on startup. No configuration needed.
|
|
56
|
+
|
|
57
|
+
## Development
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
bun run --filter @c4a/extract-ts build
|
|
61
|
+
bun run --filter @c4a/extract-ts typecheck
|
|
62
|
+
bun run --filter @c4a/extract-ts test
|
|
63
|
+
bun run --filter @c4a/extract-ts lint
|
|
64
|
+
```
|