markdown · 8047 bytes Raw Blame History

Workspace Mode - Quick Start Guide

Ready to start implementing? Follow this guide.


Before You Begin

Read These Documents (in order)

  1. WORKSPACE_VISION.md - Understand the vision and key decisions
  2. WORKSPACE_ROADMAP.md - Full implementation plan
  3. WORKSPACE_TASKS.md - Task tracker (update as you go)

Prerequisites

  • All existing fac features working
  • Clean build: make clean && make
  • All tests passing
  • Git working tree clean (commit current work)

Phase 0: Planning & Design (START HERE)

Goal: Create specification documents before writing code

Step 1: Create Directory Structure

mkdir -p docs
# (already done if you're reading this)

Step 2: Create workspace_spec.md

Document the workspace.json format in detail:

  • JSON schema
  • Field descriptions
  • Example workspaces
  • Validation rules

Template:

# Workspace Configuration Specification

## Overview
workspace.json stores the complete editor state for a workspace.

## Schema
...

## Example
...

## Validation
...

Step 3: Create fortress_integration.md

Document how Fortress modules integrate:

  • Which modules to copy from ../fortress
  • How to adapt them for fac
  • Module dependencies
  • API contracts

Template:

# Fortress Integration Plan

## Modules to Copy
1. filesystem/directory_module.f90
   - Functions: ...
   - Changes needed: ...

## Integration Points
...

Step 4: Create config_spec.md

Document config file formats:

  • favorites.json format
  • recents.json format
  • backup metadata format
  • File locations (XDG paths)

Template:

# Configuration Files Specification

## favorites.json
Location: ~/.config/fac/favorites.json
Format:
...

## recents.json
...

Step 5: Review & Finalize

  • Review all specs
  • Check for gaps
  • Verify against WORKSPACE_VISION.md
  • Get approval before coding

Phase 0 Complete When:

  • ✅ All spec documents created
  • ✅ Specs are detailed and clear
  • ✅ No open questions remain
  • ✅ Ready to write code

Phase 1: Fortress Navigator

Goal: Build basic dual-pane file/directory navigator

Step 1: Copy Fortress Code

# From fortress repo
cd ../fortress
ls -la app/
# Identify modules to copy

cd ../facsimile
mkdir -p src/fortress/{filesystem,terminal,ui}

