Skip to content

Commit ac35100

Browse files
committed
Update license to AGPL and prepare latest changes for launch
1 parent 6f40c45 commit ac35100

File tree

31 files changed

+1683
-236
lines changed

31 files changed

+1683
-236
lines changed

CLA.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Smart Code Diff — Contributor License Agreement (CLA)
2+
3+
Summary (Not a Substitute for the Terms)
4+
- You grant the project maintainers broad rights to use, modify, distribute, sublicense, and relicense your contributions, including under proprietary/commercial terms.
5+
- You confirm you have the necessary rights to contribute and that your contribution is your original work (or you have permission to submit it).
6+
- You grant a patent license for patents necessarily infringed by your contribution.
7+
8+
1. Definitions
9+
- “Contribution”: any code, documentation, or other material you submit to the project.
10+
- “You”: the individual or legal entity submitting the Contribution.
11+
- “Project”: Smart Code Diff and its maintainers.
12+
13+
2. Copyright License to the Project
14+
- You grant the Project a perpetual, worldwide, irrevocable, non-exclusive, transferable, sublicensable license to use, reproduce, prepare derivative works of, publicly display/perform, and distribute the Contribution and derivative works.
15+
- The Project may relicense the Contribution, in whole or in part, under any terms the Project chooses, including proprietary/commercial licenses.
16+
17+
3. Patent License
18+
- You grant the Project a perpetual, worldwide, irrevocable, non-exclusive, transferable, sublicensable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Contribution, where such license is only to the extent of patents necessarily infringed by the Contribution alone or in combination with the Project.
19+
20+
4. Representations
21+
- You represent that each Contribution is your original work or that you have sufficient rights to grant the above licenses.
22+
- You represent that the Contribution is provided without encumbrances that would prevent its licensing as described herein.
23+
24+
5. No Warranty; Disclaimer
25+
- Contributions are provided “as is”, without warranties or conditions of any kind.
26+
27+
6. Acceptance
28+
- You will be asked to agree to this CLA via CLA Assistant on GitHub. Do not submit Contributions unless you agree to these terms.
29+
30+
7. Entity Contributors
31+
- If you contribute on behalf of your employer or another entity, you represent you have authority to bind that entity. The entity is the “You” for purposes of this CLA.
32+
33+
8. Miscellaneous
34+
- This is the entire agreement regarding the Contribution, superseding prior communications on this topic.
35+
- If any provision is unenforceable, the remainder remains in effect.
36+
37+
For questions, contact: matt@opensensor.io
38+

COMMERCIAL_LICENSE.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Smart Code Diff — Commercial License Summary
2+
3+
This document summarizes the intent of the commercial license offered for Smart Code Diff. It is not the legal agreement. Final terms will be provided upon request and execution by both parties.
4+
5+
Scope
6+
- Permits proprietary use, integration, and distribution of Smart Code Diff without AGPL obligations.
7+
- Suitable for SaaS and embedded use where source disclosure is undesirable.
8+
9+
Grant
10+
- Non-exclusive, worldwide license to use, modify, and distribute the software in proprietary products and services.
11+
- Redistribution of modified or unmodified versions permitted under proprietary terms.
12+
- Includes the right to keep source code private (no copyleft obligations).
13+
14+
Restrictions
15+
- No removal of copyright notices or license attributions.
16+
- No use of trademarks, logos, or names of the Smart Code Diff Team without permission.
17+
- No license to patents other than those necessarily infringed by the unmodified software; patent terms provided in the executed agreement.
18+
19+
Support & Updates
20+
- Optional support, updates, and security maintenance tiers are available.
21+
22+
Pricing
23+
- Commercial licenses are available on a per-company basis. Typical range: $500–$5000/year depending on use, seats, and support.
24+
25+
Contact
26+
- Email: matt@opensensor.io to receive the full commercial license terms and a quote.
27+
28+
Relation to AGPL
29+
- This commercial license is an alternative to AGPL-3.0-only. If you obtain a commercial license, its terms supersede AGPL obligations for your covered use.
30+
31+
Disclaimer
32+
- Provided “as is” without warranties unless otherwise specified in the executed agreement.
33+

