@narumitw/pi-firecrawl 0.49.3 → 0.50.1

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
@@ -15,9 +15,10 @@ Use it to give your AI coding agent reliable web research capabilities for docum
15
15
  - Search the web and optionally scrape search result pages.
16
16
  - Supports Firecrawl API endpoint overrides.
17
17
  - Shows statusline activity only while Firecrawl tools are running.
18
- - Provides a `/firecrawl` menu with configuration help and tool controls.
18
+ - Keeps one loader tool active and exposes matching Firecrawl capabilities only when needed.
19
+ - Provides a `/firecrawl` menu with configuration help and availability controls.
19
20
  - Uses `@narumitw/pi-tui-kit` for width-safe menus and individual tool selection.
20
- - Persists the selected Firecrawl tools across Pi restarts.
21
+ - Persists the Firecrawl lazy-load catalog across Pi restarts.
21
22
  - Bounds tool output to Pi's 50 KB or 2,000-line limit while preserving oversized responses in private temporary files.
22
23
  - Never logs, displays, or stores your Firecrawl API key.
23
24
 
@@ -36,9 +37,13 @@ FIRECRAWL_API_KEY=fc-... pi -e npm:@narumitw/pi-firecrawl
36
37
  Try this package locally from the repository root:
37
38
 
38
39
  ```bash
39
- FIRECRAWL_API_KEY=fc-... pi -e ./extensions/pi-firecrawl
40
+ FIRECRAWL_API_KEY=fc-... pi -e ./packages/pi-firecrawl
40
41
  ```
41
42
 
43
+ The package declares `dist/index.ts`, so an unbuilt local checkout must run `npm --workspace @narumitw/pi-firecrawl run build` before Pi loads the package directory.
44
+
45
+ `just try firecrawl` runs that build automatically.
46
+
42
47
  ## ⚙️ Configuration
43
48
 
44
49
  Set a Firecrawl API key before running Pi:
@@ -57,13 +62,40 @@ export FIRECRAWL_API_URL=https://api.firecrawl.dev/v1
57
62
 
58
63
  ## 🛠️ Pi tools
59
64
 
65
+ - `firecrawl_load` — find and load Firecrawl capabilities relevant to a web research task.
60
66
  - `firecrawl_scrape` — scrape a single URL and return requested formats such as markdown, HTML, links, screenshots, or JSON.
61
67
  - `firecrawl_crawl` — start a site crawl job and return the Firecrawl job id.
62
68
  - `firecrawl_crawl_status` — check a crawl job status and retrieve completed crawl data.
63
69
  - `firecrawl_map` — discover URLs for a site.
64
70
  - `firecrawl_search` — search the web through Firecrawl and optionally scrape result pages.
65
71
 
66
- All tools fail with a clear configuration error when `FIRECRAWL_API_KEY` is missing.
72
+ ### Lazy tool loading
73
+
74
+ All six tools are registered, but only `firecrawl_load` starts active for this extension.
75
+
76
+ The loader accepts a task-oriented `query`, filters to capabilities allowed by settings, and adds up to three matching tools by default without removing any active Pi tool.
77
+
78
+ Set `limit` from 1 to 5 to change the maximum number loaded by one call.
79
+
80
+ A general website-crawl query can load both `firecrawl_crawl` and `firecrawl_crawl_status`, while a status-specific query loads the status capability.
81
+
82
+ Loaded capability tools remain active for the session unless the user makes them unavailable through `/firecrawl`.
83
+
84
+ On reload, resume, or fork, capabilities recorded by `firecrawl_load` on the active branch are restored when the current catalog still allows them.
85
+
86
+ Pi uses native deferred tool references on compatible Anthropic and OpenAI models.
87
+
88
+ Other models receive Pi's safe fallback and see the newly active definitions in the normal tool list on the next model request.
89
+
90
+ The capability tools omit active-only prompt metadata so loading them does not rebuild the system-prompt prefix.
91
+
92
+ The saved `tools` array controls which capabilities `firecrawl_load` may expose.
93
+
94
+ An empty array leaves the loader active but makes every Firecrawl API capability unavailable.
95
+
96
+ `firecrawl_load` performs no network request and does not create response artifacts.
97
+
98
+ Every API capability fails with a clear configuration error when `FIRECRAWL_API_KEY` is missing, and the always-active loader guidance tells the agent not to retry repeatedly.
67
99
 
68
100
  Tool output is limited to 50 KB or 2,000 lines, whichever is reached first. When a response is
69
101
  truncated, the result reports the original and displayed sizes and the path to a complete temporary
@@ -78,8 +110,8 @@ are bounded in the same way.
78
110
  /firecrawl
