8.5 KiB
Phase 3: update, build, install and test
Use only codex/word-companion-native-phase1-20261104. Phase 2's working developer installation 1.0.0.4 is preserved by preparation. The new developer build identifier is 1.0.0.5; it is not Windows-qualified until the steps below pass.
Update and prepare (no installation)
For the initial bootstrap, in the existing PlotDirector repository, fetch the new script safely:
if ((git branch --show-current).Trim() -ne 'codex/word-companion-native-phase1-20261104') { throw 'Wrong branch; do not switch automatically.' }
if (git status --porcelain=v1) { throw 'Preserve local changes before updating.' }
git pull --ff-only origin codex/word-companion-native-phase1-20261104
if ($LASTEXITCODE -eq 0) { & .\PlotDirector.NativeCompanion\WindowsValidation\Update-WordCompanion.ps1 }
Thereafter the single update/build command is:
& .\PlotDirector.NativeCompanion\WindowsValidation\Update-WordCompanion.ps1
It checks the branch/clean worktree, fetches and fast-forwards, refuses unpublished/divergent local history, finds existing Office-equipped command-line MSBuild, builds managed Release, runs native/server authentication/HTTP tests, builds signed VSTO manifests without Office registration, publishes the .NET 10 win-x64 agent and verifies a complete hash-inventoried package. If the script itself changed on fetch it re-enters the updated script. It never launches Visual Studio or its installer, changes workloads/PATH/IDE settings, closes Word, registers the add-in or alters the current installation.
The package is placed in your Windows Downloads known folder under PlotDirectorWordCompanion\1.0.0.5-<short SHA>. A successful rerun verifies/reports the existing package rather than overwriting it. A failed preparation can leave a clearly named .preparing-<GUID> directory; it is not installed or reported as ready.
The helper first reuses a remembered certificate thumbprint, then tries the signing certificate in the existing per-user PlotDirector manifest, then a single valid current-user code-signing certificate. If selection is ambiguous, run once with -CertificateThumbprint <existing certificate thumbprint>; that nonsecret choice is remembered outside Git. It never creates/trusts a certificate or exports a private key. Missing prerequisites stop with diagnostics rather than invoking Visual Studio Installer/Repair. Office still validates the manifest signatures/trust on load.
Explicit installation and rollback
Close Word normally, dealing with its save prompts. Use the exact package path printed by the update command:
& .\PlotDirector.NativeCompanion\WindowsValidation\Install-WordCompanion.ps1 -PackagePath '<printed package path>' -StopAgent
-StopAgent explicitly permits stopping only the named Companion agent in this Windows session/user profile after Word is closed. Visual Studio is not stopped. Without this switch a running agent causes a diagnostic stop. The installer detects/reuses the existing per-user PlotDirector Word add-in registry key instead of introducing a second registration. Multiple existing registrations cause a diagnostic stop.
Packages are copied to versioned %LOCALAPPDATA%\PlotDirector\WordCompanionDeveloper\versions\ directories and verified before registration. The former registry values/manifest location are backed up; existing Phase 2 files remain untouched. A repeated install of the same package does not replace that rollback backup. No machine-wide registry, trust store, ClickOnce updater or production distribution channel is changed. Use -WhatIf to preview the explicit install.
To restore the immediately previous per-user registration, with Word closed:
& .\PlotDirector.NativeCompanion\WindowsValidation\Install-WordCompanion.ps1 -Rollback -StopAgent
If a previous registration did not exist, rollback removes the new registration. Packages are retained. Signature/trust failures must be diagnosed; do not disable VSTO security or run IDE Repair. Preparing a package does not prove Windows build/installation acceptance; those operations remain unexecuted on Atlas.
Sign in and AI use
- Open Word. Check the native ribbon/Diagnostics and agent connection. Use Connect / Sign In and enter the HTTPS PlotDirector site root, for example the Development site provided in the repository guide. Site addresses are author-configured, not embedded in the add-in. The agent remembers only this address; credentials are memory-only.
- Approve the browser connection using the normal PlotDirector login/2FA. Approve only a request you initiated; compare the request-code suffix shown by the Companion and browser. Grants expire in four hours; password/security-stamp changes and lockout revoke access. Disconnect / forget sign-in clears the local grant. Agent restart requires sign-in again.
- Choose Analyse to detect local structure. No manuscript is uploaded. Existing markers are labelled as existing; other structural candidates are labelled local. Expand/collapse chapter nodes and select a result to inspect its bounded title, source, confidence and reasoning. Double-click navigates by Word position, without rewriting text.
- Select an authorised PlotDirector book in the review window, check one or more chapter nodes on the displayed local-results page, then choose AI: analyse checked chapters. An explicit confirmation identifies the book and warns about uploading/costs. No automatic upload occurs on opening, sign-in or local detection.
- Chapters are read in bounded Word-thread batches and uploaded individually by the agent. Review progress across the selected chapter batch. AI results appear in the separate AI scene suggestions tab, grouped by chapter. Errors are inspectable rows. Successful chapters remain available when another fails. Retry is another explicit selection/upload action, not silent replay.
- Cancel stops queued/reading work and requests server cancellation for the active chapter; already completed results remain. Server timeouts, configuration failures, invalid AI boundaries, authorisation expiry and quota failures appear as errors. If a network failure makes the outcome unknown, retry may incur another provider charge. No manuscript text, markers, imports or canonical scenes are changed.
The server must have this native API deployed, normal account/Story Intelligence entitlement, available configured OpenAI credentials/model/prompt, and migration 230 for the independently shipped marker-security fix. The final Phase 3 report states the actual Development deployment status. Production is not changed.
Windows qualification checklist
Build/install the new matching add-in and agent using the scripts; record exact Git SHA, version, tools, Office build and bitness. A Linux parse pass does not establish that Office MSBuild generates the expected portable signed manifest paths. If the package verifier refuses a manifest dependency/version, capture that diagnostic and correct the build, not the verifier's safety checks.
Test normal login/2FA, browser refusal, expiry/sign-out, authorised and unauthorised books, unavailable server/provider, quota error and reconnect. Use a small synthetic chapter for the first actual AI request. Confirm narrative boundary suggestions, confidence/reasoning and Word navigation; distinguish them from pre-existing markers. Do not accept a successful local detection as AI evidence.
Then test the author's manuscript and synthetic 190k/250k fixtures: three documents, repeated text, short/long paragraphs, rapid switching, edits, save/close/cancelled close, agent termination/restart and partial chapter failure. Check 100/150/200% DPI, resizing, modeless focus, full-title/evidence inspection, expansion state and both paginated tabs. Record COM/batch/tick timing, typing/scroll/save/close responsiveness, CPU/memory and queue depth versus add-in-disabled trials.
The current observed-revision model does not detect every same-length edit in an already dirty document. Results describe a captured snapshot; re-detect after editing. Chapter upload has a 120,000 Word-position/text-character bound, at most 10,000 paragraphs and 500 returned AI scenes; split/review an oversized chapter rather than uploading a whole novel. Up to 256 explicitly selected chapters can queue in one document; AI results are capped at 5,000 rows/document. No semantic editing, server-to-Word prose writing or Context/Intent migration is implemented.
Commit Windows fixes and qualification evidence to the same shared branch and push. Do not create a Windows feature branch or alter Production.