CONTRIBUTING.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Contributing to Smart Code Diff
2+
3+
Thank you for your interest in contributing!
4+
5+
Code of Conduct
6+
- Be respectful and constructive. Treat others as you wish to be treated.
7+
8+
How to Contribute
9+
1) Fork the repo and create a feature branch.
10+
2) Write clear, tested code. Run `cargo fmt`, `cargo clippy`, and project tests.
11+
3) Submit a Pull Request with a clear description and rationale.
12+
13+
Contributor License Agreement (CLA)
14+
- We use a CLA to preserve dual-licensing rights. All contributors must agree to the CLA before contributions can be merged.
15+
- We recommend enabling GitHub CLA Assistant for this repository. When you open a PR, you’ll be prompted to sign.
16+
- The CLA text is in CLA.md. By contributing, you agree to those terms.
17+
18+
Licensing Model
19+
- Core project: AGPL-3.0-only
20+
- Companies needing closed-source usage may obtain a commercial license; see COMMERCIAL_LICENSE.md.
21+
22+
Developer Setup
23+
- Rust 1.75+, Node.js 18+
24+
- Build: `cargo build`
25+
- Test: `cargo test`
26+
- Frontend: `cd nextjs-frontend && npm install && npm run dev`
27+
28+
Questions?
29+
- Open a GitHub Discussion or Issue, or email: matt@opensensor.io
30+

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ resolver = "2"
1313
version = "0.1.0"
1414
edition = "2021"
1515
authors = ["Smart Code Diff Team"]
16-
license = "MIT"
17-
repository = "https://github.com/your-org/smart-code-diff"
16+
license = "AGPL-3.0-only"
17+
repository = "https://github.com/opensensor/smartdiff"
1818
description = "A next-generation code diffing tool that performs structural and semantic comparison"
1919

2020
[workspace.dependencies]