79
111
  ```
80
112
 
81
- Opens a menu with configuration quick start, command usage, tool status, controls for enabling
82
- or disabling all Firecrawl tools, and a selector for choosing individual tools.
113
+ Opens a menu with configuration quick start, command usage, lazy-catalog status, controls for making
114
+ all Firecrawl capabilities available or unavailable, and a selector for choosing individual tools.
83
115
 
84
116
  Direct subcommands are also available:
85
117
 
@@ -97,27 +129,41 @@ Direct subcommands are also available:
97
129
  - `help` shows command usage.
98
130
  - `config` shows API-key presence and API URL without displaying the API key value.
99
131
  - `quickstart` is an alias for `config`.
100
- - `status` shows runtime tool state, persisted selection, settings file path, API-key presence,
101
- API URL, and active non-Firecrawl tool count.
102
- - `tools` opens a width-safe selector for choosing individual `firecrawl_*` tools.
132
+ - `status` shows available and loaded capability counts, loader state, the persisted catalog,
133
+ settings file path, API-key presence, API URL, and active non-Firecrawl tool count.
134
+ - `tools` opens a width-safe immediate-save selector for choosing capabilities available to lazy-load.
103
135
  - `toggle` is an alias for `tools`.
104
- - `enable` enables all `firecrawl_*` tools for future turns.
105
- - `disable` disables all `firecrawl_*` tools for future turns. The slash command remains
106
- available.
136
+ - `enable` makes all five API capabilities available but leaves newly available definitions deferred.
137
+ - `disable` makes all five API capabilities unavailable and unloads affected active definitions.
138
+ The slash command and `firecrawl_load` remain available.
139
+
140
+ The menu, `tools`, `help`, `config`, `quickstart`, and `status` routes require TUI or RPC mode so their
141
+ results are observable.
107
142
 
108
- The selected tool names are saved to:
143
+ Print and JSON modes reject those routes and unknown commands explicitly instead of entering
144
+ unavailable UI or silently notifying a no-op channel.
145
+
146
+ The deterministic `enable` and `disable` routes remain available in every mode.
147
+
148
+ Tool-selector toggles save immediately in user action order.
149
+
150
+ Done, Escape, or cancellation closes the selector without undoing changes that were already saved.
151
+
152
+ The available capability names are saved to:
109
153
 
110
154
  ```text
111
155
  ${PI_CODING_AGENT_DIR:-~/.pi/agent}/pi-firecrawl.json
112
156
  ```
113
157
 
114
- When the file is missing or invalid, the extension preserves Pi's current active-tool policy
115
- instead of enabling tools by itself. A valid saved selection is restored on Pi startup and
116
- `/reload`. A missing file is created by the first successful selection change. Within one Pi process, selection saves run in invocation order, reread the latest valid document, and preserve unknown fields. Malformed JSON
117
- or invalid recognized fields block the save without replacement; a failed save restores the prior
118
- Firecrawl tool selection while preserving other extensions' current tools. The settings file
119
- stores only tool names and a timestamp; it never stores `FIRECRAWL_API_KEY`, request headers, or
120
- other secrets.
158
+ When the file is missing or invalid, the extension preserves Pi's current Firecrawl availability
159
+ policy instead of replacing it. An unsaved catalog remains stable across runtime reloads. A valid
160
+ saved catalog is restored on Pi startup and `/reload`, while its capability definitions remain
161
+ deferred. A missing file is created by the first successful
162
+ availability change. Within one Pi process, catalog saves run in invocation order, reread the latest
163
+ valid document, and preserve unknown fields. Malformed JSON or invalid recognized fields block the
164
+ save without replacement; a failed save restores both the prior availability and loaded capability
165
+ state while preserving other extensions' active tools. The settings file stores only tool names and
166
+ a timestamp; it never stores `FIRECRAWL_API_KEY`, request headers, or other secrets.
121
167
 
122
168
  Compatibility: older versions used `pi-firecrawl-settings.json`. A legacy-only file remains
123
169
  readable with a warning and is never modified automatically; rename it to `pi-firecrawl.json`.
@@ -168,11 +214,15 @@ Start a crawl with markdown extraction:
168
214
  ## 🗂️ Package layout
169
215
 
170
216
  ```txt
171
- extensions/pi-firecrawl/
217
+ packages/pi-firecrawl/
218
+ ├── dist/ # Generated TypeScript runtime loaded by Jiti
219
+ ├── scripts/
220
+ │ └── build-runtime.mjs # Deterministic runtime builder and boundary validator
172
221
  ├── src/
173
- │ ├── index.ts # Pi package entrypoint
174
- │ ├── firecrawl.ts # Extension registration and command orchestration
175
- │ └── *.ts # Package-local client, settings, selector, and tool modules
222
+ │ ├── index.ts # Pi package entrypoint
223
+ │ ├── firecrawl.ts # Extension registration and command orchestration
224
+ │ ├── lazy-tools.ts # Deferred capability catalog and loader tool
225
+ │ └── *.ts # Package-local client, settings, selector, and tool modules
176
226
  ├── README.md
177
227
  ├── LICENSE
178
228
  ├── tsconfig.json
@@ -181,6 +231,8 @@ extensions/pi-firecrawl/
181
231
 
182
232
  `index.ts` is the Pi entrypoint and forwards to `firecrawl.ts`; the other source modules are internal.
183
233
 
234
+ The generated runtime is built from the authoritative `src/index.ts` graph and does not import back into `src`.
235
+
184
236
  ## 🔎 Keywords
185
237
 
186
238
  Pi extension, Pi coding agent, Firecrawl, web scraping, web crawling, URL discovery, web search, markdown extraction, AI research agent, TypeScript Pi tools.