Skip to content

Add text HTTP transformers and HTML metadata utilities - #43

Merged
Kralizek merged 26 commits into
masterfrom
feature/html-open-graph
Oct 1, 2026
Merged

Kralizek merged 26 commits into
masterfrom
feature/html-open-graph

Conversation

@Kralizek

@Kralizek Kralizek commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Summary

Adds the generic Hooksmith capabilities needed to compose HTML metadata enrichment without coupling provider integrations to page scraping.

@hooksmith/http

  • adds fetchText(...) for arbitrary-method text responses
  • adds getText(...) as the GET convenience transformer
  • mirrors the existing fetchJson/getJson transformer conventions
  • supports headers, arbitrary request bodies, mapping, and the existing non-2xx failure behavior
  • adds focused tests for GET, arbitrary methods/body mapping, and unsuccessful responses

New @hooksmith/html

Introduces the newly registered @hooksmith/html package for HTML parsing and metadata extraction utilities.

Initial surface:

  • OpenGraphMetadata
  • parseOpenGraph() — pure pipeline transformer from HTML text to metadata
  • getOpenGraph() — convenience transformer that fetches HTML through @hooksmith/http and parses the result

The initial Open Graph parser extracts:

  • og:title
  • og:description
  • og:image
  • og:url
  • og:type
  • og:site_name

It also falls back to <title> and meta[name=description], decodes common HTML entities, and resolves relative Open Graph image/URL values when a base URL is known.

Design boundary

The intended layering is:

@hooksmith/http  -> transport / text retrieval
@hooksmith/html  -> HTML interpretation / metadata extraction
provider package -> provider-specific serialization

This deliberately keeps Open Graph discovery out of social/provider packages such as @hooksmith/bluesky.

Compatibility

Existing HTTP APIs are unchanged. The new text transformers and HTML package are additive.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Unresolved HTML parsing and redirect URL handling issues need correction before approval.

Review effort: Lite
Findings: 2 Medium severity · 2 Low severity

Open (4)
What changed in this PR

Adds text HTTP transformers and a new HTML package for Open Graph metadata extraction.

Changes:

  • Adds fetchText and getText with mapping, headers, bodies, and error handling.
  • Introduces Open Graph parsing and fetching utilities.
  • Registers the new workspace package with tests and documentation.
File Description
extensions/​http/​types.ts Defines text transformer types.
extensions/​http/​transformers.ts Implements text HTTP transformers.
extensions/​http/​mod.ts Exports the new HTTP APIs.
extensions/​http/​fetch_text_test.ts Tests text transformer behavior.
extensions/​html/​README.md Documents the HTML package.
extensions/​html/​mod.ts Implements Open Graph parsing and fetching.
extensions/​html/​mod_test.ts Tests metadata extraction.
extensions/​html/​deno.json Defines the HTML package.
deno.json Registers the HTML workspace package.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread extensions/html/mod.ts Outdated
Comment thread extensions/html/mod.ts
Comment thread extensions/html/README.md Outdated
Comment thread extensions/http/mod.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

Three unresolved moderate correctness issues remain in the HTML metadata parser.

Review effort: Lite
Findings: None

Resolved since last review (4)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Avoid extracting metadata from comments and script content

extensions/​html/​mod.ts:80

Because this regex scans raw source rather than tokenizing HTML, it also matches <meta> text inside comments or script/string content. For example, a commented-out og:title before the real tag is stored first and wins, so pages with embedded examples can return incorrect metadata. Ignore comments/script blocks or use a DOM-aware parser before extracting tags.

@Kralizek
Kralizek merged commit a6b7d99 into master Oct 1, 2026
10 checks passed
@Kralizek
Kralizek deleted the feature/html-open-graph branch October 1, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants