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
27 changes: 13 additions & 14 deletions DO_NEXT.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# Frankencode — Do Next

Follow the phases in [PLAN.md](PLAN.md). Security first.
All 6 planned phases are complete. Remaining work is backlog items.

## Immediate: Phase 1 — Security Fixes
## Backlog: Features

1. Fix S1: `Filesystem.contains()` — add `realpathSync()` in `src/util/filesystem.ts`
2. Fix S2: `exec()` → `spawn()` in `src/cli/cmd/github.ts`
3. Fix S3: workspace trust prompt for `.opencode/` MCP and plugins
4. Fix S4: server auth for non-loopback binding
5. Fix S5: sensitive file deny-list for read tool
6. Evaluate upstream security PRs: #10763, #10974, #14581
- [ ] TUI rendering of edit indicators (hidden/replaced/annotated parts)
- [ ] CAS garbage collection improvements (size limits, age-based cleanup)
- [ ] TUI features from upstream PRs (sidebar position, /edit command, syntax highlighting)

## Then: Phase 2 — High-Priority Upstream Fixes
## Backlog: Maintenance

Cherry-pick 8 commits from vouched contributors. See [PLAN.md](PLAN.md) Phase 2.
- [ ] Periodic upstream re-sync — cherry-pick new fixes as they land on `upstream/dev`
- [ ] S3 workspace trust — full trust prompt (VS Code model) for `.opencode/` autoloading
- [ ] Monitor upstream community PRs for backportable fixes

## See Also

- [PLAN.md](PLAN.md) — full 6-phase roadmap
- [GAP_ANALYSIS.md](GAP_ANALYSIS.md) — current vs target state per phase
- [BUGS.md](BUGS.md) — security issues S1-S5
- [UPSTREAM_STATUS.md](UPSTREAM_STATUS.md) — upstream commit/PR catalogue
- [PLAN.md](PLAN.md) — completed 6-phase roadmap
- [GAP_ANALYSIS.md](GAP_ANALYSIS.md) — all phase gaps closed
- [UPSTREAM_STATUS.md](UPSTREAM_STATUS.md) — upstream commit/PR catalogue with analysis
- [docs/SECURITY_AUDIT.md](docs/SECURITY_AUDIT.md) — CVE and vulnerability status
97 changes: 21 additions & 76 deletions GAP_ANALYSIS.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,35 @@
# Frankencode — Gap Analysis

**Date:** 2026-03-21
**Date:** 2026-03-22

## Current State → Target State by Phase
## All Phases Complete

### Phase 1: Security Fixes
| Phase | Goal | Status |
|-------|------|--------|
| 1 | Security fixes (S1-S5) | Done — 4 fixed, 1 mitigated |
| 2 | High-priority upstream fixes | Done — 5 backported |
| 3+4 | Quality + community fixes | Done — OpenTUI 0.1.88, agent ordering |
| 5 | Remaining tests | Done — 24 new tests (filterEdited, filterEphemeral, validation) |
| 6 | Effect behavioral analysis | Done — 0 need reimplementation |

| Area | Current | Target |
|------|---------|--------|
| `Filesystem.contains()` | Lexical check only — symlinks escape project | `realpathSync()` + lexical check |
| `exec()` in github.ts | Shell string execution | `spawn()` with argument array |
| `.opencode/` autoloading | No trust prompt — MCP/plugins run on clone | Trust prompt before loading workspace configs |
| Server auth | Skips auth when no password set | Require password for non-loopback, or bind loopback only |
| Read tool | No .gitignore check — exposes .env | Sensitive file deny-list |
| Security bugs in BUGS.md | 5 open (S1-S5) | 0 open |
## Remaining Gaps (Backlog)

### Phase 2: High-Priority Upstream Fixes

| Area | Current | Target |
|------|---------|--------|
| thinkingConfig | Set for all models | Only set for models with reasoning capability |
| SIGHUP handler | Missing | Restored (1-line fix from Dax) |
| Default timeout | Incorrect value | Fixed (2-line fix from Ariane Emory) |
| Event route processing | Synchronous | Queued to prevent backpressure |
| Forked prompt attachments | File parts lost | Preserved |
| Tagged error messages | Lost during processing | Preserved |
| Truncate permission | Import cycle | Broken cycle |
| Chunk timeout | Enabled by default | Disabled by default |

### Phase 3: Quality + OpenTUI

