refactor: monorepo adapter separation (clis/ at root)#782
Merged
Conversation
…aration Separates CLI adapters from the core runtime to prepare for independent adapter distribution via postinstall fetch. Key changes: - Move src/clis/ → clis/ (adapters at repo root) - Change tsconfig rootDir from "src" to "." so tsc compiles both - Create root-level shim files (registry.ts, errors.ts, etc.) so adapter relative imports (../../registry.js) resolve correctly - Update build-manifest.ts, main.ts paths for new dist/src/ structure - Expand ensureUserCliCompatShims() to cover all adapter import targets (types, utils, logger, launcher, browser/*, download/*, pipeline/*) - Add scripts/fetch-adapters.js postinstall for ~/.opencli/clis/ sync - Update vitest.config.ts adapter test paths - Add package.json files field to exclude adapters from npm package Official adapter files are unconditionally overwritten on update; user-created files not in the manifest are preserved.
…adapters - Add dist/clis/ and dist/cli-manifest.json to package.json files field so built-in adapters and manifest ship with the npm package - Replace execSync with execFileSync to prevent command injection - Add version check to skip redundant adapter fetches - Track tmpRoot explicitly for reliable cleanup
…tch, first-run fallback 1. Manifest-based update strategy: - Read old manifest to identify previously-official files - Clean up files removed upstream (in old manifest but not new) - User-created files (never in any manifest) remain untouched 2. Only run fetch-adapters on global install (npm_config_global=true) or explicit OPENCLI_FETCH=1, preventing heavy side effects for local/dev installs 3. First-run fallback in discovery.ts: - ensureUserAdapters() checks for adapter-manifest.json - If missing and ~/.opencli/clis/ is empty, spawns fetch-adapters.js - Guarantees adapters are available even with --ignore-scripts
Adapters already ship in the npm package (dist/clis/), so there's no need to clone from GitHub. Copy directly from the installed package: - Eliminates git, curl, tar dependencies - No network calls in postinstall - No timeout/offline issues - Version always matches the installed CLI - ~65 lines of clone/download code replaced by one cpSync loop
2 tasks
jackwener
added a commit
that referenced
this pull request
Apr 4, 2026
check-doc-coverage.sh still referenced src/clis/ after PR #782 moved adapters to root clis/. This caused CI to fail with "0/1 documented".
jackwener
added a commit
that referenced
this pull request
Apr 4, 2026
* fix: review follow-ups — better first-run log, OPENCLI_FETCH=1 skips version check - Clarify first-run log message: "copying adapters (one-time setup)" - Add comment explaining why scriptPath uses two levels of ../ - OPENCLI_FETCH=1 now bypasses version-skip to allow forced refresh * fix: update doc-coverage script path after clis/ move check-doc-coverage.sh still referenced src/clis/ after PR #782 moved adapters to root clis/. This caused CI to fail with "0/1 documented". * fix: resolve package root dynamically for symlink and first-run paths The symlink at ~/.opencli/node_modules/@jackwener/opencli pointed to dist/ instead of the package root in prod mode, breaking user TS CLIs that import from '@jackwener/opencli/registry'. The first-run scriptPath also resolved incorrectly in dev mode. Extract findPackageRoot() that walks up to find package.json, fixing both paths for dev (src/) and prod (dist/src/) layouts.
jackwener
added a commit
to gucasbrg/opencli
that referenced
this pull request
Apr 4, 2026
- Rebase onto main after clis/ move (PR jackwener#782) - Remove installInterceptor calls (no longer used after waitForCapture removal) - Change strategy from INTERCEPT to PUBLIC (browser: true) to match actual behavior - Improve polling loop readability
jackwener
added a commit
that referenced
this pull request
Apr 4, 2026
* fix(36kr): replace waitForCapture with DOM polling for search/hot waitForCapture(6) always times out on 36kr because the API intercept never captures a matching request. However, the DOM is already fully rendered with search/hot results by the time the timeout fires. Replace the 6-second intercept wait with a DOM polling loop that checks for article links (a[href*="/p/"]) every 300ms, returning immediately once content is available (typically ~1s vs 6s timeout + error). Tested on opencli 1.6.2 with both CDP and Browser Bridge modes. * fix: rebase onto main, remove unused interceptor, fix strategy - Rebase onto main after clis/ move (PR #782) - Remove installInterceptor calls (no longer used after waitForCapture removal) - Change strategy from INTERCEPT to PUBLIC (browser: true) to match actual behavior - Improve polling loop readability --------- Co-authored-by: buruguo <buruguo@lambdafintech.com> Co-authored-by: jackwener <jakevingoo@gmail.com>
jackwener
added a commit
to linxule/opencli
that referenced
this pull request
Apr 4, 2026
New adapter files were created at src/clis/lesswrong/ but PR jackwener#782 moved all adapters to root clis/. Move to correct location.
jackwener
added a commit
that referenced
this pull request
Apr 4, 2026
* feat(lesswrong): add LessWrong adapter 15 commands for the LessWrong rationality and AI alignment community: - Post listings: curated, frontpage, new, top, top-week/month/year - Content: read (full post), comments, shortform (quick takes) - Discovery: tag, tags, sequences - Users: user (profile), user-posts All commands use the public GraphQL API (no browser required). Time-filtered views use the `after` date parameter. Tag lookup resolves slugs to IDs via the `tagBySlug` view. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: move lesswrong adapter to clis/ (post PR #782 restructure) New adapter files were created at src/clis/lesswrong/ but PR #782 moved all adapters to root clis/. Move to correct location. --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: jackwener <jakevingoo@gmail.com>
jackwener
added a commit
to zhangtaopy/opencli
that referenced
this pull request
Apr 4, 2026
Post PR jackwener#782 restructure: adapter files live at root clis/, not src/clis/.
jackwener
added a commit
that referenced
this pull request
Apr 4, 2026
* feat(hupu): add hupu cli adapter * fix(hupu): prevent detail from returning the wrong thread * refactor: deduplicate shared utilities in hupu adapter - Merge postHupuJson and postHupuReplyJson into single function with mode parameter - Move stripHtml and decodeHtmlEntities to utils.ts, remove duplicate definitions * fix(hupu): add mentions command * fix: move mentions.ts to clis/hupu/, remove src/clis/hupu duplicates Post PR #782 restructure: adapter files live at root clis/, not src/clis/. --------- Co-authored-by: jackwener <jakevingoo@gmail.com>
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/clis/→ rootclis/to separate adapters from CLI runtime../../registry.js) resolve correctly without modifying any adapter codetsconfig.jsonrootDir from"src"to"."— output becomesdist/src/+dist/clis/ensureUserCliCompatShims()to cover all 14 adapter import targetsscripts/fetch-adapters.jspostinstall script for~/.opencli/clis/sync (git sparse-checkout with tarball fallback)filesfield in package.json to exclude adapters from npm packageUpdate Strategy
adapter-manifest.json) are unconditionally overwritten on updateTest plan
tsccompiles cleanlynpm run build(clean-dist + tsc + clean-yaml + copy-yaml + build-manifest) succeedsdist/src/main.js) runs correctly