Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ fin-guru/data/user-profile.yaml
**/user-profile.yaml
# Onboarding state and progress (may contain sensitive configuration)
.onboarding-state.json
# Setup progress tracking (user-specific)
.setup-progress
.onboarding-progress.json
# All generated strategies and reports
fin-guru-private/
Expand Down
16 changes: 8 additions & 8 deletions .planning/REQUIREMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@

### Setup Automation

| ID | Requirement | Scope | Phase | Notes |
|----|-------------|-------|-------|-------|
| ONBD-05 | setup.sh orchestrates full first-time setup | v1 | 2 | Dependency checks, onboarding, config generation |
| ONBD-06 | setup.sh is idempotent — re-run updates missing fields only | v1 | 2 | Detect existing files, diff against template, prompt for missing |
| SETUP-01 | Dependency checker verifies prerequisites (uv, bun, Python 3.12+) | v1 | 2 | Show exact install commands on failure, fail-fast |
| SETUP-02 | setup.sh creates fin-guru-private/ directory structure | v1 | 2 | hedging/, strategies/, analysis/ subdirectories |
| SETUP-03 | --check-deps-only flag for dry-run dependency verification | v1 | 2 | For CI/debugging use |
| ID | Requirement | Scope | Phase | Status | Notes |
|----|-------------|-------|-------|--------|-------|
| ONBD-05 | setup.sh orchestrates full first-time setup | v1 | 2 | Complete | Dependency checks, directory creation, config scaffolding, Python deps |
| ONBD-06 | setup.sh is idempotent — re-run updates missing fields only | v1 | 2 | Complete | File-level skip/prompt; field-level YAML merge deferred to Phase 3 |
| SETUP-01 | Dependency checker verifies prerequisites (uv, bun, Python 3.12+) | v1 | 2 | Complete | check-all-then-fail, OS-specific install commands, sort -V comparison |
| SETUP-02 | setup.sh creates fin-guru-private/ directory structure | v1 | 2 | Complete | 13+ subdirectories including hedging/, strategies/, analysis/ |
| SETUP-03 | --check-deps-only flag for dry-run dependency verification | v1 | 2 | Complete | Dry-run check, no filesystem modifications, exit code reflects status |

### Onboarding Wizard

Expand Down Expand Up @@ -256,4 +256,4 @@
| **11: Integration** | EXPL-07, EXPL-10, EXPL-12, EXPL-13 |

---
*Last updated: 2026-02-02*
*Last updated: 2026-02-04 (Phase 2 requirements marked Complete)*
6 changes: 3 additions & 3 deletions .planning/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ Plans:
**Plans**: 2 plans

Plans:
- [ ] 02-01-PLAN.md -- Rewrite setup.sh: dependency checker, OS detection, color output, CLI args, --check-deps-only, auto-install prompts (SETUP-01, SETUP-03)
- [ ] 02-02-PLAN.md -- Directory creation, config scaffolding, .setup-progress tracking, idempotent re-runs, integration test update (ONBD-05, ONBD-06, SETUP-02)
- [x] 02-01-PLAN.md -- Rewrite setup.sh: dependency checker, OS detection, color output, CLI args, --check-deps-only, auto-install prompts (SETUP-01, SETUP-03)
- [x] 02-02-PLAN.md -- Directory creation, config scaffolding, .setup-progress tracking, idempotent re-runs, integration test update (ONBD-05, ONBD-06, SETUP-02)

---

Expand Down Expand Up @@ -518,7 +518,7 @@ Phases execute in numeric order: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10
| Phase | Milestone | Plans Complete | Status | Completed |
|-------|-----------|----------------|--------|-----------|
| 1. Git Scrub & Security | M1 | 0/3 | Planned | - |
| 2. Setup Automation | M1 | 0/2 | Planned | - |
| 2. Setup Automation | M1 | 2/2 | Complete | 2026-02-04 |
| 3. Onboarding Wizard | M1 | 0/2 | Planned | - |
| 4. Polish & Hooks | M1 | 0/2 | Planned | - |
| 5. Agent Readiness | M1 | 0/0 | Planned | - |
Expand Down
36 changes: 21 additions & 15 deletions .planning/STATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,34 @@
See: .planning/PROJECT.md (updated 2026-02-02)

