소스 검색

changes before 2026-06-02

Brandon Wong 3 주 전
부모
커밋
bf206df037
2개의 변경된 파일96개의 추가작업 그리고 0개의 파일을 삭제
  1. 83 0
      codemcp.toml
  2. 13 0
      frontend/src/cljs/microtables_frontend/views/sheet.cljs

+ 83 - 0
codemcp.toml

@@ -0,0 +1,83 @@
+# Claude Desktop project's instructions (in "project knowledge"):
+# "Initialize the codemcp tool with /Users/yellowdig/personal/projects/microtables/."
+# (use absolute path for <home> because otherwise the LLM will hallucinate a home path)
+
+project_prompt = '''
+# Microtables
+
+## Project Overview
+A lightweight spreadsheet application designed for quick calculations — positioned between a calculator and a full office suite. The goal is fast loading with support for common spreadsheet operations.
+
+## Architecture
+
+**Frontend** (`/frontend/`)
+- **Language**: ClojureScript (compiled via shadow-cljs)
+- **Framework**: Reagent + re-frame (React wrapper)
+- **Build**: Leiningen + shadow-cljs
+- **Dev server**: `lein dev` → localhost:8280
+
+**Server** (`/server/`)
+- **Language**: JavaScript (ES6+ with Babel)
+- **Framework**: Express
+- **Status**: Minimal implementation - currently the frontend is fully functional standalone
+- **Future**: Will handle persistence and collaboration
+
+## Key Concepts
+
+### Data Structure
+The spreadsheet data is a nested map: `{column-letter {row-number {:value ...}}}`
+
+Example:
+```clojure
+{"A" {1 {:value 78 :inbound [...]}
+      3 {:value "=B2 * 4" :refs [...]}}
+ "B" {2 {:value "=A1 + 3" :refs [...] :inbound [...]}}}
+```
+
+### Formula System
+- Formulae start with `=` and are evaluated using **math.js** library
+- Range syntax supported: `=sum(A1:A10)`
+- Cell references create a **doubly-linked tree structure**:
+  - `:refs` - forward references (cells this formula depends on)
+  - `:inbound` - back references (cells that depend on this cell)
+  - `:display` - computed/evaluated value shown to user
+  - `:value` - raw user input
+  - `:dirty` - flag indicating re-evaluation needed
+
+### Evaluation Flow
+1. When a cell changes, parse for references
+2. Update forward (`:refs`) and back (`:inbound`) reference trees
+3. Evaluate the cell
+4. Recursively evaluate all cells in `:inbound` queue
+5. Cycle detection prevents infinite loops
+
+## Important Files
+
+**Frontend Core Logic**
+- `frontend/src/cljs/microtables_frontend/core.cljs` - App initialization
+- `frontend/src/cljs/microtables_frontend/db.cljs` - Data model definition
+- `frontend/src/cljs/microtables_frontend/events.cljs` - State mutations (re-frame)
+- `frontend/src/cljs/microtables_frontend/subs.cljs` - Data queries (re-frame)
+- `frontend/src/cljs/microtables_frontend/evaluation.cljs` - Formula evaluation engine
+- `frontend/src/cljs/microtables_frontend/views/sheet.cljs` - Grid rendering
+
+**Project Configuration**
+- `frontend/project.clj` - Leiningen config
+- `frontend/shadow-cljs.edn` - ClojureScript build config
+
+## Development Notes
+
+- Almost everything is subject to change (architecture, structure, design)
+- The frontend currently operates completely standalone
+- Focus is on simplicity and performance for common use cases
+- Data structures prioritize clarity over micro-optimization (small dataset assumption)
+
+## Common Tasks
+
+**Run frontend**: `cd frontend && lein dev`  
+**Install npm dependency**: Add to `shadow-cljs.edn`, then restart  
+**Understand formula eval**: Start in `evaluation.cljs`, trace through `evaluate-from-cell`  
+**Modify grid UI**: Look in `views/sheet.cljs`
+'''
+
+[commands]

+ 13 - 0
frontend/src/cljs/microtables_frontend/views/sheet.cljs

@@ -4,6 +4,19 @@
    [microtables-frontend.utils.coordinates :as coords]
    [re-frame.core :as re-frame]))
 
+;TODO: expand selection/highlight mode
+;      - directional controls
+;        - arrow keys, enter, tab, shift-enter, shift-tab
+;        - enter key triggers editing (?)
+;      - special controls
+;        - expand selection
+;        - move selection
+;        - delete selection (neighbouring cells displaced in)
+;        - clear selection (cells become blank)
+;        - continue selection (intelligent sequence continuation)
+;      - common functions (sum, avg, etc)
+;        - display numeric answer in menu
+;        - offer to put the answer (in formula form) in a cell (to be chosen by clicking)
 (defn cell [c r data]
   (let [datum (get-in data [c r])]
     ^{:key (str c r)} [:td