Files
makelore/.project-docs/30-worklog/tasks/20260824-pi-remove-opencode-a41c9e72.md

199 lines
12 KiB
Markdown

# Task: Implement PI-140 legacy OpenCode removal
## Identity
- Task ID: 20260824-pi-remove-opencode-a41c9e72
- Mode: Feature
- Branch: codex/20260824-pi-remove-opencode-a41c9e72-pi-remove-opencode
- Worktree: D:\Datas\OthersProjects\makelore-pi-remove-opencode-a41c9e72
- Base commit: 61fede2b4dfed3e29a6c4e37aee73896713979e1
- Owner: codex-root
- Status: Ready for Integration
## Scope
- Implement planner ticket PI-140 from accepted PI-130 commit `61fede2`.
- Move the legacy schema-v1 normalizer and generated-Agent manifest comparison
needed by the one-time cutover into a migration-owned helper, then remove the
production dependency on `electron/opencode`.
- Finish product-owned project, skill, provider, lifecycle, and Renderer wiring
through `/api/coding/*` and the existing Coding project/runtime services.
- Delete legacy OpenCode Main modules, Host routes, Renderer stores/types/UI,
tests/E2E fixtures, runtime resources, bundle/smoke scripts, and dependencies.
- Update packaging verification and current product documentation for the Pi-only
release while preserving the application/storage compatibility identifiers.
## Intent And Constraints
- Treat the cutover as a hard removal: no dual runtime, fallback, selector, or
compatibility wrapper may remain in production code.
- Preserve `.niancode/project.json` authority, stable Agent ids, project-scoped
state, app id `app.niancode.desktop`, the `niancode` protocol, and existing
installed-user storage identities.
- Preserve PI-020 migration guarantees: timestamped backup, exact comparison of
generated Agent files, backup of modified/uncertain Agent files, atomic schema
v2 write, empty v2 Conversation metadata, rollback on failure, and one-time
legacy conversation notice.
- Do not read project `.opencode` after migration. Leave all unrelated legacy
`.opencode` content and `<userData>/opencode` inert; do not recursively delete
either location. Do not create `.pi/agents`.
- Keep `resources/coding-skills` as the sole vendor-neutral built-in Skill source
and remove the runtime-specific extension consumer/resource.
- Keep the user's explicit real-Provider verification waiver as Accepted Risk;
do not claim it passed. macOS x64/arm64 validation remains deferred to PI-150
and must not be claimed here.
- Do not edit canonical shared project-memory documents from this feature
worktree; record promotion candidates here for later integration.
- Other registered Planning tasks do not declare a current overlap. The old
model-switch integration on `main` is complete and this task starts from a
later accepted baseline; its separately owned untracked task record remains
outside this worktree and scope.
## Plan
1. Extract the retained legacy v1 normalization/manifest logic into the Coding
migration boundary and add focused migration coverage for exact-generated,
modified, uncertain, rollback, notice, and no-post-migration-read behavior.
2. Replace remaining Main/context/provider/project/skill consumers with the
product-owned Coding composition and remove OpenCode IPC/events/routes.
3. Move the remaining Renderer project catalog, project configuration, skill,
and settings consumers to `/api/coding/*`; remove legacy runtime controls and
obsolete UI/store/type modules.
4. Remove OpenCode source, dependencies, runtime resources, bundle/smoke scripts,
and obsolete tests/E2E fixtures; update packaging probes and README copy.
5. Run focused migration/Coding tests, typecheck, zero-residue searches, the full
unit suite, production Vite build, and the available Windows-side packaging
checks that belong to PI-140.
6. Reconcile the task record, record only supported promotion candidates, commit
the coherent cutover, and request planner review without expanding into
PI-150 cross-platform or real-Provider qualification.
## Outcome
- Completed the hard production cutover from the legacy OpenCode stack to the
product-owned Coding composition and Pi runtime. Main, Preload, Host API, and
Renderer product flows now use `/api/coding/*`; the old route, IPC/event
surface, runtime manager/client, Renderer stores/types/pages, resources,
bundle/smoke scripts, dependencies, and obsolete tests were removed.
- Retained only the migration-owned schema-v1 normalizer and expected generated
Agent comparison in `electron/coding-projects/legacy-v1.ts`. Migration keeps
exact-delete/backup/rollback/notice behavior: it enumerates the legacy Agent
directory, removes exact generated files, and moves modified plus unknown Agent
files into the timestamped backup. Valid schema-v2 projects bypass legacy reads,
unrelated `.opencode` content remains inert, and no `.pi/agents` directory is
introduced.
- Preserved the existing session-observation product behavior at the
vendor-neutral boundary. A live ordinary prompt that reaches the authoritative
completed settlement queues the final Coding Conversation Snapshot using the
project id and product Conversation id; hydrate/reconnect snapshots,
steer/follow-up, failed/aborted turns, and replies without assistant natural
language do not enqueue.
- Preserved compatibility identifiers `app.niancode.desktop`, `niancode`, and
the persisted electron-store name `opencode-projects`. The remaining source
references to OpenCode are categorized compatibility/history boundaries:
the persisted store/file identity, migration paths, project-package exclusion,
and the one-time user notice.
- Corrected unpackaged Electron resource resolution so the Pi CLI and bundled
Skills resolve from the repository root instead of `dist-electron/main`.
- Declared the supported Canvas and msgpackr native optional-package closure at
the application root. Root cause: electron-builder's pnpm production collector
omitted transitive optional native/loader packages from ASAR; the explicit
platform packages make packaged native loading deterministic.
- Removed `opencode-ai`, `@opencode-ai/plugin`, `@playwright/mcp`, the OpenCode
runtime resources, and their packaging configuration. The Windows x64 package
contains the Pi CLI/runtime manifest and no legacy OpenCode package, binary,
plugin, MCP bundle, or fallback route.
- Upstream `@earendil-works/pi-ai` still contains files named `opencode*.js/json`
for its Provider protocol adapters. They are part of Pi's Provider package,
not the removed OpenCode runtime/package/plugin/fallback, and remain covered by
the explicitly accepted real-Provider qualification risk.
- Removed the unreferenced legacy session run machine and old `.gitignore`
exception, updated current repository guidance and the session-observation
integration guide to Coding/Pi, and restored the `node:path` import required by
the bundled-Python verifier.
- Planner incremental re-review through cumulative source HEAD `16f5c57` accepted
the implementation with Standards Pass / Spec Pass and zero remaining findings.
## Verification
- `corepack pnpm --version`: passed with the repository-pinned pnpm `10.33.4`.
- `CI=true corepack pnpm install --frozen-lockfile`: passed after regenerating
the lockfile from the accepted PI-130 base with pnpm 10; no pnpm 11 peer-context
noise remains.
- `pnpm run typecheck`: passed, including after the pinned-pnpm dependency rebuild.
- `pnpm exec eslint . --quiet`: passed.
- Full unit suite after planner fixes: 174 files passed; 1496 tests passed,
2 skipped (1498 total).
- Pressure suite: 1 file and 1 test passed.
- Focused post-review suite: 3 files and 34 tests passed for migration,
session-observation sync, and Conversation store settlement behavior. It covers
valid-v2 no-legacy-read, unknown/modified Agent backup, live ordinary-prompt
settlement, no hydrate/follow-up replay, and current-turn assistant natural-
language gating that cannot reuse an older assistant reply.
- Electron E2E: 3 tests passed for first Pi conversation latency/submit ordering,
Pi product UI, and bundled Skill project configuration.
- `pnpm run build:vite`: passed (Renderer, Electron Main, Preload, and utility).
- `node scripts/verify-bundled-python.mjs --root resources/python/win32-x64
--target win32-x64`: passed for Python 3.12.13 and stdlib after restoring the
required `node:path` import.
- Windows Pi bundle: passed with 130 production packages and 6 runtime assets.
- Staged Pi probe: local sessions, shell, abort, and concurrency passed; decision
intentionally remained `partial-pass` / `incomplete` because real Provider
turns were not verified.
- Windows x64 NSIS packaging: passed; installer
`release/Makelore-2.0.0-win-x64.exe` was produced.
- Packaged Electron runtime verifier: passed for Electron 43.4.0 / Node 24.18.1,
bundled Python, uv 0.10.0, npm 11.6.2, Canvas/msgpackr native loading from
ASAR/unpacked resources, and Unicode copying. Verified installer size was
202,365,344 bytes.
- Product-package Pi probe: local surface passed; cold p95 638 ms and warm p95
626 ms. Decision intentionally remained `partial-pass` / `incomplete` because
the Provider matrix has `realTurnVerified: false`.
- Repository-wide zero-residue scan has no unclassified hit. Production hits are
limited to migration paths, persisted compatibility identifiers, packaging
exclusion, and the one-time notice; tests contain migration fixtures and
negative assertions; old task/evidence records remain history. Canonical
project-memory descriptions are explicitly listed below for PI-160 promotion,
as required by feature-worktree ownership. The Windows artifact/ASAR scan also
separately categorizes the upstream Pi Provider adapter filenames described in
Outcome rather than treating their text as a legacy runtime residue.
- Planner review of `61fede2..5a275b9` returned Standards/Spec Needs Fix for four
P1s: unknown Agent backup, silently disconnected session observation, repo-wide
residue, and the Python verifier import. The current post-review changes address
all four. Incremental re-review of `5a275b9..16f5c57` accepted the fixes with
Standards Pass / Spec Pass and zero remaining findings.
- `git diff --check`: passed; only the repository's existing LF-to-CRLF warnings
were emitted.
- macOS x64/arm64 validation was explicitly skipped and is not reported as Pass.
- Real Provider validation was explicitly waived and is not reported as Pass.
## Follow-ups
- PI-150 must validate macOS x64/arm64 and the remaining planner-required
cross-platform release matrix before final release qualification.
- Real Provider turns still need future qualification for concurrency, credential
isolation, and protocol compatibility. The user explicitly accepted these
risks for PI-140, so this task must remain `partial-pass` / `incomplete` on that
dimension rather than silently promoting it to Pass.
- PI-160 should integrate the accepted PI-140 commit, promote the canonical
project-memory updates below, and resolve any accepted-document supersession.
## Promotion Candidates
- `.project-docs/20-architecture/module-map.md`: replace obsolete OpenCode module
ownership/data flow with Coding composition, the Pi runtime, and `/api/coding`.
- `.project-docs/40-domain/business-rules.md`: replace legacy Session/runtime/model
rules with schema-v2 Project/Conversation/Pi rules and inert legacy migration.
- `.project-docs/30-worklog/current-state.md`: record the accepted PI-140 commit,
Windows verification, explicit macOS/Provider deferrals, and supersede the old
production OpenCode state.
- Accepted commitments/decisions/success criteria that name the removed OpenCode
runtime should be reviewed at PI-160. Mechanical factual replacements follow
PI-140; changing accepted historical commitments requires integration-time
human judgment rather than a feature-worktree canonical edit.
- Promotion evidence: cumulative source HEAD `16f5c57`, this task-record completion
commit, the verification results above, and planner acceptance from task
`01a0202d-abd3-7851-b7e7-6ca8ccdbb702`.
- Semantic conflict: current canonical project memory still describes OpenCode
as the production runtime; PI-160 must supersede those statements atomically.