node-pagefind 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,84 +1,87 @@
1
- # pr-digest
1
+ # node-pagefind
2
2
 
3
- A CLI tool for generating comprehensive digests of GitHub pull requests, optimized for AI agent handoffs with full timeline context.
3
+ A Node.js CLI and SDK for querying [Pagefind](https://pagefind.app/) search indices. Supports both local and remote data sources with automatic version-keyed caching.
4
4
 
5
5
  ## Features
6
6
 
7
- - Fetches all PR information (title, description, branches)
8
- - Retrieves complete timeline including reviews, comments, and status changes
9
- - Formats output using markdown-factory for clean, readable output
10
- - Includes AI agent instructions based on timeline analysis
11
- - Flexible authentication (args, env vars, or gh CLI)
12
- - Auto-detects PR from current git repository using Octokit
7
+ - Query any Pagefind index from Node.js — local or remote
8
+ - CLI with `search`, `filters`, and `info` subcommands
9
+ - Programmatic SDK via cli-forge's `.sdk()` method
10
+ - `PagefindClient` class for fine-grained lifecycle control
11
+ - Version-keyed caching in `/tmp/node-pagefind/` with automatic invalidation
12
+ - Optional `--cachePath` for custom cache directories (bypasses version management)
13
13
 
14
14
  ## Installation
15
15
 
16
16
  ```bash
17
- npm install -g pr-digest
17
+ npm install node-pagefind
18
18
  ```
19
19
 
20
- ## Usage
20
+ ## CLI Usage
21
21
 
22
- ### Auto-detect PR from current git repository
22
+ ### Search a remote site
23
23
 
24
24
  ```bash
25
- pr-digest digest
25
+ node-pagefind search "react hooks" --url nx.dev/docs --limit 5 --excerpt
26
26
  ```
27
27
 
28
- When run from a GitHub repository, `pr-digest` will:
28
+ ### Search a local build
29
29
 
30
- 1. Detect the GitHub repository from `git remote get-url origin`
31
- 2. Get the current branch name from `git branch --show-current`
32
- 3. Search GitHub for an open PR with a matching head branch
33
- 4. Generate a digest for that PR
30
+ ```bash
31
+ node-pagefind search "getting started" --path ./dist
32
+ ```
34
33
 
35
- You can still explicitly provide owner/repo/pr if needed:
34
+ ### List available filters
36
35
 
37
- - `--owner` and `--repo` override the detected GitHub repository
38
- - `--pr` overrides the auto-detected PR number
36
+ ```bash
37
+ node-pagefind filters --url nx.dev/docs
38
+ ```
39
39
 
40
- ### Using a GitHub PR URL
40
+ ### Show index info
41
41
 
42
42
  ```bash
43
- pr-digest digest https://github.com/owner/repo/pull/123
43
+ node-pagefind info --url nx.dev/docs
44
44
  ```
45
45
 
46
- ### With output file
46
+ ### Custom cache directory
47
47
 
48
48
  ```bash
49
- pr-digest digest --url https://github.com/owner/repo/pull/123 --output digest.md
49
+ node-pagefind search "query" --url nx.dev/docs --cachePath ./my-cache
50
50
  ```
51
51
 
52
- ### Authentication
52
+ ## SDK Usage
53
53
 
54
- The tool tries token sources in this order:
54
+ The package exports a cli-forge SDK where each subcommand becomes a typed async function:
55
55
 
56
- 1. `--token` CLI argument
57
- 2. `GH_TOKEN` environment variable
58
- 3. `GITHUB_TOKEN` environment variable
59
- 4. `gh auth token` command (requires GitHub CLI)
56
+ ```typescript
57
+ import { sdk } from 'node-pagefind';
60
58
 
61
- ## Digest Format
59
+ const result = await sdk.search({
60
+ query: 'react hooks',
61
+ url: 'https://nx.dev/docs',
62
+ limit: 5,
63
+ });
64
+ ```
62
65
 
63
- The generated digest includes:
66
+ ## PagefindClient Usage
64
67
 
65
- - **PR Header**: Title, number, and link
66
- - **Branch Information**: Base branch (for `git diff` commands) and head branch
67
- - **Timeline Section**: Full conversation history including:
68
- - Review summary with approval statistics
69
- - Individual review comments with review states
70
- - Nx Cloud CI links (detected and highlighted)
71
- - General Comments: Issue-level comments with threaded replies
72
- - File-Specific Comments\*\*: Review comments grouped by file with line numbers and ranges
73
- - **AI Agent Instructions**: Context-aware guidelines based on timeline data
68
+ For more control over initialization and reuse across multiple queries:
74
69
 
75
- > **Timeline Features:**
70
+ ```typescript
71
+ import { PagefindClient } from 'node-pagefind';
76
72
 
77
- - Shows review state (approved, changes requested, commented, dismissed, etc.)
78
- - Groups comments into threads with replies
79
- - Detects Nx Cloud CI links in review comments and highlights them
80
- - Provides review summary statistics for quick overview
81
- - Helps AI agents understand the full review conversation context
73
+ const client = new PagefindClient({ baseUrl: 'https://nx.dev/docs' });
74
+ await client.init('en');
75
+
76
+ const results = await client.search('react hooks');
77
+ const filters = await client.filters();
78
+ ```
79
+
80
+ ## Caching
81
+
82
+ By default, downloaded `pagefind.js` files are cached in `/tmp/node-pagefind/<version>/` with a `known-versions.json` map tracking which data source uses which version. If a version mismatch occurs at init time, the cache is invalidated and the client is re-downloaded automatically.
83
+
84
+ When `cachePath` is provided, the file is stored directly at `<cachePath>/pagefind.js` with no version management — useful for CI/CD or embedded use cases where you want deterministic control over the cache location.
82
85
 
83
86
  ## Development
84
87
 
@@ -91,7 +94,4 @@ npm run test
91
94
 
92
95
  # Type check
93
96
  npm run typecheck
94
-
95
- # Lint
96
- npm run lint
97
97
  ```