Skip to content

Commit 637cf8c

Browse files
authored
Merge pull request #103 from codervisor:copilot/implement-spec-181
Deprecate TypeScript core in favor of Rust implementation (spec 181)
2 parents 0c76324 + 35a04f7 commit 637cf8c

File tree

240 files changed

+612
-49098
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+612
-49098
lines changed

.github/workflows/copilot-setup-steps.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ jobs:
4040
- name: Install JavaScript dependencies
4141
run: pnpm install --frozen-lockfile
4242

43-
- name: Build lean-spec CLI (TypeScript)
44-
run: pnpm --filter lean-spec run build
45-
4643
- name: Set up Rust toolchain
4744
uses: actions-rust-lang/setup-rust-toolchain@v1
4845

CONTRIBUTING.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ pnpm typecheck # Type check all packages (with caching)
3636
All packages in the monorepo maintain synchronized versions automatically. The root `package.json` serves as the single source of truth.
3737

3838
**Packages:**
39-
- `lean-spec` (CLI package)
40-
- `@leanspec/core` (shared core library)
39+
- `lean-spec` (CLI package - wrapper for Rust binary)
4140
- `@leanspec/ui` (web UI package)
4241
- `@leanspec/mcp` (MCP server wrapper)
42+
- `@leanspec/desktop` (Tauri desktop app)
4343

4444
### Automated Version Sync
4545

