Source Tree Architecture — Weavetab Docs
Internal organization and module boundaries within the @weavetab/sdk package. Official documentation and technical reference for Source Tree Architectur...
# Source Tree Architecture
The `@weavetab/sdk` codebase is organized around clear modular boundaries:
```
sdk/
├── src/
│ ├── index.ts # Master library exports (definePlugin, PluginBuilder, defineTool, types)
│ ├── cli.ts # Developer CLI commands (init, build, manifest, preflight, doctor, etc.)
│ ├── desktop.ts # DesktopClient & Electron app discovery types
│ ├── preflight.ts # Security, anti-squatting, and agent instructions context budget auditor
│ ├── tab.ts # Lightweight TabClient wrapper around CDP session
│ ├── testing.ts # Offline unit test simulation harness (simulateToolCall, createMockContext, etc.)
│ ├── version.ts # Synchronized package semver constant
│ └── schema/
│ └── exporter.ts # Generates JSON Schema Draft-07 & weavetab.json from TypeScript types
├── schema/
│ ├── plugin.json # Exported plugin JSON Schema specification
│ └── tool.json # Exported tool JSON Schema specification
├── test/
│ ├── cli.test.mjs # CLI commands & preflight verification tests
│ ├── ecosystem.test.mjs # Ecosystem & SDK integration tests
│ └── schema.test.mjs # Schema export & validation unit tests
├── docs/ # Documentation markdown files mirrored to weavetab.dev/docs
├── package.json
└── tsconfig.json
```
---
## Key Modules
### `src/preflight.ts`
Enforces the mandatory context budget on instructions:
- `MIN_INSTRUCTIONS_CHARS = 20`
- `MAX_INSTRUCTIONS_CHARS = 3200`
- `MAX_INSTRUCTIONS_LINES = 80`
Also audits permission consistency between code and `weavetab.json`.
### `src/index.ts`
Provides the declarative `definePlugin` / `defineTool` / `defineCommand` helpers alongside the fluent `PluginBuilder` class, storage/extension/memory interfaces, and permission definitions.
### `src/schema/exporter.ts`
Programmatically generates the single-source-of-truth JSON Schema Draft-07 documents (`schema/plugin.json`, `schema/tool.json`).