FRONTEND_IMPROVEMENTS.md

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
# Frontend Diff Comparison Improvements
2+
3+
## Summary
4+
5+
Fixed the Next.js frontend to properly leverage the Rust backend's advanced AST-based function matching algorithm, and created a new function-centric view that sorts functions by change magnitude instead of grouping by file.
6+
7+
## Problems Identified
8+
9+
1. **Not leveraging the Rust backend properly**: The frontend was calling `/api/comparison/analyze` which used a simplified regex-based function extraction instead of the advanced AST parser
10+
2. **MCP layer was unnecessary**: The MCP endpoints were just wrappers that added complexity without benefit for the web UI
11+
3. **File-centric organization**: Functions were grouped by file, making it hard to see the most changed functions across the entire codebase
12+
4. **Confusing change detection**: Functions that were moved AND modified appeared in multiple categories
13+
14+
## Solutions Implemented
15+
16+
### 1. Enhanced Rust Backend (`crates/web-ui/src/handlers.rs`)
17+
18+
**Changed**: `analyze_function_changes()` function
19+
20+
**Before**: Used regex patterns to extract functions
21+
```rust
22+
// Simple function extraction using regex patterns
23+
let functions = extract_functions_simple(&file.content, language_str, &file.relative_path);
24+
```
25+
26+
**After**: Uses proper AST parsing with Hungarian algorithm matching
27+
```rust
28+
// Parse files using TreeSitter AST parser
29+
let parser = TreeSitterParser::new(language);
30+
let parse_result = parser.parse(&file.content, Some(&file.path));
31+
source_functions_ast.extend(parse_result.functions);
32+
33+
// Use advanced FunctionMatcher with Hungarian algorithm
34+
let function_matcher = FunctionMatcher::new(similarity_threshold);
35+
let match_result = function_matcher.match_functions(&source_functions_ast, &target_functions_ast);
36+
```
37+
38+
**Benefits**:
39+
- Accurate function extraction across all languages
40+
- Optimal matching using Hungarian algorithm
41+
- Proper similarity scoring based on AST structure
42+
- Correct change type detection (moved, renamed, modified)
43+
44+
### 2. Improved Change Type Detection (`crates/diff-engine/src/changes.rs`)
45+
46+
**Updated**: `determine_primary_change_type()` function
47+
48+
**Key improvement**: Clear priority order for change types:
49+
1. Cross-file move (whether modified or not - similarity score indicates modification level)
50+
2. Rename (only if high similarity)
51+
3. Move within file (only if high similarity)
52+
4. Modification (default)
53+
54+
**Result**: A function that is moved AND modified is correctly categorized as "moved" with a low similarity score, rather than appearing in both "moved" and "modified" categories.
55+
56+
### 3. Better Change Summaries (`crates/mcp-server/src/comparison/manager.rs`)
57+
58+
**Enhanced**: Diff summaries now clearly indicate combined changes:
59+
- "Function moved from X to Y and modified (75% similar)"
60+
- "Function renamed from 'foo' to 'bar' and modified (80% similar)"
61+
- "Function moved from X to Y (unchanged)"
62+
63+
### 4. New Function-Centric View Component
64+
65+
**Created**: `nextjs-frontend/src/components/diff/FunctionCentricDiffView.tsx`
66+
67+
**Features**:
68+
- **Sorted by change magnitude**: Most changed functions appear first (regardless of file)
69+
- **File path as indicator**: Shows source/target file paths as small labels per function
70+
- **Visual change metrics**: Color-coded change magnitude and similarity percentages
71+
- **Flexible filtering**: Filter by change type (modified, added, deleted, moved, renamed)
72+
- **Multiple sort options**: By magnitude, similarity, or name
73+
- **Search**: Find functions by name or file path
74+
75+
**UI Layout**:
76+
```
77+
┌─────────────────────────────────────────────────────┐
78+
│ [Search] [Filter: Modified ▼] [Sort: Magnitude ▼] │
79+
├─────────────────────────────────────────────────────┤
80+
│ ┌─────────────────────────────────────────────────┐ │
81+
│ │ functionName() [modified] │ │
82+
│ │ 📄 src/old.rs → src/new.rs │ │
83+
│ │ Source: L10-50 Target: L15-55 │ │
84+
│ │ 85% changed │ │
85+
│ │ 15% similar │ │
86+
│ └─────────────────────────────────────────────────┘ │
87+
│ ┌─────────────────────────────────────────────────┐ │
88+
│ │ anotherFunction() [moved] │ │
89+
│ │ 📄 src/utils.rs → src/helpers.rs │ │
90+
│ │ Source: L100-120 Target: L200-220 │ │
91+
│ │ 5% changed │ │
92+
│ │ 95% similar │ │
93+
│ └─────────────────────────────────────────────────┘ │
94+
└─────────────────────────────────────────────────────┘
95+
```
96+
97+
### 5. Enhanced Comparison Component
98+
99+
**Created**: `nextjs-frontend/src/components/diff/EnhancedDiffComparison.tsx`
100+
101+
**Features**:
102+
- Toggle between function-centric and file-centric views
103+
- Summary statistics (total, added, deleted, modified, renamed, moved)
104+
- Direct integration with Rust backend (no MCP middleman)
105+
- Better error handling and loading states
106+
107+
**New page**: `/enhanced-diff` - Try it out!
108+
109+
### 6. Updated ComparisonService
110+
111+
**Removed**: MCP-specific methods (`analyzeDirectoriesWithMCP`, `getChangedFunctionsFromMCP`)
112+
113+
**Enhanced**: `analyzeDirectories()` now:
114+
- Calls Rust backend's improved `/api/comparison/analyze` endpoint
115+
- Calculates `changeMagnitude` for each function (0.0 = no change, 1.0 = complete change)
116+
- Properly transforms AST-based results to frontend format
117+
118+
## Architecture Clarification
119+
120+
### Why NOT use MCP endpoints?
121+
122+
**MCP (Model Context Protocol)** is designed for AI agents to interact with code, not for web UIs:
123+
- MCP returns text-based responses that need parsing
124+
- Adds unnecessary complexity (Next.js API → MCP Server → Rust Backend)
125+
- Web UI can call Rust backend directly with structured JSON
126+
127+
**Better architecture**:
128+
```
129+
Next.js Frontend → Rust Backend (with AST matching)
130+
131+
Advanced diff-engine
132+
- TreeSitter AST parsing
133+
- Hungarian algorithm matching
134+
- Tree edit distance
135+
- Similarity scoring
136+
```
137+
138+
**MCP is still useful for**:
139+
- AI agents analyzing code changes
140+
- Claude/GPT integrations
141+
- Command-line tools
142+
- Automated code review workflows
143+
144+
## Files Changed
145+
146+
### Rust Backend
147+
- `crates/web-ui/src/handlers.rs` - Use AST-based function matching
148+
- `crates/diff-engine/src/changes.rs` - Improved change type detection
149+
- `crates/mcp-server/src/comparison/manager.rs` - Better diff summaries
150+
151+
### Next.js Frontend
152+
- `nextjs-frontend/src/services/comparisonService.ts` - Removed MCP methods, enhanced analyzeDirectories
153+
- `nextjs-frontend/src/components/diff/FunctionCentricDiffView.tsx` - NEW: Function-centric view
154+
- `nextjs-frontend/src/components/diff/EnhancedDiffComparison.tsx` - NEW: Enhanced comparison UI
155+
- `nextjs-frontend/src/app/enhanced-diff/page.tsx` - NEW: Page for enhanced diff
156+
157+
### Files to Remove (Optional)
158+
- `nextjs-frontend/src/app/api/mcp/compare-locations/route.ts` - Not needed for web UI
159+
- `nextjs-frontend/src/app/api/mcp/list-changed-functions/route.ts` - Not needed for web UI
160+
161+
## Testing
162+
163+
1. **Start the Rust backend**:
164+
```bash
165+
cd crates/web-ui
166+
cargo run --release
167+
```
168+
169+
2. **Start the Next.js frontend**:
170+
```bash
171+
cd nextjs-frontend
172+
npm run dev
173+
```
174+
175+
3. **Navigate to**: http://localhost:3000/enhanced-diff
176+
177+
4. **Test with two directories**:
178+
- Select source and target directories
179+
- Click "Start Comparison"
180+
- Toggle between function-centric and file-centric views
181+
- Try filtering by change type
182+
- Sort by different criteria
183+
184+
## Key Improvements
185+
186+
**Accurate function detection** - AST parsing instead of regex
187+
**Optimal matching** - Hungarian algorithm finds best matches
188+
**Clear categorization** - Functions appear in one category with detailed info
189+
**Change magnitude sorting** - See most changed functions first
190+
**File-agnostic view** - Functions sorted by impact, not file organization
191+
**Simpler architecture** - Direct Rust backend calls, no MCP middleman
192+
**Better UX** - Visual indicators, search, filtering, multiple views
193+
194+
## Next Steps (Optional)
195+
196+
1. **Add detailed diff view**: Click a function to see line-by-line AST diff
197+
2. **Persist comparisons**: Save comparison results for later review
198+
3. **Export reports**: Generate markdown/HTML reports of changes
199+
4. **Batch comparisons**: Compare multiple directory pairs
200+
5. **Integration tests**: Add tests for the new matching algorithm
201+