@@ -121,9 +121,10 @@ This project uses [Turborepo](https://turbo.build/) to manage the monorepo with
121121
- **Task dependencies** - Dependencies built first automatically
122122

123123
**Packages:**
124-
- `packages/cli` - Main CLI tool (published as `lean-spec`)
125-
- `packages/core` - Core spec parsing/validation library (internal)
126-
- `packages/web` - Live specs showcase (Next.js app)
124+
- `packages/cli` - CLI wrapper for Rust binary (published as `lean-spec`)
125+
- `packages/mcp` - MCP server wrapper (published as `@leanspec/mcp`)
126+
- `packages/ui` - Web UI bundle (published as `@leanspec/ui`)
127+
- `packages/desktop` - Tauri desktop app (not published to npm)
127128
- `docs-site/` - Git submodule pointing to `codervisor/lean-spec-docs` (Docusaurus)
128129

129130
**Key files:**
@@ -134,7 +135,19 @@ This project uses [Turborepo](https://turbo.build/) to manage the monorepo with
134135
**Build specific package:**
135136
```bash
136137
turbo run build --filter=lean-spec
137-
turbo run build --filter=@leanspec/core
138+
turbo run build --filter=@leanspec/ui
139+
```
140+
141+
**Rust Development:**
142+
```bash
143+
# Build Rust binaries
144+
pnpm rust:build
145+
146+
# Run Rust tests
147+
pnpm rust:test
148+
149+
# Copy binaries to packages
150+
pnpm rust:copy
138151
```
139152

140153
## Testing

docs/agents/PUBLISHING.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Publishing Releases
22

3-
**Publish both CLI and UI packages to npm with synchronized versions:**
3+
**Publish CLI and UI packages to npm with synchronized versions:**
4+
5+
## Architecture Overview
6+
7+
With the Rust migration complete (spec 181):
8+
- **CLI** (`lean-spec`) - JavaScript wrapper that invokes Rust binary
9+
- **MCP** (`@leanspec/mcp`) - JavaScript wrapper that invokes Rust MCP binary
10+
- **UI** (`@leanspec/ui`) - Next.js app with inlined utilities
11+
- **Platform packages** - Rust binaries for each platform (published separately)
12+
13+
The Rust binaries are distributed via optional dependencies (e.g., `lean-spec-darwin-arm64`).
414

515
## Publishing Dev Versions
616

@@ -48,12 +58,12 @@ The `.github/workflows/publish-dev.yml` workflow will automatically:
4858

4959
⚠️ **CRITICAL**: All steps must be completed in order. Do NOT skip steps.
5060

51-
1. **Version bump**: Update version in all package.json files (root, cli, core, ui, mcp) for consistency
61+
1. **Version bump**: Update version in all package.json files (root, cli, ui, mcp) for consistency
5262
2. **Update CHANGELOG.md**: Add release notes with date and version
5363
3. **Type check**: Run `pnpm typecheck` to catch type errors (REQUIRED before release)
54-
4. **Test**: Run `pnpm test:run` to ensure tests pass (web DB tests may fail - that's OK)
64+
4. **Test**: Run `pnpm test:run` to ensure tests pass
5565
5. **Build**: Run `pnpm build` to build all packages
56-
6. **Validate**: Run `node bin/lean-spec.js validate` and `cd docs-site && npm run build` to ensure everything works
66+
6. **Validate**: Run `node bin/lean-spec.js validate --warnings-only` and `cd docs-site && npm run build` to ensure everything works
5767
7. **Commit & Tag**:
5868
```bash
5969
git add -A && git commit -m "feat: release version X.Y.Z with [brief description]"
@@ -64,10 +74,9 @@ The `.github/workflows/publish-dev.yml` workflow will automatically:
6474
- ⚠️ **CRITICAL**: This step prevents `workspace:*` from leaking into npm packages
6575
- Creates backups of original package.json files
6676
- Replaces all `workspace:*` dependencies with actual versions
67-
9. **Publish to npm**: For each package (core, cli, mcp, ui):
77+
9. **Publish to npm**: For each package (cli, mcp, ui):
6878
```bash
69-
cd packages/core && npm publish --access public
70-
cd ../cli && npm publish --access public
79+
cd packages/cli && npm publish --access public
7180
cd ../mcp && npm publish --access public
7281
cd ../ui && npm publish --access public
7382
```
@@ -90,7 +99,6 @@ The `.github/workflows/publish-dev.yml` workflow will automatically:
9099
[List enhancements]
91100
92101
### 📦 Published Packages
93-
- `@leanspec/[email protected]`
94102
95103
- `@leanspec/[email protected]`
96104
- `@leanspec/[email protected]`
@@ -119,14 +127,12 @@ The `.github/workflows/publish-dev.yml` workflow will automatically:
119127
120128
## Critical - Workspace Dependencies
121129
122-
- The `@leanspec/core` package MUST NOT be in `packages/cli/package.json` dependencies
123-
- tsup config has `noExternal: ['@leanspec/core']` which bundles the core package
124-
- NEVER add `@leanspec/core` back to dependencies - it will cause `workspace:*` errors
130+
- The CLI package is now a thin wrapper for Rust binaries - no need for bundling
125131
- If you see `workspace:*` in published dependencies, the package is broken and must be republished
126132
127133
## Package Publication Notes
128134
129135
**Important**:
130-
- Do NOT publish `@leanspec/core` or `@leanspec/web` - they are internal packages
131136
- The `@leanspec/ui` package IS published to npm as a public scoped package
132137
- Both `lean-spec` (CLI) and `@leanspec/ui` are published automatically via GitHub Actions when a release is created
138+
- Platform-specific binary packages (e.g., `lean-spec-darwin-arm64`) are published separately via the rust-binaries workflow

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"sync-rust-versions": "tsx scripts/sync-rust-versions.ts",
1212
"publish:platforms": "tsx scripts/publish-platform-packages.ts",
1313
"publish:main": "tsx scripts/publish-main-packages.ts",
14-
"dev": "turbo run dev --filter=@leanspec/ui --filter=@leanspec/core",
14+
"dev": "turbo run dev --filter=@leanspec/ui",
1515
"dev:web": "turbo run dev --filter=@leanspec/ui",
1616
"dev:cli": "turbo run dev --filter=lean-spec",
1717
"dev:desktop": "pnpm --filter @leanspec/desktop dev:desktop",

packages/README.md

Lines changed: 92 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -6,67 +6,83 @@ This directory contains the LeanSpec monorepo packages.
66

77
```
88
packages/
9-
├── core/ - @leanspec/core: Platform-agnostic spec parsing & validation
10-
├── cli/ - lean-spec: CLI tool and MCP server (Node.js)
11-
├── mcp/ - @leanspec/mcp: MCP server wrapper (spec 102)
12-
└── ui/ - @leanspec/ui: Standalone UI bundle + launcher (spec 087)
9+
├── cli/ - lean-spec: CLI wrapper for Rust binary
10+
├── mcp/ - @leanspec/mcp: MCP server wrapper
11+
├── desktop/ - @leanspec/desktop: Tauri desktop app
12+
└── ui/ - @leanspec/ui: Standalone UI bundle + launcher
1313
```
1414

15-
## @leanspec/core
15+
## Architecture (Post Rust Migration)
1616

17-
**Platform-agnostic spec parsing and validation library.**
17+
**As of spec 181**, the core functionality has migrated to Rust:
1818

19-
The core package provides:
20-
- Type definitions (`SpecInfo`, `SpecFrontmatter`, etc.)
21-
- Frontmatter parsing (using gray-matter)
22-
- Validators (frontmatter, structure, line count)
23-
- Utilities (stats, insights, filters)
24-
- Abstract storage interface (`SpecStorage`)
25-
26-
**No file system dependencies** - uses storage adapters for platform-specific I/O.
27-
28-
### Usage
19+
```
20+
┌─────────────────┐
21+
│ Desktop App │
22+
│ @leanspec/desktop│ ──► Rust backend (leanspec-core)
23+
└─────────────────┘
2924
30-
```typescript
31-
import {
32-
parseFrontmatterFromString,
33-
FrontmatterValidator,
34-
type SpecStorage
35-
} from '@leanspec/core';
25+
┌─────────────────┐
26+
│ UI App │
27+
│ @leanspec/ui │ ──► Next.js (inlined utilities)
28+
└─────────────────┘
3629
37-
// Parse frontmatter from markdown content
38-
const content = await storage.readFile('spec.md');
39-
const frontmatter = parseFrontmatterFromString(content);
30+
┌─────────────────┐
31+
│ CLI │
32+
│ lean-spec │ ──► Rust binary (leanspec-cli)
33+
└─────────────────┘
4034
41-
// Validate spec
42-
const validator = new FrontmatterValidator();
43-
const result = await validator.validate(spec);
35+
┌─────────────────┐
36+
│ MCP Server │
37+
│ @leanspec/mcp │ ──► Rust binary (leanspec-mcp)
38+
└─────────────────┘
4439
```
4540

41+
**Key changes:**
42+
- `@leanspec/core` TypeScript package has been deprecated and deleted
43+
- CLI is now a thin wrapper that invokes the Rust binary
44+
- MCP server runs the Rust MCP binary
45+
- UI inlines minimal utilities (frontmatter, atomic file ops)
46+
- Desktop uses Tauri with Rust backend
47+
4648
## lean-spec (CLI)
4749

48-
**Command-line interface and MCP server.**
50+
**JavaScript wrapper for Rust CLI binary.**
51+
52+
The CLI package provides:
53+
- Platform detection and binary resolution
54+
- Fallback to locally built Rust binaries for development
55+
- Templates for `lean-spec init`
56+
57+
### Usage
58+
59+
```bash
60+
# Install globally
61+
npm install -g lean-spec
4962

50-
Implements:
51-
- All CLI commands (`list`, `create`, `update`, `validate`, etc.)
52-
- MCP server for AI agent integration
53-
- FileSystemStorage adapter (Node.js fs operations)
54-
- Terminal output formatting
63+
# Or run via npx
64+
npx lean-spec list
65+
npx lean-spec create my-feature
66+
```
5567

5668
### Development
5769

5870
```bash
59-
cd packages/cli
60-
pnpm install
61-
pnpm build
62-
pnpm test
71+
# Build Rust binaries first
72+
cd rust && cargo build --release
73+
74+
# Copy binaries to packages
75+
node scripts/copy-rust-binaries.mjs
76+
77+
# Test CLI
78+
node bin/lean-spec.js --version
6379
```
6480

6581
## @leanspec/mcp
6682

6783
**MCP server integration wrapper.**
6884

69-
Simple passthrough wrapper that delegates to `lean-spec mcp`. Makes MCP setup more discoverable with a dedicated package name.
85+
Simple passthrough wrapper that delegates to the Rust MCP binary. Makes MCP setup more discoverable with a dedicated package name.
7086

7187
### Usage
7288

@@ -75,36 +91,39 @@ Simple passthrough wrapper that delegates to `lean-spec mcp`. Makes MCP setup mo
7591
npx -y @leanspec/mcp
7692
```
7793

78-
The package automatically installs `lean-spec` as a dependency and runs `lean-spec mcp`. See [MCP Integration docs](https://lean-spec.dev/docs/guide/usage/ai-assisted/mcp-integration) for setup instructions.
79-
80-
## Storage Adapters
81-
82-
The core package uses abstract storage interfaces to enable platform independence:
83-
84-
### FileSystemStorage (CLI)
85-
86-
```typescript
87-
// packages/cli/src/adapters/fs-storage.ts
88-
import { FileSystemStorage } from './adapters/fs-storage.js';
89-
90-
const storage = new FileSystemStorage();
91-
const content = await storage.readFile('/path/to/spec/README.md');
92-
```
94+
See [MCP Integration docs](https://lean-spec.dev/docs/guide/usage/ai-assisted/mcp-integration) for setup instructions.
9395

9496
## @leanspec/ui
9597

9698
**Published UI bundle and launcher.**
9799

98100
Contains the Next.js application and exposes a CLI (`npx @leanspec/ui`). Used automatically by `lean-spec ui` outside the monorepo.
99101

102+
The UI package inlines minimal utilities (formerly from `@leanspec/core`):
103+
- `createUpdatedFrontmatter` - Update spec metadata
104+
- `atomicWriteFile` - Safe file writing
105+
100106
### Development
101107

102108
```bash
103109
pnpm --filter @leanspec/ui build # build Next.js app and prepare artifacts
104110
node packages/ui/bin/ui.js --dry-run
105111
```
106112

107-
The build script produces `.next/standalone` and prepares assets for publishing via the GitHub Actions workflow.
113+
## @leanspec/desktop
114+
115+
**Tauri desktop application.**
116+
117+
Cross-platform desktop app using:
118+
- Rust backend (Tauri commands for spec operations)
119+
- React/Vite frontend
120+
- Shared UI components with web app
121+
122+
### Development
123+
124+
```bash
125+
pnpm --filter @leanspec/desktop dev:desktop
126+
```
108127

109128
## Building
110129

@@ -115,8 +134,8 @@ pnpm build
115134

116135
Build specific package:
117136
```bash
118-
pnpm --filter @leanspec/core build
119-
pnpm --filter lean-spec build
137+
pnpm --filter @leanspec/ui build
138+
pnpm --filter @leanspec/desktop build
120139
```
121140

122141
## Testing
@@ -128,49 +147,27 @@ pnpm test
128147

129148
Run tests for specific package:
130149
```bash
131-
pnpm --filter @leanspec/core test
132-
pnpm --filter lean-spec test
150+
pnpm --filter @leanspec/ui test
133151
```
134152

135153
## Publishing
136154

137-
The CLI package (`lean-spec`), the MCP wrapper (`@leanspec/mcp`), and the UI bundle (`@leanspec/ui`) are published to npm. The core package (`@leanspec/core`) is currently workspace-only but can be published if needed for external use.
155+
Published packages:
156+
- `lean-spec` - CLI (wrapper + Rust binary via optional dependencies)
157+
- `@leanspec/mcp` - MCP server wrapper
158+
- `@leanspec/ui` - Web UI bundle
138159

139-
## Architecture
140-
141-
```
142-
┌─────────────────┐
143-
│ UI App │
144-
│ @leanspec/ui │
145-
└────────┬────────┘
146-
147-
│ uses Core
148-
149-
150-
┌─────────────────┐
151-
│ @leanspec/core │ ◄── Platform-agnostic
152-
│ │
153-
│ • Types │
154-
│ • Parsers │
155-
│ • Validators │
156-
│ • Utilities │
157-
└────────┬────────┘
158-
159-
│ uses FileSystemStorage
160-
161-
162-
┌─────────────────┐
163-
│ CLI & MCP │
164-
│ lean-spec │
165-
└─────────────────┘
166-
```
160+
Platform-specific binary packages (published separately):
161+
- `lean-spec-darwin-arm64`
162+
- `lean-spec-darwin-x64`
163+
- `lean-spec-linux-arm64`
164+
- `lean-spec-linux-x64`
165+
- `lean-spec-windows-x64`
167166

168167
## Migration Notes
169168

170-
The monorepo was created in spec 067 by:
171-
1. Creating `packages/core/` with extracted shared logic
172-
2. Moving existing code to `packages/cli/`
173-
3. Implementing `FileSystemStorage` adapter in CLI
174-
4. Core package exports validators, parsers, and utilities
175-
176-
**Zero breaking changes** for end users - the `lean-spec` CLI works identically to before.
169+
**Spec 181 (TypeScript Deprecation)**:
170+
- Deleted `@leanspec/core` TypeScript package
171+
- CLI now invokes Rust binary directly
172+
- UI inlines 2 utility functions (~50 lines)
173+
- Single source of truth in Rust

0 commit comments

Comments
 (0)