| Area | Current | Target |
|------|---------|--------|
| OpenTUI version | 0.1.88 | 0.1.90 |
| Agent/skill ordering | Non-deterministic | Stable ordering |
| apply_patch | Not in EDIT_TOOLS filter | Included |
| Provider.list() type | Loose | `Record<ProviderID, Info>` |
| Prompt schema debugging | No logs | Validation debug logs |

### Phase 4: Community Fixes + Features

| Area | Current | Target |
|------|---------|--------|
| Retry backoff | Unbounded exponential | Capped at 30s |
| 429 retry | Respects non-retryable flag | Retries transient 429s |
| Lone surrogates | 400 errors from providers | Stripped before sending |
| Empty content blocks | Sent to providers | Filtered out |
| LSP clients | Accumulate (memory leak) | Dead clients removed |
| Memory during prompting | Full scan | Lazy boundary scan + windowing |
| Subagent plan escape | Possible | Prevented |
| TUI permissions | Manual per-tool | Auto-accept mode option |

### Phase 5: Tests

| Area | Current | Target |
|------|---------|--------|
| filterEdited tests | 0 | Comprehensive (hidden, empty, synthetic placeholder) |
| ContextEdit validation | 0 | Ownership, budget, recency, privileged agents |
| TUI dialog tests | 0 | 9 dialogs covered |
| TUI interaction tests | 0 | Keyboard nav, prompt input, command palette |

### Phase 6: Effect Behavioral Analysis

| Area | Current | Target |
|------|---------|--------|
| Upstream Effect behaviors | Not analyzed | Each PR reviewed, valuable behaviors reimplemented |
| SkillService capabilities | Content cache only | + any new capabilities from upstream |
| FileTimeService | No semaphore | Evaluate if semaphore prevents races |
| VcsService | Our version | + HEAD filter fix if not already applied |

---
| Gap | Priority | Notes |
|-----|----------|-------|
| S3 workspace trust prompt | Med | Warning log added; full VS Code-style trust model planned |
| TUI edit indicators | Low | No visual indicator for hidden/replaced/annotated parts |
| CAS GC improvements | Low | Basic GC exists; size limits and age-based cleanup not implemented |
| Upstream re-sync | Ongoing | Cherry-pick new fixes as they land; 162 commits analyzed |

## Permanently Out of Scope

- Desktop/Electron app (never shipping)
- Bun→Node portability refactors (Bun-only target)
- Desktop/Electron app
- Bun→Node portability refactors
- Zen platform changes
- Web app UI (low priority, evaluate case-by-case)

---

## Cross-references

