Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(cli): preserve per-attachment assets in verify output#430

Merged
bensonwong merged 8 commits into
mainfrom
feat/verify-preserve-attachment-assets
Apr 15, 2026
Merged

feat(cli): preserve per-attachment assets in verify output#430
bensonwong merged 8 commits into
mainfrom
feat/verify-preserve-attachment-assets

Conversation

@bensonwong
Copy link
Copy Markdown
Collaborator

Summary

  • Collects the attachments map (pageImages, originalDownload) from each verifyAttachment result and merges it into the final verify-response.json output, alongside the existing verifications map
  • Output only includes attachments when at least one attachment returned assets (no empty object noise)
  • mergedAttachments typed as Record<string, AttachmentAssets> for consistency with the parallel pattern in the second verify function
  • Updates README hero tagline

Test plan

  • Run npx deepcitation verify against a multi-attachment input; confirm verify-response.json contains both verifications and attachments keys
  • Run against an input with no attachments; confirm attachments key is absent from output
  • bun run lint passes (no new lint errors)

bensonwong and others added 4 commits April 15, 2026 14:49
Collect the attachments map (pageImages, originalDownload) from each
verifyAttachment result and merge it into the final output JSON so
callers like updateDemoVerifications.ts can enrich demo data with
page images.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Matches the identical pattern already used in the second verify
function (line 1263) instead of widening to Record<string, unknown>.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated (UTC)
agui-chat-deepcitation Ignored Ignored Preview Apr 15, 2026 11:10pm
deepcitation-langchain-rag-chat Ignored Ignored Preview Apr 15, 2026 11:10pm
mastra-rag-deepcitation Ignored Ignored Preview Apr 15, 2026 11:10pm
nextjs-ai-sdk-deepcitation Ignored Ignored Preview Apr 15, 2026 11:10pm

@claude
Copy link
Copy Markdown

claude Bot commented Apr 15, 2026

Code Review

src/cli/commands.ts — the main change

Overall: the logic is correct and mirrors the existing pattern at line 1263. A few things worth addressing:

1. Type widening on output is unnecessary

Changing the output type from a narrow literal to Record<string, unknown> to support dynamic property assignment is a common pattern but loses precision. A typed alternative avoids casting:

const output: { verifications: Record<string, unknown>; attachments?: Record<string, AttachmentAssets> } = { verifications: merged };
if (Object.keys(mergedAttachments).length > 0) output.attachments = mergedAttachments;

This keeps attachments typed all the way through to the writeFileSync call.

2. Inconsistency with the second verify function (line 1300)

The second verify function writes { verifications: merged } to verifyResponsePath without attachments, even though it also builds mergedAttachments (lines 1263–1272). The mergedAttachments there is used only for in-memory reattachPageImages/downloadUrl backfill — it never surfaces in the file.

That's a divergent output schema between the two paths. If downstream tooling reads verify-response.json and expects attachments when assets are present, callers of the second path will silently get nothing. Either:

  • Add the same conditional output.attachments write to the second function too, or
  • Add a comment in the second function explicitly noting the omission is intentional (e.g., because reattachPageImages inlines the images directly into verifications).

3. Silent key collision via Object.assign

if (result.attachments) Object.assign(mergedAttachments, result.attachments);

If two verifyAttachment calls return an overlapping key in their attachments map, the second silently wins. This is consistent with how merged verifications are handled, but worth calling out since attachments is keyed by attachmentId — collisions here would indicate a grouping bug upstream. A DEV assertion or at least a comment acknowledging the invariant ("each attachmentId appears in exactly one group") would make the intent clearer.

4. No automated test coverage

The test plan is manual-only. Given that normalizeVerifyResponse.test.ts already sets up AttachmentAssets fixtures, adding a unit test for the mergedAttachments → output.attachments conditional (both present and absent cases) would be straightforward and would prevent regressions here.


README.md

The new tagline introduces two issues:

  1. "/verify Citations" — the leading / makes this read like a CLI command fragment embedded in marketing copy. Likely unintentional.
  2. Capitalization — "Citations" with a capital C is inconsistent with the lowercase "hallucinations" on the line above.

The old tagline ("Build Trusted AI Products. / Show proof for every AI citation.") was clearer about what the product does. "Stop hallucinations" is a broader claim that doesn't reflect the tool's actual scope (citation verification, not general hallucination prevention).


Test plan note

The test plan uses bun run lint, but the repo's AGENTS.md specifies npm run check:fix then npm run lint. Minor inconsistency worth aligning.


Summary: The core logic in commands.ts is sound and consistent with the parallel pattern elsewhere. The main actionable items are: (1) address the divergent output between the two verify functions, (2) strengthen the type of output, and (3) reconsider the README tagline.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 15, 2026

✅ Playwright Test Report

Status: Tests passed

📊 Download Report & Snapshots (see Artifacts section)

What's in the Visual Snapshots

The gallery includes visual snapshots for:

  • 🖥️ Desktop showcase (all variants × all states)
  • 📱 Mobile showcase (iPhone SE viewport)
  • 📟 Tablet showcase (iPad viewport)
  • 🔍 Popover states (verified, partial, not found)
  • 🔗 URL citation variants

Run ID: 24483084563

bensonwong and others added 4 commits April 15, 2026 15:23
- Narrow output type from Record<string,unknown> to explicit shape
- Write attachments to verify-response.json in both verify paths
- Add invariant comments on Object.assign(mergedAttachments)
- Add unit tests for attachments present/absent in output file
- Fix README tagline slash and capitalisation
- Simplify quota error message to remove stale pricing copy

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- Update cliUnit.test.ts assertions to match simplified quota message
  (removed stale "Standard"/"Pro" tier copy from PaymentRequiredError)
- Fix tsconfig.jest.json: "6.0" is invalid under TS 5.9; downgrade to "5.0"
- Remove trailing blank line in markdownToHtml.ts (biome auto-fix)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The package requires typescript ^6.0.2; TS 6 requires "6.0" to silence
the moduleResolution=node10 deprecation (TS5107). The prior commit
incorrectly downgraded to "5.0" due to missing local node_modules.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@bensonwong bensonwong merged commit cfb8343 into main Apr 15, 2026
14 checks passed
@bensonwong bensonwong deleted the feat/verify-preserve-attachment-assets branch April 15, 2026 23:16
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.

1 participant