Skip to content

refactor: rename datasource command group to webscraper#184

Merged
CarmenDou merged 2 commits into
mainfrom
feat/apify-integration
Jun 27, 2026
Merged

refactor: rename datasource command group to webscraper#184
CarmenDou merged 2 commits into
mainfrom
feat/apify-integration

Conversation

@CarmenDou

@CarmenDou CarmenDou commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Renames the CLI command group datasourcewebscraper (follow-up to the merged #179). The integration is web-scraping-only, so webscraper reads truer than the generic datasource.

Changes

  • Command: insforge datasource apify connect/logininsforge webscraper apify connect/login (provider sub-level apify kept for future providers e.g. Firecrawl)
  • Directory src/commands/datasource/src/commands/webscraper/, registerWebscraperCommands
  • Backend API path consumed by the token fetch + route-level-404 handling: /api/datasources/apify/*/api/webscraper/apify/*
  • README "Data Sources" section → "Web Scraper"
  • All user-facing command strings updated

Verification

  • npm run build ✓, npx tsc --noEmit clean for changed files
  • 46/46 vitest pass (apify, apify-bridge, apify-token, skills)
  • insforge webscraper apify --help works; old datasource command removed

Cross-repo dependency

Depends on the InsForge OSS backend renaming the route mount /datasources/webscraper (PR forthcoming) and the insforge-skills web-scraper rename. Merge together — the CLI now calls /api/webscraper/apify/token, which the renamed backend serves.

🤖 Generated with Claude Code


Summary by cubic

Renamed the CLI datasource group to webscraper and updated API paths, docs, and messages. The connect flow now preserves detailed remediation from the auth bridge on failure.

  • Refactors

    • Commands: insforge webscraper apify connect and ... login; removed the datasource group.
    • Code: moved src/commands/datasource/* to src/commands/webscraper/*; registerWebscraperCommands replaces registerDatasourceCommands.
    • API: switched token fetch and 404 handling to /api/webscraper/apify/*.
    • Docs/UX: README retitled to “Web Scraper”; user-facing strings updated. Connect now surfaces the bridge’s specific remediation instead of a generic login hint.
  • Migration

    • Use insforge webscraper apify connect and insforge webscraper apify login going forward.
    • Requires backend exposing /api/webscraper/apify/*; older/self-hosted backends will show “web scraper not available.”

Written for commit 2341f82. Summary will update on new commits.

Review in cubic

Note

Rename datasource CLI command group to webscraper

  • Renames the top-level CLI group from datasource to webscraper in src/index.ts, so all Apify commands now live under insforge webscraper apify.
  • Updates the API endpoint in src/lib/api/apify-token.ts from /api/datasources/apify/token to /api/webscraper/apify/token.
  • Updates route-level 404 detection in src/lib/api/oss.ts to match /api/webscraper paths, with a new error message referencing "web scraper".
  • Updates all user-facing remediation messages, docs, and test fixtures to reference webscraper instead of datasource.
  • Risk: the old /api/datasources/apify/token endpoint and datasource CLI commands are no longer referenced; clients using the old path or command will not get the updated error handling.

Macroscope summarized 2341f82.

Summary by CodeRabbit

  • New Features
    • Renamed the integration flow from Data Sources to Web Scraper in the CLI and docs, including the new webscraper command namespace (Apify first).
  • Bug Fixes
    • Updated token, connection, and login guidance so errors direct to the correct webscraper apify connect/login commands.
    • Improved backend “not available” messaging for Web Scraper–related 404 responses.
  • Documentation
    • Refreshed README integration instructions and examples to match the Web Scraper flow.
  • Tests
    • Adjusted Apify token test expectations for Web Scraper–specific error messaging.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The CLI and docs rename the Apify integration from datasource to webscraper, update command wiring for the new namespace, and switch Apify token and connection error handling to the new web scraper route and messages.

Changes

Web scraper CLI and Apify integration rename

Layer / File(s) Summary
Command surface and docs
README.md, src/commands/webscraper/index.ts, src/index.ts
The top-level command registration and README examples now use webscraper for Apify integration commands and descriptions.
Apify auth bridge messages
src/commands/webscraper/apify/connect.ts, src/commands/webscraper/apify/login.ts, src/lib/apify-bridge.ts, src/lib/api/apify.ts
The Apify connect/login warnings, bridge errors, and connection timeout message now reference webscraper apify connect/login.
Token endpoint and backend 404 handling
src/lib/api/apify-token.ts, src/lib/api/apify-token.test.ts, src/lib/api/oss.ts
The Apify token fetch uses /api/webscraper/apify/token, the 404 remap points to the new connect command, and backend route 404s add a web scraper-specific message.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • InsForge/CLI#179: Introduces the Apify integration wiring and auth flow that this PR renames and retargets to webscraper.

Suggested reviewers

  • jwfing

Poem

A bunny hopped through CLI fields,
And swapped old names for webscraper shields.
connect and login now sing anew,
While tokens hop the route marked true.
🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: renaming the CLI command group from datasource to webscraper.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/apify-integration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jun 27, 2026

Copy link
Copy Markdown

Greptile Summary

This PR renames the datasource CLI command group to webscraper and updates all related API paths (/api/datasources/apify/*/api/webscraper/apify/*), user-facing strings, error messages, and README documentation to match.

  • Command rename: insforge datasource apify connect/logininsforge webscraper apify connect/login; the old datasource command is removed entirely, so any scripts using the old name will break.
  • API path change: All OSS backend calls now target /api/webscraper/apify/token; the route-level 404 guard in oss.ts is updated to match, and the existing error handling for "not_connected" vs. route-miss 404s is preserved correctly.
  • New error handling: connect.ts adds logic to detect a specific bridge error by substring-matching the error message, then surfaces it directly rather than showing the generic fallback; this works correctly today but is fragile to future message changes.

Confidence Score: 5/5

Safe to merge once the backend PR renaming the route mount from /datasources to /webscraper is coordinated and lands together.

The change is a consistent rename across all touched files with no logic regressions. The route-level 404 guard, the not_connected vs. route-miss disambiguation, and the auth bridge error flow are all preserved correctly. The one new piece of logic (substring-matching a bridge error message to select the user-facing warning) works correctly for the current error set; it is a maintenance concern, not a current defect.

No files require special attention beyond ensuring the backend route rename lands in the same deploy window.

Important Files Changed

Filename Overview
src/commands/webscraper/apify/connect.ts Renamed from datasource; all user-facing strings updated. New catch block logic detects error type by substring match — correct now but fragile long-term.
src/commands/webscraper/apify/login.ts Straightforward rename; command string and JSDoc updated cleanly.
src/commands/webscraper/index.ts Function renamed to registerWebscraperCommands; description strings updated; no logic changes.
src/index.ts Import and command registration updated to webscraper; clean change.
src/lib/api/apify-token.ts API path changed from /api/datasources/apify/token to /api/webscraper/apify/token; error messages updated; logic unchanged.
src/lib/api/apify-token.test.ts Error message strings in test fixtures updated to match new path; test logic unchanged and all 4 cases still cover the correct branches.
src/lib/api/oss.ts Route-level 404 guard updated from /api/datasources to /api/webscraper; user message reworded accordingly.
src/lib/apify-bridge.ts JSDoc comment and two error message strings updated; no logic changes.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant User
    participant CLI as insforge webscraper apify
    participant OSS as OSS Backend /api/webscraper
    participant Apify as Apify API

    User->>CLI: connect
    CLI->>OSS: POST /api/webscraper/apify/cli-start
    OSS-->>CLI: "{ type: "authorize", authorizeUrl }"
    CLI->>User: Open browser to authorizeUrl
    User->>Apify: OAuth authorize
    CLI->>OSS: Poll /api/webscraper/apify/connection
    OSS-->>CLI: "{ kind: "connected", connection }"
    CLI->>OSS: GET /api/webscraper/apify/token
    OSS-->>CLI: "{ accessToken }"
    CLI->>Apify: apify login --token token
    Apify-->>CLI: Logged in
    CLI->>User: Apify connected

    User->>CLI: login
    CLI->>OSS: GET /api/webscraper/apify/token
    OSS-->>CLI: "{ accessToken }"
    CLI->>Apify: apify login --token token
    Apify-->>CLI: Logged in
    CLI->>User: Authenticated
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant User
    participant CLI as insforge webscraper apify
    participant OSS as OSS Backend /api/webscraper
    participant Apify as Apify API

    User->>CLI: connect
    CLI->>OSS: POST /api/webscraper/apify/cli-start
    OSS-->>CLI: "{ type: "authorize", authorizeUrl }"
    CLI->>User: Open browser to authorizeUrl
    User->>Apify: OAuth authorize
    CLI->>OSS: Poll /api/webscraper/apify/connection
    OSS-->>CLI: "{ kind: "connected", connection }"
    CLI->>OSS: GET /api/webscraper/apify/token
    OSS-->>CLI: "{ accessToken }"
    CLI->>Apify: apify login --token token
    Apify-->>CLI: Logged in
    CLI->>User: Apify connected

    User->>CLI: login
    CLI->>OSS: GET /api/webscraper/apify/token
    OSS-->>CLI: "{ accessToken }"
    CLI->>Apify: apify login --token token
    Apify-->>CLI: Logged in
    CLI->>User: Authenticated
Loading

Reviews (2): Last reviewed commit: "Preserve bridge remediation on connect f..." | Re-trigger Greptile

Comment thread src/lib/api/apify-token.ts Outdated

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/commands/webscraper/apify/connect.ts`:
- Around line 115-119: The catch in connect() is collapsing every
runApifyAuthBridge() failure into the generic “run apify login” warning, which
loses the bridge-specific next step. Update the catch around runApifyAuthBridge
so it distinguishes the malformed-token error coming from the Apify bridge in
apify-bridge.ts and shows the correct follow-up for connect, while keeping the
existing generic message for other failures. Use the existing connect() flow and
clack.log.warn path to preserve the appropriate remediation text.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 218368bc-7554-46e9-9141-1185073fa2e0

📥 Commits

Reviewing files that changed from the base of the PR and between c6dabda and 98ae6ee.

📒 Files selected for processing (10)
  • README.md
  • src/commands/webscraper/apify/connect.ts
  • src/commands/webscraper/apify/login.ts
  • src/commands/webscraper/index.ts
  • src/index.ts
  • src/lib/api/apify-token.test.ts
  • src/lib/api/apify-token.ts
  • src/lib/api/apify.ts
  • src/lib/api/oss.ts
  • src/lib/apify-bridge.ts

Comment thread src/commands/webscraper/apify/connect.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 issues found across 10 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/commands/webscraper/apify/connect.ts Outdated
Comment thread src/lib/api/apify-token.ts

@jwfing jwfing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM - approved.

@CarmenDou CarmenDou merged commit 96aa4e3 into main Jun 27, 2026
4 checks passed
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