- [PLAN.md](PLAN.md) — phase details and exit criteria
- [BUGS.md](BUGS.md) — security issues S1-S5 + bug tracker
- [DO_NEXT.md](DO_NEXT.md) — immediate next actions
- [STATUS.md](STATUS.md) — current metrics
- [UPSTREAM_STATUS.md](UPSTREAM_STATUS.md) — full upstream catalogue
- [PLAN.md](PLAN.md) — completed roadmap
- [DO_NEXT.md](DO_NEXT.md) — backlog items
- [UPSTREAM_STATUS.md](UPSTREAM_STATUS.md) — full catalogue with Phase 6 analysis
- [docs/SECURITY_AUDIT.md](docs/SECURITY_AUDIT.md) — CVEs and vulnerability details
16 changes: 6 additions & 10 deletions PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> **Frankencode** is a fork of [OpenCode](https://github.com/anomalyco/opencode) (`dev` branch) that adds context editing, content-addressable storage, and an edit graph.

**Status (2026-03-21):** All features implemented. 51 bugs fixed, 5 security issues open. Type safety complete. Zod v4 migrated. 1473 tests passing, 0 tsgo errors.
**Status (2026-03-22):** All 6 phases complete. 51 bugs fixed, 4 security issues fixed, 1 mitigated. Type safety complete. Zod v4 migrated. 1512 tests passing, 0 tsgo errors. Upstream Effect analysis done — zero items need reimplementation.

**Upstream divergence:** 23 ahead, 162 behind, ~195 open PRs catalogued. See [UPSTREAM_STATUS.md](UPSTREAM_STATUS.md).

Expand Down Expand Up @@ -102,18 +102,14 @@ Cherry-pick or reimplement the best community contributions:

---

## Phase 6: Effect Behavioral Analysis
## Phase 6: Effect Behavioral Analysis — COMPLETE

For each of the 12 upstream Effect PRs, extract behavioral changes and reimplement in our architecture. NOT a rebase.
Analyzed all 12 upstream Effect PRs. Result: **zero items need reimplementation.**

Key PRs to analyze:
- #17544 — LayerMap (foundational, already done differently)
- #17849 — SkillService (we have content cache — check for new capabilities)
- #18483 — InstanceState consolidation (extract any bug fixes)
- #17829 — VcsService (contains HEAD filter bug fix)
- #17835 — FileTimeService (Semaphore locks — evaluate benefit)
- 2 bug fixes (VcsService HEAD filter, FileTimeService await+Semaphore) — already in our tree
- 10 pure structural refactors — not applicable to our architecture

**Exit criteria:** Behavioral changes extracted and reimplemented where valuable.
See [UPSTREAM_STATUS.md](UPSTREAM_STATUS.md) for full per-PR analysis.

---

Expand Down
48 changes: 23 additions & 25 deletions STATUS.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
# Frankencode — Project Status

**Date:** 2026-03-21
**Current phase:** Phase 1 (Security Fixes) — see [PLAN.md](PLAN.md)
**Date:** 2026-03-22
**All 6 phases complete.** See [PLAN.md](PLAN.md).

## Metrics

| Metric | Value |
|--------|-------|
| Tests | 1473 pass, 0 fail, 8 skip (127 files) |
| Tests | 1512 pass, 0 fail, 8 skip (133 files) |
| tsgo errors | 0 |
| Open security issues | 5 (S1-S5) |
| Security issues | 4 fixed (S1,S2,S4,S5), 1 mitigated (S3) |
| Open bugs | 0 |
| Deferred bugs | 1 (B51) |
| Fixed bugs | 51 |
| `any` remaining | 20 documented structural exceptions |
| Upstream divergence | 23 ahead, 162 behind, ~195 open PRs |
| PRs merged | #16-#25 |
| Upstream Effect PRs | All 12 analyzed — 0 need reimplementation |
| PRs merged | #16-#30 |

## Phase Progress

| Phase | Status | Description |
|-------|--------|-------------|
| 1 | **Next** | Security fixes (S1-S5) |
| 2 | Planned | High-priority upstream bug fixes (8 cherry-picks) |
| 3 | Planned | Quality fixes + OpenTUI upgrade |
| 4 | Planned | Community bug fixes + features |
| 5 | Planned | Remaining tests |
| 6 | Planned | Effect behavioral analysis |

## Key Documents

| File | Purpose |
|------|---------|
| [PLAN.md](PLAN.md) | 6-phase roadmap with exit criteria |
| [GAP_ANALYSIS.md](GAP_ANALYSIS.md) | Current → target state per phase |
| [BUGS.md](BUGS.md) | Security issues S1-S5 + bug tracker |
| [DO_NEXT.md](DO_NEXT.md) | Immediate next actions |
| [UPSTREAM_STATUS.md](UPSTREAM_STATUS.md) | Upstream commit/PR catalogue |
| [docs/SECURITY_AUDIT.md](docs/SECURITY_AUDIT.md) | CVEs and vulnerability analysis |
| Phase | Status | PR |
|-------|--------|-----|
| 1 | **Done** — Security fixes (S1-S5) | #26 |
| 2 | **Done** — High-priority upstream fixes (5 backported) | #27 |
| 3+4 | **Done** — OpenTUI upgrade + agent ordering | #28 |
| 5 | **Done** — Remaining tests (24 new) | #29 |
| 6 | **Done** — Effect behavioral analysis (0 need reimplementation) | #30 |

## What's Next

All planned phases complete. Remaining work is in the backlog:
- TUI rendering of edit indicators
- CAS garbage collection improvements
- TUI features from upstream PRs
- Periodic upstream re-sync (cherry-pick new fixes as they land)

See [DO_NEXT.md](DO_NEXT.md) and [PLAN.md](PLAN.md).
37 changes: 17 additions & 20 deletions UPSTREAM_STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,30 +99,27 @@ These replace Bun-specific APIs with Node.js equivalents. Only valuable if we pl
| `e9a17e448` | #17146 | AbigailJixiangyuyu | fix(windows): restore /editor support on Windows | Low |
| `54ed87d53` | #18010 | Luke Parker | fix(windows): use cross-spawn for shim-backed commands | Low |

## Effect-ification (12) — Kit Langton
## Effect-ification (12) — Kit Langton — ANALYZED (Phase 6)

**Cannot be cherry-picked.** These are architectural changes that conflict with Frankencode's approach:
**Cannot be cherry-picked.** Architectural divergence — upstream uses `InstanceState` + `ScopedCache`, we deleted `Instance` entirely.

- **Upstream:** `Instance` → `InstanceState` (using `ScopedCache` from Effect)
- **Frankencode:** `Instance` deleted → `InstanceALS` + `InstanceLifecycle` + module-level state maps with `registerDisposer`
**Phase 6 analysis result: zero items need reimplementation.** All behavioral changes are already in our tree. The 12 PRs are pure structural refactors (move to Effect service, rename, flatten facades) with no new runtime behavior.

Each PR must be analyzed for **behavioral changes** (bug fixes, new capabilities) that we should reimplement in our architecture, versus pure structural refactors (rename, move) that don't apply.

| SHA | PR | Description | Conflict |
| SHA | PR | Description | Analysis |
|-----|-----|-------------|----------|
| `469c3a420` | #17544 | refactor(instance): move scoped services to LayerMap | **HIGH** |
| `9e740d994` | #17827 | effectify FileWatcherService | Med |
| `e5cbecf17` | #17829 | fix+refactor: effectify VcsService | Med |
| `2cbdf04ec` | #17835 | effectify FileTimeService with Semaphore locks | Med |
| `335356280` | #17675 | effectify FormatService | Med |
| `69381f6ae` | #17845 | effectify FileService | Med |
| `384982276` | #17849 | effectify SkillService | **HIGH** — we have skill cache |
| `9e7c136de` | #17878 | effectify SnapshotService | Med |
| `5dfe86dcb` | #17957 | effectify TruncateService, delete Scheduler | Med |
| `a800583ae` | #18093 | unify service namespaces and align naming | High |
| `e78944e9a` | #18266 | effectify Installation, drop Effect suffix | Med |
| `38e0dc9cc` | #18483 | Move state into InstanceState, flatten facades | **HIGH** |
| `5d2f8d77f` | #18158 | upgrade effect beta, fix test regressions (Luke Parker) | Med |
| `469c3a420` | #17544 | move scoped services to LayerMap | Pure structural — we use registerDisposer |
| `9e740d994` | #17827 | effectify FileWatcherService | Pure structural |
| `e5cbecf17` | #17829 | fix+refactor VcsService | Bug fix (HEAD filter scoping) **already in our tree** |
| `2cbdf04ec` | #17835 | effectify FileTimeService + Semaphore | Bug fix (await + Semaphore) **already in our tree** |
| `335356280` | #17675 | effectify FormatService | Pure structural |
| `69381f6ae` | #17845 | effectify FileService | Pure structural |
| `384982276` | #17849 | effectify SkillService | Pure structural — our skill cache is separate |
| `9e7c136de` | #17878 | effectify SnapshotService | Pure structural |
| `5dfe86dcb` | #17957 | effectify TruncateService, delete Scheduler | Pure structural — we don't use Scheduler |
| `a800583ae` | #18093 | unify service namespaces | Pure rename (drop "Service" suffix) |
| `e78944e9a` | #18266 | effectify Installation | Pure structural |
| `38e0dc9cc` | #18483 | InstanceState + flatten facades | Architectural divergence — N/A |
| `5d2f8d77f` | #18158 | upgrade effect beta (Luke Parker) | Dependency update — we pin our own version |

## App/Desktop (20+) — Permanently Skip Desktop, Evaluate Web App

Expand Down
1 change: 1 addition & 0 deletions WHAT_WE_DID.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ CAS, edit graph, context editing (6 ops), side threads, objective tracker, class
- **#27:** Phase 2 upstream fixes: prompt parts (#17815), thinkingConfig guard (#18283), chunk timeout (#18264), error messages (#18165), event queue (#18259)
- **#28:** Phase 3+4 merged: OpenTUI 0.1.88 upgrade, agent ordering stability. Most other items already applied or diverged.
- **#29:** Phase 5 tests: filterEdited (8), filterEphemeral (6), ContextEdit validation (10) — 24 new tests
- **#30:** Phase 6 Effect analysis: all 12 upstream Effect PRs reviewed — zero need reimplementation
Loading