508 Commits

Author SHA1 Message Date
Michael Ramos 3a7f1156cd chore: bump version to 0.18.0
Also fix stale annotate description in README and add missing PLANNOTATOR_ORIGIN entry to the env vars table.

For provenance purposes, this commit was AI assisted.
v0.18.0
2026-04-19 17:41:53 -07:00
Alexander Kolberg 54c206c77d Add ~ support for user-entered file paths (#572)
* refactor(path): centralize user path resolution

* fix(annotate): resolve user paths in file entrypoints

* fix(pi-extension): restore resolve import and add typecheck to CI

The refactor removed `resolve` from `node:path` imports, but `resolvePlanPath()`
and the planning-mode write/edit guards still call `resolve(...)`. That breaks
plan submission and plan-file restriction at runtime for Pi users.

Also wires pi-extension's tsconfig into the root `typecheck` script so CI
catches this class of missing-symbol regression in the future. Required
adding @mariozechner/pi-* packages as explicit devDependencies so tsc can
resolve them (they were previously only reachable transitively via the
peer dep, which Bun keeps in its `.bun/` store unhoisted).

For provenance purposes, this commit was AI assisted.

* fix(path): reject whitespace-only user paths and run vendor before typecheck

resolveUserPath() trims input, so whitespace-only customPath/vaultPath
resolved to process.cwd(). Plans silently wrote into the repo root and
Obsidian notes landed in <cwd>/plannotator/ instead of erroring.

Guard at both call sites (getPlanDir, saveToObsidian — Bun + Pi copies).

Also prepend vendor.sh to the root typecheck script so fresh-clone
`bun run typecheck` works without a separate vendoring step.

For provenance purposes, this commit was AI assisted.

* fix(path): short-circuit resolveUserPath on empty input

Trimming in normalizeUserPathInput meant whitespace-only input resolved
to cwd/baseDir. Callers like the annotate CLI and reference API endpoints
would then list the project root instead of erroring. Return "" early so
downstream existsSync/resolveMarkdownFile checks fail naturally.

For provenance purposes, this commit was AI assisted.

---------

Co-authored-by: Michael Ramos <mdramos8@gmail.com>
2026-04-19 16:54:15 -07:00
HeikoAtGitHub 9bc1ba97d3 feat: detect OpenCode origin + activate PLANNOTATOR_ORIGIN override (#590)
* feat: detect OpenCode origin + activate PLANNOTATOR_ORIGIN override

Extend the origin detection chain in apps/hook/server/index.ts to recognize
OpenCode via `process.env.OPENCODE`, the stable runtime flag set by the
OpenCode binary (also sets OPENCODE_RUN_ID, OPENCODE_PID, OPENCODE_PROCESS_ROLE,
but OPENCODE=1 is the canonical detection flag).

Additionally, activate `PLANNOTATOR_ORIGIN` as an explicit override. The
comment in packages/server/index.ts already documented this variable, but
it was never actually read. It is now honored at the top of the detection
chain and validated against AGENT_CONFIG so only known origins take effect
— invalid values fall through to env-based detection.

Priority order after this change:
  PLANNOTATOR_ORIGIN > Codex > Copilot CLI > OpenCode > Claude Code (default)

Single-point fix: all five existing `detectedOrigin` usages (lines 405,
568, 694, 741, 999) pick up the new chain automatically. The `'opencode'`
origin key is already defined in packages/shared/agents.ts (AGENT_CONFIG),
complete with a UI badge — the detection chain was the last missing piece.

Closes the gap noted in packages/shared/agents.ts header comment:
"If detection is via environment variable, add it to the detection chain
in apps/hook/server/index.ts (detectedOrigin constant)".

* fix: remove stray project argument from getServerConfig calls

getServerConfig only accepts gitUser — the project argument was silently
ignored at runtime but fails the typecheck. Reverts the two call sites to
their correct single-argument form.

For provenance purposes, this commit was AI assisted.

---------

Co-authored-by: Michael Ramos <mdramos8@gmail.com>
2026-04-19 15:56:25 -07:00
Michael Ramos 104be99f3c Add thumbs up quick label button to annotation toolbar (#588)
* Add thumbs-up quick annotation button to annotation toolbar

A one-click "👍 Looks good" button joins the existing quick-label
system so users can approve a selection, code block, or diff hunk
without opening the picker. Covers plan, annotate, and plan-diff
modes (all share the same AnnotationToolbar).


* Move thumbs-up button to the right of the zap quick-label button

For provenance purposes, this commit was AI assisted.
2026-04-19 08:44:58 -07:00
Michael Ramos 84aa1d7d0b Surface Save as PDF via existing print flow (#587)
Rename the Options menu item from "Print Plan" to "Print / Save as PDF"
with a subtitle guiding users to pick "Save as PDF" as the print
destination. Linked docs, plan diff, annotate mode, and archive mode
all render through the same Viewer's [data-print-region="article"],
so print.css already covers them with no further changes.
2026-04-18 23:43:31 -07:00
dgrissen2 8a4ef65553 Add annotate wide mode (#578)
* Add annotate wide mode

* Extend wide mode: add Focus variant, enable in all modes, reposition controls

- Drop annotate-only gate in canUseAnnotateWideMode; available in plan review, annotate, and linked-doc flows (archive/diff still excluded)
- Add Focus mode alongside Wide: both collapse sidebars and suppress annotation panel auto-open; only Wide removes the reader width cap
- Move controls out of AnnotationToolstrip/StickyHeaderLane; render as absolute-positioned "Wide | Focus" text buttons floating above the plan card's top-right edge (no vertical space cost)
- Add Radix-based Tooltip primitive (packages/ui/components/Tooltip.tsx) and TooltipProvider; replaces the ad-hoc CSS tooltip with portaled, accessible, animated content
- Polish: tracking-wide for 11px labels, focus-visible ring, active press state, aria-pressed, weight-stable toggle (color-only), 60px right offset under tater mode

For provenance purposes, this commit was AI assisted.

* Update wideMode test to cover both annotate and plan review modes

The annotateMode gate was removed — update the test matrix to assert
wide mode is enabled in annotate AND plan review, and disabled for
archive/diff across both mode values.

For provenance purposes, this commit was AI assisted.

* Drop unused annotateMode parameter from canUseAnnotateWideMode

The parameter was ignored after the annotate-only gate was removed.
Prune it from the signature, the App.tsx call site and deps, and the
test matrix to match the actual behavior (disabled only for archive
and diff).

For provenance purposes, this commit was AI assisted.

---------

Co-authored-by: Michael Ramos <mdramos8@gmail.com>
2026-04-18 23:21:05 -07:00
Michael Ramos 615cc59c38 Prevent model from auto-invoking plannotator slash commands (#586)
Add `disable-model-invocation: true` frontmatter so these user-driven
commands (which open browser UIs and require human interaction) can
only be triggered explicitly by the user, not picked up automatically
by the model.
2026-04-18 20:44:25 -07:00
Michael Ramos ea758f9978 Add configurable paste service URL for self-hosting (#582)
* Wire PLANNOTATOR_PASTE_URL through opencode/pi servers and Landing demo link

OpenCode plugin only read PLANNOTATOR_SHARE_URL; add a getPasteApiUrl helper
and thread it into plan/annotate/archive server starts. Pi extension's
serverReview gains the same shareBaseUrl/pasteApiUrl env-var pair already
used by serverPlan/serverAnnotate. Landing.tsx now accepts a shareBaseUrl
prop for self-hosters' demo link. Paste-service CORS defaults grow a
comment clarifying that self-hosters must override ALLOWED_ORIGINS.

* Embed custom paste origin in short URL fragment

When PLANNOTATOR_PASTE_URL is set to a non-default paste service, the
generated short link now includes a base64url-encoded paste param in the
fragment (#key=...&paste=...). The share portal and importFromShareUrl
extract it on load so they can fetch from the right paste backend without
needing a server — fixing broken short links for self-hosters who use a
custom paste service but keep the hosted share portal.

Backward compatible: links without a paste param continue to use the
default or server-provided paste API URL as before.

For provenance purposes, this commit was AI assisted.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-17 22:21:49 -07:00
Александар Симић 0fe6c86333 Fix for RSS feed (#573)
Advertise the blog feed in the shared marketing layout
so feed readers and browsers can discover it automatically.
2026-04-16 07:53:50 -07:00
Andrei Neculau a8dc9e8f4b don't change current agent (#564)
agent_cycle is not the correct command as the user may have several agents defined, not only build and plan
2026-04-15 16:40:06 -07:00
Michael Ramos 32d78a4c8c docs(marketing): add parameter placeholder to /plannotator-review command
For provenance purposes, this commit was AI assisted.
2026-04-15 15:20:47 -07:00
Michael Ramos 96eab3a9c3 docs(marketing): update review command description to mention GitHub and GitLab PRs
For provenance purposes, this commit was AI assisted.
2026-04-15 15:18:31 -07:00
Michael Ramos 51d49a5c87 docs(marketing): replace html with spec/plan in annotate description
For provenance purposes, this commit was AI assisted.
2026-04-15 15:15:20 -07:00
Michael Ramos 6072f93c9e docs(marketing): use folder in annotate description, keep dir in param placeholder
For provenance purposes, this commit was AI assisted.
2026-04-15 15:13:11 -07:00
Michael Ramos 5ac9987e6a docs(marketing): apply shimmer animation to Plan review cap item
For provenance purposes, this commit was AI assisted.
2026-04-15 15:11:09 -07:00
Michael Ramos afd57e486f docs(marketing): rename folder to dir in annotate command
For provenance purposes, this commit was AI assisted.
2026-04-15 15:09:28 -07:00
Michael Ramos 7fb147403e docs(marketing): add parameter placeholder to /plannotator-annotate command
For provenance purposes, this commit was AI assisted.
2026-04-15 15:07:27 -07:00
Michael Ramos 2fbf180aac docs(marketing): add folder to annotate command description
For provenance purposes, this commit was AI assisted.
2026-04-15 15:07:14 -07:00
Michael Ramos 23aa6d456c docs(marketing): replace em dash with colon in plan review description
For provenance purposes, this commit was AI assisted.
2026-04-15 15:06:31 -07:00
Michael Ramos 901e92e188 docs(marketing): move /plannotator-review below annotate and last in capabilities
For provenance purposes, this commit was AI assisted.
2026-04-15 15:04:25 -07:00
Michael Ramos 9eb07e2985 docs(marketing): update annotate command description to include html and URL
For provenance purposes, this commit was AI assisted.
2026-04-15 15:03:57 -07:00
Michael Ramos e966db5188 docs(privacy): clarify decryption key is not stored for shared plans
For provenance purposes, this commit was AI assisted.
2026-04-15 14:50:08 -07:00
Michael Ramos f1fc0cb55c feat(marketing): add privacy policy page and footer link
For provenance purposes, this commit was AI assisted.
2026-04-15 14:46:35 -07:00
Orestis Ioannou 14bff361f8 fix(opencode): reuse local server for review flows (#567)
* fix(opencode): reuse local server for review flows

Try the default local OpenCode server before spawning a new one, and resolve bundled assets and command paths correctly when the plugin is loaded from source during local testing.

* Fix typecheck after narrowing the opencode type to the sdk
2026-04-15 08:22:55 -07:00
Michael Ramos 4139999526 feat(plan-diff): word-level inline diff rendering (#565)
* feat(plan-diff): word-level inline diff rendering

Two-pass hierarchical diff (diffLines outer + diffWordsWithSpace inner)
so modified plan blocks render with inline insertions/deletions in
context instead of showing the whole old block struck-through above the
whole new block. Resolves #560.

Engine (packages/ui/utils/planDiffEngine.ts):
- computeInlineDiff runs a second-pass word diff on modified blocks
  that pass a whitelist gate (paragraph/heading/list-item with matching
  structural fields).
- Sentinel substitution atomizes inline-code spans, markdown links, and
  fenced code blocks before diffWordsWithSpace runs, so diff markers
  never land inside backticks, link hrefs, or across fence boundaries.
  Fence regex uses a backreference so variable-length (e.g., 4-backtick
  wrapping 3-backtick) fences are matched atomically.
- Annotation context for an inline-diffed modified block now captures
  both old and new content so comments on struck-through words preserve
  that text in the exported feedback.

Renderer (packages/ui/components/plan-diff/PlanCleanDiffView.tsx):
- New InlineModifiedBlock component renders a modified block as one
  structural wrapper with <ins>/<del> wrappers inside, parsed through
  the local InlineMarkdown in a single pass so markdown delimiter pairs
  survive across token boundaries.
- InlineMarkdown extended to recognize <ins>/<del> tag passthrough
  (with recursive parsing of the wrapped content) and to recursively
  parse link anchor text so diff markers inside links render correctly.
- Plain-text stop-char scanner includes '<' so <ins>/<del> dispatch
  re-enters the loop instead of swallowing tag text.
- Click-to-annotate works in every editor mode (not just comment), with
  the block-level onClick opening the popover directly.

Mode switcher (packages/ui/components/plan-diff/PlanDiffModeSwitcher.tsx):
- Adds a third "Classic" tab between Rendered and Raw. Rendered is the
  new word-level default (labeled "exp"); Classic forces the legacy
  block-level stacked fallback for every modified block.

Styling (packages/ui/theme.css, packages/editor/index.css):
- plan-diff-word-added / plan-diff-word-removed utility classes for
  inline highlights with box-decoration-break: clone across line wraps.
- Inline <code> inside the diff wrappers picks up a tinted background
  so code-pill changes read unambiguously green/red.
- New plan-diff-modified class (amber border) for inline-diff modified
  blocks, matching the GitHub/VSCode convention of green=add,
  red=remove, yellow=both.

Tests (packages/ui/utils/planDiffEngine.test.ts):
- 18 tests covering the engine's qualification gate, structural-field
  matching, sentinel round-trip (inline code / links / fences), token
  content for common edit patterns.

For provenance purposes, this commit was AI assisted.

* chore(demo): restructure default demo, add VITE_DIFF_DEMO stress test

Demo content changes that support the word-level diff work but do not
alter shipped app behavior — only what other devs see running dev:hook.

packages/editor/demoPlan.ts (default V3 editor content):
- Added a "Context" section at the top of the plan with prose that
  showcases the word-level engine in V2→V3 diff: bold phrase swap,
  inline-code pill swaps, a link URL change, and a single-line code
  edit inside a config block.
- Moved the mermaid architecture diagram and graphviz service map to
  an "Appendix: Diagrams" section at the end of the plan; they were
  rendering ugly mid-document.

apps/hook/dev-mock-api.ts (Vite mock for the diff API):
- PLAN_V1 / PLAN_V2 split into *_DEFAULT (original Real-time
  Collaboration plan — preserved identically from pre-branch state) and
  *_DIFF_TEST (the 20-case Auth Service Refactor diff-engine stress
  test, kept as an opt-in tool).
- Resolves which pair to serve based on VITE_DIFF_DEMO env var. Matches
  the V2 Context section to the new V3 Context, with differences that
  produce rich word-level inline diffs on first load.
- Diagrams moved to Appendix in V2_DEFAULT to match V3.

packages/editor/App.tsx:
- Both demo imports are active. VITE_DIFF_DEMO=1 swaps
  DIFF_DEMO_PLAN_CONTENT into the editor's default; unset renders the
  original Real-time Collaboration plan as before.

packages/editor/demoPlanDiffDemo.ts (new):
- 20-case stress test (paragraphs, headings, lists, tables, fences,
  blockquotes, known limitations). Each case has an identical
  "What to watch for" blockquote label in both V2 and V3 so the diff
  view cleanly isolates each case. Opt-in only.

.gitignore:
- Ignore .claude/ runtime lock/state files. Machine-specific content
  that should not be tracked.

For provenance purposes, this commit was AI assisted.

* style(plan-diff): refine modified-block visual — amber gutter, no fill

Drop the yellow background fill from .plan-diff-modified and keep only a
softened amber left border. Added/removed blocks remain loud (full fill +
strong border) because add/remove are block-scope events — the whole
block matters. Modify is a word-scope event — the individual changed
words carry loud inline red/green highlights, and a block-level fill
would compete with that inline work. The amber gutter at 75% opacity now
reads as a quiet "look inside, the change is in the text" marker that
sits coherently with the rest of the palette.

For provenance purposes, this commit was AI assisted.

* fix(plan-diff): sanitize link hrefs against javascript: / data: schemes

PlanCleanDiffView has its own local copy of InlineMarkdown (separate
from the one in Viewer.tsx). The link-rendering branch was passing the
captured URL directly to href with no validation, so a plan containing
  [click me](javascript:alert(document.cookie))
would render as a live clickable anchor in the diff view. Plan content
is attacker-influenced — Claude pulls from source comments, READMEs,
fetched URLs — so this is a real exploit path in the diff flow.

Port the same guard Viewer.tsx already has: sanitizeLinkUrl() rejects
javascript:, data:, vbscript:, and file: schemes (case-insensitive, with
optional leading whitespace). Rejected links render their anchor text as
plain text instead of a clickable <a>, so the content is still visible
to the reader but no longer dangerous.

For provenance purposes, this commit was AI assisted.
2026-04-14 18:43:38 -07:00
Prannay Hebbar 724554600f feat(viewer): render color swatches next to hex color codes (#562)
When a plan contains hex color values (#rgb, #rrggbb, #rgba, #rrggbbaa),
the InlineMarkdown renderer now shows a small filled swatch inline to the
left of the code so the actual color is immediately visible.
2026-04-14 10:53:39 -07:00
Michael Ramos f1d3a880ed feat(annotate): try Accept: text/markdown before Jina/Turndown (#557)
Sites that support Cloudflare's "Markdown for Agents" (or similar
content negotiation) now return markdown directly, skipping the Jina
Reader and Turndown conversion entirely. The negotiation attempt uses
a short 5s timeout so failures fall through quickly to the existing
pipeline.

For provenance purposes, this commit was AI assisted.
2026-04-13 21:30:09 -07:00
Michael Ramos e22c911c2c chore: bump version to 0.17.10
For provenance purposes, this commit was AI assisted.
v0.17.10
2026-04-13 08:02:26 -07:00
Michael Ramos 38ca19ec1a ci: add smoke tests for compiled binaries in release pipeline (#555)
Runs three checks on the linux-x64 binary after compilation, before
artifact upload: --help (binary loads), review server startup (full
import chain + bundled HTML + git integration + HTTP binding), and
annotate server startup. Catches the class of build breakage where
compilation succeeds but the binary crashes on launch.

For provenance purposes, this commit was AI assisted.
2026-04-13 07:34:13 -07:00
David han (Bart) c2dadc9717 Bind local Plannotator servers to loopback by default (#533)
* Harden review agent job launch endpoints

* Stabilize agent job auth tests

* Drop review agent job token gating

* Align useAgentJobs with upstream formatting

* Allow remote sessions to bind all interfaces
2026-04-13 07:00:05 -07:00
Michael Ramos e410ac2568 docs(annotate): add URL/HTML docs, blog post, and env var references (#553)
- Rewrote the annotate command docs page to cover all four input types
  (URLs, HTML files, folders, markdown) with Jina Reader pipeline details,
  --no-jina flag, JINA_API_KEY, and source badge
- Added PLANNOTATOR_JINA and JINA_API_KEY to the environment variables
  reference page
- New blog post: "Annotate Any Web Page or HTML File" with embedded video

For provenance purposes, this commit was AI assisted.
2026-04-12 21:46:52 -07:00
Michael Ramos 81ae7f6d27 chore: move update-deps skill to .agents/skills/
For provenance purposes, this commit was AI assisted.
2026-04-12 20:48:01 -07:00
Michael Ramos 8cdab79094 chore: remove stray SVGs committed to root in #526
These were working files accidentally committed at the repo root.
Not referenced by any code.

For provenance purposes, this commit was AI assisted.
2026-04-12 20:47:22 -07:00
Michael Ramos ba80c9f172 fix: disable Renovate automerge to prevent repeat of #548 incident
Renovate's Immortal mode recreates closed PRs and automerges them
immediately. This is how #548 (Bun 1.3.12) landed on main despite
being explicitly closed. Disabling automerge ensures all dependency
PRs require human review.

For provenance purposes, this commit was AI assisted.
2026-04-12 20:46:15 -07:00
Michael Ramos 04848af686 chore: enforce 7-day minimum release age for supply chain hardening (#550)
- Add minimumReleaseAge (7 days) + internalChecksFilter (strict) to Renovate config
- Disable Renovate automerge (was the root cause of #548 re-merging overnight)
- Add minimumReleaseAge (604800s) to bunfig.toml for bun install/update
- Exclude @pierre/diffs from age gate (current ^1.1.12 can't resolve under 7-day gate)
- Bump audited deps: diff 8.0.4, claude-agent-sdk 0.2.92, codex-sdk 0.118.0, marked 17.0.6, @types/node 25.5.2
- Add /update-deps skill for supply chain audited dependency updates

For provenance purposes, this commit was AI assisted.
2026-04-12 20:45:02 -07:00
Michael Ramos d92564fe1c Revert "chore(deps): update github actions (#548)"
This reverts commit 66862a8131.
2026-04-12 20:43:17 -07:00
renovate[bot] 66862a8131 chore(deps): update github actions (#548)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-13 02:29:26 +00:00
Michael Ramos b780739291 feat(annotate): support HTML files and URL annotation (#545)
* fix(annotate): sanitize dangerous link protocols in markdown renderer

Block javascript:, data:, and vbscript: URLs in InlineMarkdown link
rendering. Links with dangerous protocols render as plain text instead
of clickable anchors. Uses a blocklist approach so existing links with
custom protocols (obsidian://, vscode://, Windows C:\ paths) continue
to work.

For provenance purposes, this commit was AI assisted.

* feat(annotate): add HTML-to-markdown and URL-to-markdown utilities

- html-to-markdown.ts: Turndown wrapper with GFM table rule, strips
  script/style/noscript tags
- url-to-markdown.ts: Jina Reader (free, returns markdown) with
  fetch+Turndown fallback. Warns on Jina failure, auto-skips Jina for
  local/private URLs (localhost, 192.168.*, 10.*, etc.)
- config.ts: add jina setting and resolveUseJina() with priority chain
  --no-jina flag > PLANNOTATOR_JINA env > config.json > default true

For provenance purposes, this commit was AI assisted.

* feat(annotate): support HTML files and URLs in annotate command

Extend the annotate subcommand to accept .html/.htm local files
(converted via Turndown) and https:// URLs (fetched via Jina Reader
with fetch+Turndown fallback). URL content is fetched terminal-side
before opening the browser.

Add --no-jina global flag to disable Jina Reader per-invocation.
Add 10MB file size guard for local HTML files.

For provenance purposes, this commit was AI assisted.

* feat(annotate): HTML files in folder browser and on-demand conversion

- Widen file browser glob to include .html/.htm alongside markdown
- handleDoc converts HTML files via Turndown on demand when selected
- hasMarkdownFiles accepts optional extensions param for folder validation
- Add sourceInfo field to annotate server API response
- Add _site/, public/, out/, .docusaurus/, .jekyll-cache/,
  storybook-static/ to FILE_BROWSER_EXCLUDED

For provenance purposes, this commit was AI assisted.

* feat(annotate): source attribution badge for HTML/URL annotations

Show a subtle badge in DocBadges displaying the URL hostname or HTML
filename for converted content. Thread sourceInfo from API response
through App → Viewer → DocBadges.

Also update Pi extension to accept HTML-only folders in annotate mode.

For provenance purposes, this commit was AI assisted.

* test: update CLI help text assertion for HTML/URL annotate support

For provenance purposes, this commit was AI assisted.

* fix(annotate): address PR review findings

Security:
- Add project-root containment check for HTML files in /api/doc handler
  using exported isWithinProjectRoot() from resolve-file.ts
- Blocks path traversal via absolute paths or ../ escapes

isLocalUrl fixes:
- Add bracketed IPv6 loopback [::1] detection
- Replace hostname.startsWith('10.') with proper IPv4 regex to avoid
  matching public hostnames like 10.example.com

Revert Pi extension change:
- Pi server doesn't implement HTML file browsing or conversion yet
- Keep Pi folder validation markdown-only until both implementations
  are updated per CLAUDE.md guidelines

Cleanup:
- Remove dead el.children || el.childNodes fallback in table rule
- Extract hostnameOrFallback() helper to @plannotator/shared/project
  replacing duplicated try/catch IIFEs in DocBadges and index.ts

For provenance purposes, this commit was AI assisted.

* feat(annotate): Pi extension HTML annotation parity

Bring the Pi extension to full parity with the Bun server for HTML
annotation support:

- Vendor html-to-markdown and url-to-markdown via vendor.sh
- walkMarkdownFiles now scans .html/.htm alongside markdown
- handleDocRequest converts HTML files on-demand via Turndown with
  isWithinProjectRoot containment check
- serverAnnotate includes sourceInfo in /api/plan response
- index.ts supports URL detection (Jina Reader + fallback), HTML file
  detection with Turndown conversion, folder HTML validation, and 10MB
  file size guard
- openMarkdownAnnotation accepts and threads sourceInfo
- Add turndown as a Pi extension dependency

For provenance purposes, this commit was AI assisted.

* fix(pi): Obsidian vault walks stay markdown-only, add try/catch for HTML

- Add extensions param to walkMarkdownFiles (default: HTML-inclusive)
- Obsidian callers pass /\.mdx?$/i to match Bun server behavior
- Add try/catch around HTML file reads in handleDocRequest

For provenance purposes, this commit was AI assisted.

* fix(annotate): address second review — base-block traversal, metadata IP, dead code

Security:
- Add isWithinProjectRoot check to the base-relative block for HTML
  files in both Bun and Pi /api/doc handlers. Previously HTML files
  served via the base query param bypassed the containment guard.
- Add 169.254.0.0/16 (link-local / cloud metadata) to isLocalUrl
  private IP ranges

Cleanup:
- Remove dead hostname === "[::1]" check (WHATWG URL parser strips
  brackets; hostname === "::1" already handles it)
- Remove dead parent?.childNodes fallback in table cell() function

For provenance purposes, this commit was AI assisted.

* refactor(annotate): replace custom table rules with turndown-plugin-gfm

Drop ~60 lines of hand-rolled GFM table conversion that had a bug
(tables without explicit <thead> produced invalid GFM). Use the
official turndown-plugin-gfm plugin (24KB) which correctly handles
all table patterns plus adds strikethrough and task list support.

For provenance purposes, this commit was AI assisted.

* fix(annotate): handle all CommonMark backslash escapes in InlineMarkdown

Expand the backslash escape regex to cover all CommonMark-defined
escapable characters (. ) - # > + | { } &), not just the subset
the parser uses for formatting. Fixes literal backslashes appearing
in rendered output for Turndown-escaped content like "1\." → "1.".

For provenance purposes, this commit was AI assisted.

* fix(annotate): prevent SSRF via redirect to private/local URLs

Replace redirect: "follow" with redirect: "manual" in fetchViaTurndown
and validate each redirect hop against isLocalUrl. Blocks attacks where
an external URL redirects to cloud metadata endpoints (169.254.169.254)
or other private IPs. Limits redirect chain to 10 hops.

For provenance purposes, this commit was AI assisted.

* chore: update lockfile for turndown-plugin-gfm in Pi extension

bun install needed to resolve turndown-plugin-gfm in the Pi extension
workspace after adding it to apps/pi-extension/package.json.

For provenance purposes, this commit was AI assisted.

* fix(annotate): switch to @joplin/turndown-plugin-gfm, fix TS errors

Replace unmaintained turndown-plugin-gfm (2017, v1.0.2) with the
actively maintained Joplin fork (2025, v1.0.64, 16KB).

Fix TypeScript errors that broke CI:
- Add @ts-expect-error for untyped @joplin/turndown-plugin-gfm import
- Restructure fetchViaTurndown redirect loop to avoid uninitialized
  variable — first fetch before loop, loop only for redirects

For provenance purposes, this commit was AI assisted.

* fix(annotate): use proper declarations.d.ts instead of ts-expect-error

Add declarations.d.ts for @joplin/turndown-plugin-gfm with typed
function signatures, remove the ts-expect-error suppression.

For provenance purposes, this commit was AI assisted.

* fix: explicitly include declarations.d.ts in shared tsconfig

CI's tsc wasn't finding the ambient module declaration with implicit
include. Add explicit include to ensure declarations.d.ts is always
picked up regardless of environment.

For provenance purposes, this commit was AI assisted.

* fix: use ts-expect-error for @joplin/turndown-plugin-gfm types

CI's tsc does not pick up ambient declarations.d.ts files despite
local tsc finding them — likely a module resolution discrepancy
between environments. Revert to @ts-expect-error which passes in
both CI and local typecheck.

For provenance purposes, this commit was AI assisted.

* fix(annotate): body size limit for URL fetches, redirect error, file: protocol

- Add 10MB body size limit to both Jina and fetch+Turndown URL paths,
  matching the local HTML file guard. Streams response body and aborts
  if limit exceeded.
- Distinguish "Too many redirects" from a genuine 3xx response after
  redirect loop exhaustion.
- Add file: to the dangerous protocol blocklist in sanitizeLinkUrl.

For provenance purposes, this commit was AI assisted.

* fix(annotate): HTML folder outside cwd, HTML linked doc navigation

- Remove containment check from base-relative block for HTML files in
  both Bun and Pi /api/doc handlers. Matches markdown behavior so HTML
  files in annotated folders outside cwd are served correctly.
  Standalone block (no base) retains its cwd check as fallback.
- Widen isLocalMd → isLocalDoc to treat .html/.htm links as linked
  documents. Clicking [Next](next.html) in a converted page now opens
  it via /api/doc with Turndown conversion instead of a new browser tab.

For provenance purposes, this commit was AI assisted.

* fix(annotate): full loopback range, drain redirect bodies, document env vars

- Expand loopback check from just 127.0.0.1 to the full 127.0.0.0/8
  range so all loopback addresses skip Jina Reader
- Cancel redirect response body before re-fetching to avoid leaking
  TCP connections back to the pool
- Document PLANNOTATOR_JINA and JINA_API_KEY in CLAUDE.md env var table

For provenance purposes, this commit was AI assisted.

* fix(annotate): IPv6 loopback, readBodyWithLimit fallback, env var docs, comments

- Add [::1] back to isLocalUrl — WHATWG URL hostname getter preserves
  brackets for IPv6 (verified: Bun and Node both return "[::1]").
  Add comment explaining the empirical verification so future reviewers
  don't re-flag.
- Fix readBodyWithLimit null-body fallback to still enforce the 10MB
  limit via text length check instead of silently falling through.
- Document PLANNOTATOR_JINA and JINA_API_KEY in AGENTS.md env var table
  (CLAUDE.md is a symlink to AGENTS.md).
- Add comments to base-relative blocks in both Bun and Pi handleDoc
  explaining the intentional lack of containment check (matches
  pre-existing markdown behavior, base is set server-side).

For provenance purposes, this commit was AI assisted.

* fix(annotate): block IPv4-mapped IPv6 and private IPv6 ranges in isLocalUrl

Add PRIVATE_IPV6 regex matching bracketed IPv6 private/reserved ranges:
- ::ffff: (IPv4-mapped — embeds private IPv4 as hex, e.g. [::ffff:c0a8:1])
- fe80: (link-local)
- fc00::/7 (unique-local, covers fc00:: through fdff::)

Closes the redirect-SSRF bypass where a public URL redirects to a
private address expressed as IPv4-mapped IPv6, e.g.
http://[::ffff:169.254.169.254]/latest/meta-data/

For provenance purposes, this commit was AI assisted.

* fix(annotate): document IPv6 hostname verification, sourceInfo type, annotate flow

- Expand isLocalUrl comment with full empirical verification table
  showing actual hostname getter output for every IPv6 format in both
  Bun and Node — prevents false-positive review findings about brackets
- Add sourceInfo to /api/plan response type in App.tsx for type safety
- Update CLAUDE.md annotate flow diagram to reflect HTML/URL/folder
  input types

For provenance purposes, this commit was AI assisted.

* fix(annotate): escape \(, cancel response bodies on error, doc sourceInfo

- Add ( to backslash escape regex alongside existing ) — Turndown
  emits \( in link-adjacent contexts
- Cancel response body before throwing on !res.ok in both fetchViaJina
  and fetchViaTurndown error paths (redirect loop already did this)
- Document sourceInfo field in AGENTS.md annotate server API table

For provenance purposes, this commit was AI assisted.

* fix(annotate): skip base injection for URL annotations, body cleanup

- Skip dirname(filePath) base injection when filePath is a URL in both
  Bun and Pi annotate servers. dirname on a URL string produces a
  nonsensical filesystem path, causing linked doc clicks to 404.
  URL annotations now let links open normally instead.
- Cancel response body before throwing on content-type mismatch and
  content-length overflow in fetchViaTurndown/readBodyWithLimit.
- Fix double parseInt in readBodyWithLimit content-length check.
- Correct AGENTS.md flow diagram: OpenCode not yet implemented for
  HTML/URL annotation.

For provenance purposes, this commit was AI assisted.

* feat(annotate): OpenCode HTML file and URL annotation support

Add URL detection (Jina Reader + fallback), HTML file detection with
Turndown conversion, 10MB file size guard, and sourceInfo threading
to OpenCode's handleAnnotateCommand. Uses the same shared utilities
as the Bun CLI and Pi extension.

OpenCode uses the Bun server directly (startAnnotateServer from
@plannotator/server/annotate), so no server-side changes needed —
only the command handler routing was missing.

Note: folder annotation mode is not added (OpenCode didn't have it
before this PR for markdown either — separate scope).

For provenance purposes, this commit was AI assisted.

* chore(annotate): update slash command description, align fetch log messages

- OpenCode plannotator-annotate.md description now mentions HTML/URL
- Align fetch progress messages across all three clients: all now show
  "(via Jina Reader)" or "(via fetch+Turndown)" consistently

For provenance purposes, this commit was AI assisted.

* fix(annotate): skip conversion for .md URLs, wikilink HTML targets, cleanup

- URLs ending in .md/.mdx are fetched raw — no Jina, no Turndown.
  Content is already markdown. Removes text/plain from fetchViaTurndown
  content-type whitelist since .md URLs are now short-circuited.
- Wikilink regex widened to preserve .html/.htm targets instead of
  appending .md (e.g. [[page.html]] no longer becomes page.html.md)
- Remove redundant existsSync before statSync in OpenCode handler

For provenance purposes, this commit was AI assisted.

* test(annotate): add htmlToMarkdown conversion tests

Tests cover the core conversion utility that all three clients depend on:
- Basic HTML → markdown (headings, paragraphs, links, code blocks)
- Tables with and without <thead> (the GFM plugin bug that was caught)
- Script/style/noscript stripping
- Strikethrough (GFM)
- Empty HTML handling
- Dangerous links preserved (sanitization is in the renderer, not here)

For provenance purposes, this commit was AI assisted.

* fix(annotate): check content-type before treating .md URLs as raw markdown

URLs ending in .md/.mdx (e.g. GitHub's viewer page for README.md)
may return HTML instead of raw markdown. fetchRawText now checks the
response content-type — if the server returns HTML, returns null so
the caller falls through to Jina/Turndown for proper conversion.

For provenance purposes, this commit was AI assisted.

* fix(annotate): add SSRF redirect protection to fetchRawText

fetchRawText (for .md/.mdx URLs) was using default redirect: "follow"
with no isLocalUrl validation on redirect hops — a .md URL redirecting
to 169.254.169.254 would be followed and credentials returned as
"markdown". Now uses redirect: "manual" with per-hop isLocalUrl checks,
matching fetchViaTurndown's SSRF protection.

For provenance purposes, this commit was AI assisted.
2026-04-12 18:56:28 -07:00
Michael Ramos aa73295b8d fix(review): work around Safari scroll-reset bug with shadow DOM diffs (#540) (#547)
Safari's compositor resets scrollTop to 0 when momentum-scrolling ends
inside a container whose child is a web-component shadow DOM (the
@pierre/diffs `<diffs-container>`). The reset bypasses all JavaScript
APIs — neither scrollTo nor the scrollTop setter fires.

Add a WebKit-only scroll event listener that detects the bogus reset
(scrollTop jumping from >200 to 0 in a single event, which cannot
happen during normal scrolling) and synchronously restores the last
known good position before the browser paints the wrong frame.

Closes #540

For provenance purposes, this commit was AI assisted.
2026-04-12 16:55:11 -07:00
Michael Ramos 8ee7c6b99f fix(ui): restore triple-click paragraph selection (#544) (#546)
Switch outside-click dismiss from pointerdown to mousedown and skip
on multi-click (event.detail >= 2).

The capture-phase pointerdown listener from useDismissOnOutsideAndEscape
was calling handleToolbarClose on the 3rd click of a triple-click,
which removed the word <mark> and normalised text nodes.  That DOM
mutation between pointerdown and mousedown reset the browser's
click-count tracking, so mousedown fired with detail=1 instead of
detail=3 — placing a cursor instead of selecting the paragraph.

Using mousedown instead of pointerdown because MouseEvent.detail is
spec-guaranteed to carry the click count (UI Events spec), whereas
the Pointer Events spec says PointerEvent.detail SHOULD be 0.

Multi-click mousedowns are part of an active selection gesture; the
web-highlighter CREATE handler already cleans up stale pending
highlights when a new selection commits, so the eager dismiss is
unnecessary.

Side-benefit: touch scroll gestures no longer dismiss the toolbar
(browsers suppress compatibility mousedown for scrolls); only taps
dismiss.  closeOnScrollOut already handles the anchor-scrolled-away
case.

Regression introduced in 39b63c9.
Fixes #544

For provenance purposes, this commit was AI assisted.
2026-04-12 10:51:40 -07:00
Michael Ramos 3f3b0f63cc fix: pin Bun to 1.3.11 to fix macOS binary codesign regression (Bun 1.3.12)
Bun 1.3.12 introduced a regression where cross-compiled macOS binaries
lose their ad-hoc linker signature, causing macOS Sequoia to SIGKILL
them immediately. Pin bun-version to 1.3.11 across all three workflow
jobs (test, build, npm-publish) until the Bun issue is resolved.

Fixes #541

Bumps version to 0.17.9.
v0.17.9
2026-04-11 12:00:07 -07:00
Michael Ramos 6677e3f280 chore: bump version to 0.17.8 v0.17.8 2026-04-10 17:27:09 -07:00
Michael Ramos 171691c197 fix(annotate): include original file annotations when submitting from linked doc view (#536)
* fix(annotate): include original file annotations when submitting from linked doc view

When using `plannotator annotate` on a file with markdown links, annotations
on the original file were silently dropped if the user clicked "Send
Annotations" while viewing a linked document. The root cause was that
`getDocAnnotations()` only read from `docCache` (previously-visited linked
docs) and the current linked doc — it never read from `savedPlanState`, where
the original file's annotations are stashed during navigation.

This adds a `sourceFilePath` option to `useLinkedDoc` so the hook can key the
stashed annotations in the returned Map. Also updates `docAnnotationCount` in
`open()` so button visibility and exit warnings reflect reality immediately,
not only after calling `back()`.

Closes #535

For provenance purposes, this commit was AI assisted.

* fix(annotate): include docCache in count when re-entering linked doc navigation

The first branch of open() set docAnnotationCount from only the original
file's annotations, ignoring any linked docs already cached from prior
navigation. After original → linkedA → back → linkedB, the count dropped
to 0 if the original had no annotations, hiding the Send Annotations button
despite linkedA's annotations sitting in docCache.

Also adds defensive spread copies for savedPlanState arrays in
getDocAnnotations() to match the hook's existing pattern.

For provenance purposes, this commit was AI assisted.

* fix(annotate): exclude destination doc from docAnnotationCount to prevent double-counting

When navigating to a previously-cached linked doc, the destination's
cached annotations were included in docAnnotationCount AND loaded into
allAnnotations, causing the exit warning to report an inflated count.
Skip the destination filepath when summing the non-active total.

For provenance purposes, this commit was AI assisted.

* fix(annotate): treat backlinks to source file as back() navigation

When a linked document contains a link back to the source file (e.g.,
original.md → design.md → backlink to original.md), opening it as a
linked doc created two competing Map entries for the same filepath in
getDocAnnotations(). The empty linked-doc entry overwrote the stashed
annotations, silently dropping them.

Now detects when the resolved destination matches sourceFilePath and
routes through back() instead, which caches the current linked doc
and restores the source file with its annotations intact.

For provenance purposes, this commit was AI assisted.
2026-04-10 17:13:16 -07:00
Michael Ramos 0287b96b63 feat(review): configurable default diff type (#531)
feat(review): configurable default diff type with first-run setup

Add `defaultDiffType` as a persistent user setting (cookie + config.json) with 'unstaged' as the default, matching `git diff` semantics. A first-run setup dialog prompts users to choose their preferred default on first review session. The setting is also available in Settings > Display.

Entry points (hook, opencode, pi-extension) read the config via `resolveDefaultDiffType()` instead of hardcoding. The setup dialog applies the chosen diff type to the active review immediately. P4 users are excluded from the Git-specific dialog.

Based on the community contribution in #521 by Hendrik Richert.

Co-authored-by: Hendrik Richert <hendrik.richert@swisscom.com>
2026-04-10 14:54:21 -07:00
Vladyslav Hrabovyi 3b1b3317ae feat(review,annotate): add Close button to exit sessions without feedback (#523)
Adds a Close button to review and annotation sessions so users can exit
cleanly without sending feedback or killing the agent. Works across all
agent origins and includes a warning dialog when annotations would be lost.

Fixes #522

Co-authored-by: gwynnnplaine <vladyslav.hrabovyii@gmail.com>
2026-04-09 19:22:01 -07:00
Michael Ramos 062106ff90 fix: improve markdown rendering and bullet alignment (#530)
* fix: pin bullet markers to top of multi-line list items

- Add `items-start` to list item flex container so markers align to the
  first line instead of centering vertically across the full item height
- Use consistent bullet glyph (•) across all nesting levels
- Add test fixture 10 covering all bullet/list types and inline gap cases

For provenance purposes, this commit was AI assisted.

* fix: improve inline markdown rendering

- Add strikethrough support (~~text~~)
- Fix ***bold italic*** by checking triple-asterisk before double
- Nudge checkbox icons down 3px to align with text baseline

For provenance purposes, this commit was AI assisted.

* fix: add backslash escaping to inline markdown renderer

- Add \* \_ \` \[ \~ \\ escape sequences — consume backslash and emit literal character
- Add \ to nextSpecial scanner so the escape handler fires correctly mid-text

For provenance purposes, this commit was AI assisted.

* fix: add autolink support to inline markdown renderer

- Handle <https://url> as clickable external links
- Handle <email@domain.com> as mailto links
- Add < to nextSpecial scanner so autolinks are detected mid-text

For provenance purposes, this commit was AI assisted.

* chore: remove HTML entities from test fixture

Not a supported feature — matches Obsidian behavior.

For provenance purposes, this commit was AI assisted.

* fix: prevent empty DocBadges wrapper in sticky header row layout

In row layout, check hasPreviousVersion && planDiffStats (what
PlanDiffBadge actually needs) instead of onPlanDiffToggle (always
truthy). Prevents an empty wrapper div that created phantom width
via gap-x-3 in the sticky bar.

For provenance purposes, this commit was AI assisted.
2026-04-09 16:44:31 -07:00
Michael Ramos bac424d056 chore: bump version to 0.17.7
For provenance purposes, this commit was AI assisted.
v0.17.7
2026-04-09 09:35:27 -07:00
Michael Ramos 93b09c7dc2 chore: bump version to 0.17.6
For provenance purposes, this commit was AI assisted.
v0.17.6
2026-04-09 08:05:34 -07:00
Michael Ramos 32fc0f92b7 docs: move verification details to dedicated reference page
The installation page was bloated with 55 lines of SLSA/SHA256
verification details before users could see agent setup instructions.
Moved to /docs/reference/verifying-your-install/ with a one-line link.

For provenance purposes, this commit was AI assisted.
2026-04-09 07:39:05 -07:00
Michael Ramos ed540dd79d fix: add OpenCode cache clearing to install.cmd
Windows CMD install script had no cache busting at all — OpenCode
users on CMD stayed on stale plugin versions indefinitely.

For provenance purposes, this commit was AI assisted.
2026-04-09 07:23:42 -07:00