LICENSE

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
MIT License
1+
Smart Code Diff — Dual License Notice
22

3-
Copyright (c) 2025 Smart Code Diff Team
3+
Copyright (c) 2025 OpenSensor Engineering, LLC
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
116

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
7+
Open Source License (AGPL-3.0-only):
8+
- This project is available under the GNU Affero General Public License v3.0.
9+
- Full text: https://www.gnu.org/licenses/agpl-3.0.en.html
10+
- If you use the software to provide a network service, your complete source code must be made available under the AGPL.
1411

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
12+
Commercial License:
13+
- A commercial, non-AGPL license is available for companies that wish to integrate or use this software without AGPL obligations.
14+
- Contact: matt@opensensor.io for pricing and terms.
15+
16+
Contributions and Relicensing:
17+
- By contributing, you agree to the Contributor License Agreement (CLA) in CLA.md, which allows the maintainers to relicense your contributions for commercial use.
18+
19+
This file summarizes licensing. In case of conflict, the full AGPL text (linked above) or your executed commercial agreement controls.

PRD.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ interface Change {
380380
- **Code Editor**: Monaco Editor for syntax highlighting
381381

382382
#### Infrastructure
383-
- **Container**: Docker with Kubernetes orchestration
384383
- **CI/CD**: GitHub Actions or GitLab CI
385384
- **Monitoring**: Prometheus + Grafana
386385
- **Cloud**: AWS or GCP with auto-scaling

QUICK_START.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,18 +278,6 @@ Create `nextjs-frontend/.env.local`:
278278
NEXT_PUBLIC_API_URL=http://localhost:8080
279279
```
280280

281-
## Docker Alternative
282-
283-
If you prefer Docker:
284-
285-
```bash
286-
# Build and run with Docker Compose
287-
docker-compose up
288-
289-
# Or build manually
290-
docker build -t smart-diff .
291-
docker run -p 8080:8080 smart-diff
292-
```
293281

294282
## Next Steps
295283

0 commit comments

Comments
 (0)