**Core value:** Anyone can clone the repo, run setup, and have a working personalized Finance Guru with their own financial data -- no hardcoded references, no manual configuration, and a growing suite of institutional-grade CLI analysis tools.
**Current focus:** Phase 1 - Git History Scrub & Security Foundation
**Current focus:** Phase 2 complete -- Setup Automation & Dependency Checking

## Current Position

Phase: 1 of 12 (Git History Scrub & Security Foundation)
Plan: 1 of 3 in current phase
Status: In progress
Last activity: 2026-02-04 -- Completed 01-01-PLAN.md (Working Tree PII Cleanup)
Phase: 2 of 12 (Setup Automation & Dependency Checking)
Plan: 2 of 2 in current phase (PHASE COMPLETE)
Status: Phase complete
Last activity: 2026-02-04 -- Completed 02-02-PLAN.md

Progress: [## ] 3%
Progress: [██░░░░░░░░░░░░░░░░░░] 6%

## Performance Metrics

**Velocity:**
- Total plans completed: 1
- Average duration: ~15 min
- Total execution time: ~0.25 hours
- Total plans completed: 3
- Average duration: ~11 min
- Total execution time: ~0.55 hours

**By Phase:**

| Phase | Plans | Total | Avg/Plan |
|-------|-------|-------|----------|
| 01 | 1/3 | ~15 min | ~15 min |
| 01-git-scrub | 1/3 | ~15 min | ~15 min |
| 02-setup-automation | 2/2 | 17 min | 9 min |

**Recent Trend:**
- Last 5 plans: 01-01 (~15 min)
- Trend: Starting
- Last 5 plans: 01-01 (~15 min), 02-01 (6 min), 02-02 (11 min)
- Trend: Accelerating

*Updated after each plan completion*

Expand All @@ -50,6 +51,11 @@ Recent decisions affecting current work:
- [01-01]: PII replaced with template variables ({account_id}, {spreadsheet_id}, {user_name}, {employer_name}, {llc_name}) rather than generic placeholders
- [01-01]: OS-level paths preserved, will be handled by git-filter-repo in Plan 02
- [01-01]: Personal email addresses and domains in backend dev guidelines cleaned as additional PII
- [02-01]: Used sort -V for version comparison (avoids Python 4.x false negative from arithmetic)
- [02-01]: check-all-then-fail pattern with set -e + || guards for dependency checking
- [02-02]: File-level idempotency only for setup.sh; field-level YAML merging deferred to Phase 3 onboarding wizard
- [02-02]: verify_directory_structure runs on every execution path (first run and re-run) to catch missing subdirs
- [02-02]: user-profile.yaml template at fin-guru/data/ (tracked in git as template, Phase 3 will populate)

### Pending Todos

Expand All @@ -63,7 +69,7 @@ None yet.

## Session Continuity

Last session: 2026-02-04
Stopped at: Completed 01-01-PLAN.md
Last session: 2026-02-04T03:46:21Z
Stopped at: Completed 02-02-PLAN.md (Phase 2 complete)
Resume file: None
Next action: /gsd:execute-phase 1 (Plan 02 - git-filter-repo history rewrite)
Next action: /gsd:plan-phase 3 (Onboarding Wizard -- depends on Phase 2 which is now complete)
110 changes: 110 additions & 0 deletions .planning/phases/02-setup-automation/02-01-SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
phase: 02-setup-automation
plan: 01
subsystem: infra
tags: [bash, setup, dependency-checker, os-detection, cli, color-output]

# Dependency graph
requires:
- phase: none
provides: "First plan in phase 2, no prior phase dependency"
provides:
- "setup.sh dependency checker with OS detection and version comparison"
- "--check-deps-only dry-run flag"
- "--help usage flag"
- "Auto-install prompts for missing dependencies"
- "Placeholder section for Plan 02 directory creation and config scaffolding"
affects: [02-02-PLAN, 03-onboarding-wizard]

# Tech tracking
tech-stack:
added: []
patterns:
- "sort -V for version comparison (avoids arithmetic pitfall)"
- "check-all-then-fail with set -e + || guards"
- "Terminal color detection with tty + TERM fallback"
- "printf for all colored output (not echo -e)"
- "command -v for dependency detection (not which)"
- "grep -oE for version extraction (not grep -oP for macOS compat)"

key-files:
created: []
modified:
- "setup.sh"

key-decisions:
- "Used sort -V for version comparison instead of arithmetic (avoids Python 4.x false negative)"
- "Used ${TERM:-dumb} default for unset TERM in CI/cron environments"
- "Check all deps before failing (accumulate with || guards under set -e)"
- "Auto-install prompt only in interactive mode ([ -t 0 ] guard)"
- "OS-specific install commands: brew for macOS, apt for Linux/WSL, curl for uv/Bun"

patterns-established:
- "setup.sh section structure: color detection -> helpers -> OS detection -> version comparison -> dep checking -> CLI parsing -> main flow"
- "check-all-then-fail accumulator pattern for set -e scripts"

# Metrics
duration: 6min
completed: 2026-02-04
---

# Phase 2 Plan 1: Dependency Checker Summary

**Pure-bash dependency checker with OS detection, sort -V version comparison, color output, CLI flags (--check-deps-only, --help), and auto-install prompts**

## Performance

- **Duration:** 6 min
- **Started:** 2026-02-04T03:22:56Z
- **Completed:** 2026-02-04T03:29:11Z
- **Tasks:** 2
- **Files modified:** 1

## Accomplishments
- Rewrote setup.sh from scratch (329 new lines replacing 357 old lines)
- Dependency checker validates Python 3.12+, uv, and Bun with check-all-then-fail pattern
- OS detection correctly identifies macOS/Linux/WSL with package manager lookup
- Color output in terminals, plain text in pipes (verified with cat -v)
- --check-deps-only flag performs dry-run check without filesystem modifications
- Auto-install prompts with tty guard for non-interactive environments
- version_gte correctly handles edge cases: 3.14 >= 3.12, 3.10 < 3.12, 4.1 >= 3.12, 3.12 >= 3.12
- Placeholder section for Plan 02 functions (directory creation, config scaffolding, Python deps)

## Task Commits

Each task was committed atomically:

1. **Task 1: Rewrite setup.sh with header, color detection, utility functions, and CLI args** - `74ab2da` (feat)
2. **Task 2: Verify dependency checker against all four success criteria paths** - _verification only, no code changes_

## Files Created/Modified
- `setup.sh` - Complete rewrite: dependency checker, OS detection, color output, CLI args, auto-install prompts

## Decisions Made
- Used `sort -V` for version comparison instead of arithmetic splitting -- avoids the critical bug where `4.1 >= 3.12` incorrectly fails (RESEARCH.md Pitfall 1)
- Used `${TERM:-dumb}` default for unset TERM -- prevents ANSI codes leaking in CI/cron where TERM is unset (RESEARCH.md Pitfall 3)
- Checked `command -v brew` before offering brew install commands -- prevents "command not found: brew" during auto-install (RESEARCH.md Pitfall 6)
- Used `[ -t 0 ]` guard before `read` prompts -- prevents script hanging in non-interactive contexts (RESEARCH.md Pitfall 4)
- Removed Steps 8-11 from old script (symlinks, onboarding, MCP Launchpad) -- out of scope per plan

## Deviations from Plan

None - plan executed exactly as written.

## Issues Encountered

None.

## User Setup Required

None - no external service configuration required.

## Next Phase Readiness
- setup.sh dependency checker is complete and verified
- Ready for 02-02-PLAN.md: directory creation, config scaffolding, .setup-progress tracking, idempotent re-runs
- Plan 02 will fill in the placeholder functions: create_directory_structure, scaffold_config_files, install_python_deps, print_summary
- Note: dev environment has python3 at 3.11 (python3.12 available separately) -- the script correctly identifies this version mismatch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix typo (“separately”).

Line 106 appears to have a truncated word (“separatel”).

✏️ Suggested fix
-- Note: dev environment has python3 at 3.11 (python3.12 available separatel...)
+- Note: dev environment has python3 at 3.11 (python3.12 available separately...)
🧰 Tools
🪛 LanguageTool

[grammar] ~106-~106: Ensure spelling is correct
Context: ...int_summary - Note: dev environment has python3 at 3.11 (python3.12 available separatel...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
In @.planning/phases/02-setup-automation/02-01-SUMMARY.md at line 106, Fix the
typo in the sentence containing "Note: dev environment has python3 at 3.11
(python3.12 available separatel) -- the script correctly identifies this version
mismatch" by replacing the truncated word "separatel" with the correct spelling
"separately" in the .planning/phases/02-setup-automation/02-01-SUMMARY.md
content so the full line reads "(python3.12 available separately)"; save and
commit the change.


---
_Phase: 02-setup-automation_
_Completed: 2026-02-04_
109 changes: 109 additions & 0 deletions .planning/phases/02-setup-automation/02-02-SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
phase: 02-setup-automation
plan: 02
subsystem: infra
tags: [bash, setup-script, idempotency, progress-tracking, uv, directory-scaffolding]

# Dependency graph
requires:
- phase: 02-setup-automation/01
provides: "Dependency checker with OS detection, color output, CLI args, --check-deps-only"
provides:
- "Complete setup.sh: directory creation, config scaffolding, progress tracking, Python deps, summary"
- "Idempotent re-run via .setup-progress file-level tracking"
- "fin-guru-private/ directory tree with hedging, strategies, analysis subdirs"
- "user-profile.yaml template for Phase 3 onboarding wizard to populate"
- "Integration test covering first run, idempotency, missing dir detection, --check-deps-only, --help"
affects: [03-onboarding-wizard, 06-config-models]

# Tech tracking
tech-stack:
added: []
patterns:
- "Progress file (.setup-progress) with line-per-step format for resumable setup"
- "scaffold_file() with [ -t 0 ] tty check for overwrite prompts"
- "verify_directory_structure() runs on EVERY path for structural validation"
- "File-level idempotency (skip or prompt) -- field-level YAML merging deferred to Phase 3"

key-files:
created:
- ".planning/phases/02-setup-automation/02-02-SUMMARY.md"
modified:
- "setup.sh"
- ".gitignore"
- "tests/integration/test_setup_onboarding_integration.sh"

key-decisions:
- "File-level idempotency only: scaffold_file skips existing files or prompts for full overwrite. Field-level YAML merging deferred to Phase 3 onboarding wizard (ONBD-06 scope boundary)"
- "verify_directory_structure runs on every execution path (first run AND re-run) to catch missing subdirs even when dirs_created is already in progress file"
- "5 trackable milestones: deps_checked, dirs_created, dirs_verified, config_scaffolded, python_deps_installed"
- "User-profile.yaml placed at fin-guru/data/ (tracked in git as template) rather than fin-guru-private/ (gitignored)"

patterns-established:
- "Progress tracking: is_step_complete/mark_step_complete with grep-based line matching"
- "Config scaffolding: scaffold_file handles tty detection, overwrite prompt defaults to N"
- "Summary reporting: CREATED_ITEMS/SKIPPED_ITEMS arrays for end-of-run report"

# Metrics
duration: 11min
completed: 2026-02-04
---

# Phase 2 Plan 2: Directory Creation, Config Scaffolding, and Idempotent Re-runs Summary

**Complete setup.sh with fin-guru-private/ directory tree, user-profile.yaml/env/README scaffolding, .setup-progress resumable tracking, uv sync Python deps, and 46-assertion integration test**

## Performance

- **Duration:** 11 min
- **Started:** 2026-02-04T03:34:51Z
- **Completed:** 2026-02-04T03:46:21Z
- **Tasks:** 3 (Task 2 was verification-only, no code changes needed)
- **Files modified:** 3

## Accomplishments
- setup.sh creates all 20+ directories under fin-guru-private/ including hedging/, strategies/active|archive|risk-management, analysis/reports, and notebooks tree
- Config scaffolding with scaffold_file() creates user-profile.yaml template, .env from .env.example, and fin-guru-private/README.md with tty-aware overwrite prompts
- .setup-progress tracks 5 milestones for resumable re-runs; second run shows "Resuming setup... (5/5 steps completed)" and skips completed steps
- verify_directory_structure runs on every execution path, detecting and recreating missing subdirectories even when the progress file shows dirs_created as complete
- Integration test rewritten with 46 assertions covering first run, --check-deps-only isolation, idempotent re-run, missing directory detection, and --help flag

## Task Commits

Each task was committed atomically:

1. **Task 1: Add progress tracking, directory creation, config scaffolding, Python deps, and summary** - `f01f48e` (feat)
2. **Task 2: Implement idempotent re-run behavior and verify SC4** - No commit (verification-only, all behavior correct from Task 1)
3. **Task 3: Update integration test for new setup.sh behavior** - `1ef6a53` (test)

## Files Created/Modified
- `setup.sh` - Added 8 new functions: is_step_complete, mark_step_complete, show_progress, create_dir, create_directory_structure, verify_directory_structure, scaffold_file, scaffold_config_files, install_python_deps, print_summary. Updated main flow with step-based execution.
- `.gitignore` - Added .setup-progress exclusion in Family Office section
- `tests/integration/test_setup_onboarding_integration.sh` - Complete rewrite: 46 assertions across 5 test groups, removed all old onboarding/symlink/MCP references

## Decisions Made
- **File-level idempotency scope boundary (ONBD-06):** scaffold_file handles skip/overwrite at file level only. Field-level YAML merging (parsing existing user-profile.yaml to add missing keys) deferred to Phase 3 onboarding wizard per CONTEXT.md: "setup.sh prepares the environment, it does not collect financial profile data."
- **verify_directory_structure on every path:** Even on first run after create_directory_structure, we run verify. This catches scenarios where dirs already existed from a prior partial run but are missing expected subdirectories.
- **user-profile.yaml at fin-guru/data/ (not fin-guru-private/):** The template is committed to git so new clones get it. Phase 3 onboarding will populate it with user data into the gitignored fin-guru-private/ location or update this template in place.
- **Non-interactive default for scaffold_file:** When stdin is not a tty, existing files are kept without prompting. This prevents CI/test hangs.

## Deviations from Plan

None - plan executed exactly as written. Task 2 (idempotency verification) required zero code fixes; all four scenarios passed on first attempt.

## Issues Encountered
- **Python 3.12 not default in dev environment:** `python3` resolves to 3.11 in this environment while `python3.12` is available at `/usr/bin/python3.12`. Handled via PATH override in testing and in the integration test's PATH Setup section. This is an environment-specific issue, not a script bug -- the dependency checker correctly reports the version mismatch.

## User Setup Required

None - no external service configuration required.

## Next Phase Readiness
- setup.sh is fully functional: `./setup.sh` on a fresh clone creates working environment
- Phase 2 is complete (both plans done): dependency checking + directory/config setup
- Ready for Phase 3 (Onboarding Wizard): user-profile.yaml template exists at fin-guru/data/, onboarding wizard will populate it with interactive financial profile data
- fin-guru-private/ directory structure is in place for hedging tools (Phase 6) and analysis outputs

---
_Phase: 02-setup-automation_
_Completed: 2026-02-04_
Loading