# Copy files (example)
cp ../fortress/app/filesystem/*.f90 src/fortress/filesystem/
cp ../fortress/app/terminal/*.f90 src/fortress/terminal/
cp ../fortress/app/ui/*.f90 src/fortress/ui/

Step 2: Adapt for fac

  • Remove main program
  • Change module names if conflicts
  • Adapt to fac's terminal API
  • Remove fortress-specific features (git, fzf for now)

Step 3: Create Navigator Module

! src/fortress/ui/navigator_module.f90
module navigator_module
    implicit none
contains
    subroutine open_fortress_navigator(selected_path, selection_type)
        ! Returns selected path and whether it's a file or directory
    end subroutine
end module

Step 4: Add to Build

# Makefile
SOURCES = ... \
          src/fortress/filesystem/directory_module.f90 \
          src/fortress/terminal/fortress_render_module.f90 \
          src/fortress/ui/navigator_module.f90 \
          ...

Step 5: Add Ctrl-O Keybinding

! src/commands/command_handler_module.f90
else if (key_input == 'CTRL_O') then
    call handle_fortress_navigator(editor, buffer)
end if

Step 6: Test

make clean && make
./fac test.txt
# Press Ctrl-O
# Should see dual-pane navigator
# Navigate, select, verify return

Phase 1 Complete When:

  • ✅ Ctrl-O opens Fortress navigator
  • ✅ Can navigate filesystem
  • ✅ Selecting directory returns path
  • ✅ Selecting file returns path
  • ✅ ESC cancels
  • ✅ No regressions in existing features

Phase 2: Workspace Detection

Goal: Detect/create workspace directories and configs

Step 1: Create Workspace Module

! src/workspace/workspace_module.f90
module workspace_module
    implicit none

    type :: workspace_t
        character(len=:), allocatable :: path
        logical :: is_workspace_mode
    end type

contains
    subroutine workspace_init(workspace, path)
        ! Detect or create workspace
    end subroutine

    function workspace_exists(path) result(exists)
        ! Check for .fac/workspace.json
    end function
end module

Step 2: Update main.f90

! app/main.f90
type(workspace_t) :: workspace

if (argc == 0) then
    ! Open Fortress welcome (Phase 5)
else if (is_directory(arg)) then
    call workspace_init(workspace, arg)
else
    ! Single file mode
end if

Step 3: Create .fac/ Structure

subroutine create_workspace_structure(path)
    ! Create .fac/ directory
    ! Create .fac/workspace.json
    ! Create .fac/backups/
end subroutine

Step 4: Test

cd /tmp/test-workspace
../facsimile/fac .
# Should create .fac/workspace.json
ls -la .fac/

Phase 2 Complete When:

  • fac . creates workspace
  • .fac/workspace.json created
  • fac file.txt still works (single-file mode)
  • ✅ Command line parsing correct

Development Guidelines

Commit Often

Commit after each major task:

git add .
git commit -m "Implement fortress navigator dual-pane display"

Test After Each Change

make clean && make
./fac test.txt
# Test new feature
# Test existing features (regression check)

Update Task Tracker

Mark tasks complete in WORKSPACE_TASKS.md as you go.

Debug Logging

Add debug logging for complex logic:

! DEBUG: Remove before final release
open(unit=99, file='/tmp/fac_workspace_debug.txt', position='append')
write(99, '(A,A)') 'Loading workspace: ', trim(path)
close(99)

Handle Errors Gracefully

if (error) then
    ! Show error to user
    ! Fallback to safe state
    ! Don't crash
end if

Keep Backwards Compatibility

Always test single-file mode:

./fac README.md
# Should work exactly as before

When Things Go Wrong

Build Fails

make clean
# Check for syntax errors
# Check module dependencies (order matters)
# Verify all files in SOURCES
make

Feature Not Working

  1. Add debug logging
  2. Check file permissions
  3. Verify paths are correct
  4. Test with simple case first
  5. Compare with spec documents

Cursor Bugs Appear

  1. Check if new code modified cursor state
  2. Verify sync_editor_to_pane calls
  3. Test with single pane/tab first
  4. Add debug output for cursor positions

State Not Persisting

  1. Verify workspace.json being written
  2. Check file permissions
  3. Verify JSON format is valid
  4. Test load/save separately

Communication

Document Decisions

If you make a design decision not in the specs:

  1. Add it to WORKSPACE_VISION.md
  2. Note why in commit message
  3. Update WORKSPACE_ROADMAP.md if it affects plan

Ask Questions

If unclear about a requirement:

  1. Check WORKSPACE_VISION.md first
  2. Check WORKSPACE_ROADMAP.md
  3. Ask before proceeding

Completion Checklist

Each Phase

  • All tasks completed
  • Tests passing
  • No regressions
  • Code committed
  • Documentation updated
  • WORKSPACE_TASKS.md updated

Final Release (Phase 7)

  • All phases complete
  • Performance acceptable
  • User testing done
  • Documentation complete
  • README.md updated
  • --help updated
  • No debug logging
  • Clean git history
  • Version bumped
  • Tagged release

Useful Commands

# Clean build
make clean && make

# Test single file mode
./fac README.md

# Test workspace mode
cd /tmp/test && ../facsimile/fac .

# Check for .fac directory
ls -la .fac/

# View workspace config
cat .fac/workspace.json | python -m json.tool

# Debug
tail -f /tmp/fac_workspace_debug.txt

# Remove workspace (clean slate)
rm -rf .fac/

Ready?

  1. ✅ Read all documentation
  2. ✅ Understand the vision
  3. ✅ Environment ready
  4. ✅ Start Phase 0!

Let's build this thing! 🚀

View source
1 # Workspace Mode - Quick Start Guide
2
3 Ready to start implementing? Follow this guide.
4
5 ---
6
7 ## Before You Begin
8
9 ### Read These Documents (in order)
10 1. **WORKSPACE_VISION.md** - Understand the vision and key decisions
11 2. **WORKSPACE_ROADMAP.md** - Full implementation plan
12 3. **WORKSPACE_TASKS.md** - Task tracker (update as you go)
13
14 ### Prerequisites
15 - All existing fac features working
16 - Clean build: `make clean && make`
17 - All tests passing
18 - Git working tree clean (commit current work)
19
20 ---
21
22 ## Phase 0: Planning & Design (START HERE)
23
24 **Goal**: Create specification documents before writing code
25
26 ### Step 1: Create Directory Structure
27 ```bash
28 mkdir -p docs
29 # (already done if you're reading this)
30 ```
31
32 ### Step 2: Create workspace_spec.md
33 Document the workspace.json format in detail:
34 - JSON schema
35 - Field descriptions
36 - Example workspaces
37 - Validation rules
38
39 **Template**:
40 ```markdown
41 # Workspace Configuration Specification
42
43 ## Overview
44 workspace.json stores the complete editor state for a workspace.
45
46 ## Schema
47 ...
48
49 ## Example
50 ...
51
52 ## Validation
53 ...
54 ```
55
56 ### Step 3: Create fortress_integration.md
57 Document how Fortress modules integrate:
58 - Which modules to copy from ../fortress
59 - How to adapt them for fac
60 - Module dependencies
61 - API contracts
62
63 **Template**:
64 ```markdown
65 # Fortress Integration Plan
66
67 ## Modules to Copy
68 1. filesystem/directory_module.f90
69 - Functions: ...
70 - Changes needed: ...
71
72 ## Integration Points
73 ...
74 ```
75
76 ### Step 4: Create config_spec.md
77 Document config file formats:
78 - favorites.json format
79 - recents.json format
80 - backup metadata format
81 - File locations (XDG paths)
82
83 **Template**:
84 ```markdown
85 # Configuration Files Specification
86
87 ## favorites.json
88 Location: ~/.config/fac/favorites.json
89 Format:
90 ...
91
92 ## recents.json
93 ...
94 ```
95
96 ### Step 5: Review & Finalize
97 - Review all specs
98 - Check for gaps
99 - Verify against WORKSPACE_VISION.md
100 - Get approval before coding
101
102 **Phase 0 Complete When**:
103 - ✅ All spec documents created
104 - ✅ Specs are detailed and clear
105 - ✅ No open questions remain
106 - ✅ Ready to write code
107
108 ---
109
110 ## Phase 1: Fortress Navigator
111
112 **Goal**: Build basic dual-pane file/directory navigator
113
114 ### Step 1: Copy Fortress Code
115 ```bash
116 # From fortress repo
117 cd ../fortress
118 ls -la app/
119 # Identify modules to copy
120
121 cd ../facsimile
122 mkdir -p src/fortress/{filesystem,terminal,ui}
123
124 # Copy files (example)
125 cp ../fortress/app/filesystem/*.f90 src/fortress/filesystem/
126 cp ../fortress/app/terminal/*.f90 src/fortress/terminal/
127 cp ../fortress/app/ui/*.f90 src/fortress/ui/
128 ```
129
130 ### Step 2: Adapt for fac
131 - Remove main program
132 - Change module names if conflicts
133 - Adapt to fac's terminal API
134 - Remove fortress-specific features (git, fzf for now)
135
136 ### Step 3: Create Navigator Module
137 ```fortran
138 ! src/fortress/ui/navigator_module.f90
139 module navigator_module
140 implicit none
141 contains
142 subroutine open_fortress_navigator(selected_path, selection_type)
143 ! Returns selected path and whether it's a file or directory
144 end subroutine
145 end module
146 ```
147
148 ### Step 4: Add to Build
149 ```makefile
150 # Makefile
151 SOURCES = ... \
152 src/fortress/filesystem/directory_module.f90 \
153 src/fortress/terminal/fortress_render_module.f90 \
154 src/fortress/ui/navigator_module.f90 \
155 ...
156 ```
157
158 ### Step 5: Add Ctrl-O Keybinding
159 ```fortran
160 ! src/commands/command_handler_module.f90
161 else if (key_input == 'CTRL_O') then
162 call handle_fortress_navigator(editor, buffer)
163 end if
164 ```
165
166 ### Step 6: Test
167 ```bash
168 make clean && make
169 ./fac test.txt
170 # Press Ctrl-O
171 # Should see dual-pane navigator
172 # Navigate, select, verify return
173 ```
174
175 **Phase 1 Complete When**:
176 - ✅ Ctrl-O opens Fortress navigator
177 - ✅ Can navigate filesystem
178 - ✅ Selecting directory returns path
179 - ✅ Selecting file returns path
180 - ✅ ESC cancels
181 - ✅ No regressions in existing features
182
183 ---
184
185 ## Phase 2: Workspace Detection
186
187 **Goal**: Detect/create workspace directories and configs
188
189 ### Step 1: Create Workspace Module
190 ```fortran
191 ! src/workspace/workspace_module.f90
192 module workspace_module
193 implicit none
194
195 type :: workspace_t
196 character(len=:), allocatable :: path
197 logical :: is_workspace_mode
198 end type
199
200 contains
201 subroutine workspace_init(workspace, path)
202 ! Detect or create workspace
203 end subroutine
204
205 function workspace_exists(path) result(exists)
206 ! Check for .fac/workspace.json
207 end function
208 end module
209 ```
210
211 ### Step 2: Update main.f90
212 ```fortran
213 ! app/main.f90
214 type(workspace_t) :: workspace
215
216 if (argc == 0) then
217 ! Open Fortress welcome (Phase 5)
218 else if (is_directory(arg)) then
219 call workspace_init(workspace, arg)
220 else
221 ! Single file mode
222 end if
223 ```
224
225 ### Step 3: Create .fac/ Structure
226 ```fortran
227 subroutine create_workspace_structure(path)
228 ! Create .fac/ directory
229 ! Create .fac/workspace.json
230 ! Create .fac/backups/
231 end subroutine
232 ```
233
234 ### Step 4: Test
235 ```bash
236 cd /tmp/test-workspace
237 ../facsimile/fac .
238 # Should create .fac/workspace.json
239 ls -la .fac/
240 ```
241
242 **Phase 2 Complete When**:
243 -`fac .` creates workspace
244 -`.fac/workspace.json` created
245 -`fac file.txt` still works (single-file mode)
246 - ✅ Command line parsing correct
247
248 ---
249
250 ## Development Guidelines
251
252 ### Commit Often
253 Commit after each major task:
254 ```bash
255 git add .
256 git commit -m "Implement fortress navigator dual-pane display"
257 ```
258
259 ### Test After Each Change
260 ```bash
261 make clean && make
262 ./fac test.txt
263 # Test new feature
264 # Test existing features (regression check)
265 ```
266
267 ### Update Task Tracker
268 Mark tasks complete in WORKSPACE_TASKS.md as you go.
269
270 ### Debug Logging
271 Add debug logging for complex logic:
272 ```fortran
273 ! DEBUG: Remove before final release
274 open(unit=99, file='/tmp/fac_workspace_debug.txt', position='append')
275 write(99, '(A,A)') 'Loading workspace: ', trim(path)
276 close(99)
277 ```
278
279 ### Handle Errors Gracefully
280 ```fortran
281 if (error) then
282 ! Show error to user
283 ! Fallback to safe state
284 ! Don't crash
285 end if
286 ```
287
288 ### Keep Backwards Compatibility
289 Always test single-file mode:
290 ```bash
291 ./fac README.md
292 # Should work exactly as before
293 ```
294
295 ---
296
297 ## When Things Go Wrong
298
299 ### Build Fails
300 ```bash
301 make clean
302 # Check for syntax errors
303 # Check module dependencies (order matters)
304 # Verify all files in SOURCES
305 make
306 ```
307
308 ### Feature Not Working
309 1. Add debug logging
310 2. Check file permissions
311 3. Verify paths are correct
312 4. Test with simple case first
313 5. Compare with spec documents
314
315 ### Cursor Bugs Appear
316 1. Check if new code modified cursor state
317 2. Verify sync_editor_to_pane calls
318 3. Test with single pane/tab first
319 4. Add debug output for cursor positions
320
321 ### State Not Persisting
322 1. Verify workspace.json being written
323 2. Check file permissions
324 3. Verify JSON format is valid
325 4. Test load/save separately
326
327 ---
328
329 ## Communication
330
331 ### Document Decisions
332 If you make a design decision not in the specs:
333 1. Add it to WORKSPACE_VISION.md
334 2. Note why in commit message
335 3. Update WORKSPACE_ROADMAP.md if it affects plan
336
337 ### Ask Questions
338 If unclear about a requirement:
339 1. Check WORKSPACE_VISION.md first
340 2. Check WORKSPACE_ROADMAP.md
341 3. Ask before proceeding
342
343 ---
344
345 ## Completion Checklist
346
347 ### Each Phase
348 - [ ] All tasks completed
349 - [ ] Tests passing
350 - [ ] No regressions
351 - [ ] Code committed
352 - [ ] Documentation updated
353 - [ ] WORKSPACE_TASKS.md updated
354
355 ### Final Release (Phase 7)
356 - [ ] All phases complete
357 - [ ] Performance acceptable
358 - [ ] User testing done
359 - [ ] Documentation complete
360 - [ ] README.md updated
361 - [ ] --help updated
362 - [ ] No debug logging
363 - [ ] Clean git history
364 - [ ] Version bumped
365 - [ ] Tagged release
366
367 ---
368
369 ## Useful Commands
370
371 ```bash
372 # Clean build
373 make clean && make
374
375 # Test single file mode
376 ./fac README.md
377
378 # Test workspace mode
379 cd /tmp/test && ../facsimile/fac .
380
381 # Check for .fac directory
382 ls -la .fac/
383
384 # View workspace config
385 cat .fac/workspace.json | python -m json.tool
386
387 # Debug
388 tail -f /tmp/fac_workspace_debug.txt
389
390 # Remove workspace (clean slate)
391 rm -rf .fac/
392 ```
393
394 ---
395
396 ## Ready?
397
398 1. ✅ Read all documentation
399 2. ✅ Understand the vision
400 3. ✅ Environment ready
401 4. ✅ Start Phase 0!
402
403 Let's build this thing! 🚀