@rol1n/pi-kit 0.1.0 → 0.1.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 +33 -58
- package/ask-u-questions/README.md +26 -0
- package/{extensions/ask-u-questions → ask-u-questions}/dialog-ui.ts +23 -0
- package/{extensions/ask-u-questions → ask-u-questions}/index.ts +9 -5
- package/{extensions/ask-u-questions → ask-u-questions}/multi-choice.ts +1 -3
- package/{extensions/ask-u-questions → ask-u-questions}/single-choice.ts +1 -3
- package/{extensions/ask-u-questions → ask-u-questions}/tool-renderers.ts +1 -3
- package/ask-u-questions/types.ts +192 -0
- package/continue-signal/README.md +20 -0
- package/{extensions/continue-signal → continue-signal}/index.ts +21 -3
- package/custom-providers/README.md +20 -0
- package/{extensions/custom-providers → custom-providers}/index.ts +16 -2
- package/image-generate/README.md +25 -0
- package/{extensions/image-generate → image-generate}/index.ts +22 -2
- package/{extensions/image-generate → image-generate}/model-selector.ts +1 -1
- package/model-vision/README.md +22 -0
- package/{extensions/multi-harness → multi-harness}/README.md +3 -3
- package/oai-subquota/README.md +22 -0
- package/{extensions/oai-subquota → oai-subquota}/index.ts +16 -6
- package/{extensions/oai-subquota → oai-subquota}/snapshot.ts +127 -1
- package/{extensions/oai-subquota → oai-subquota}/ui.ts +1 -1
- package/package.json +45 -46
- package/prompt-snipaste/README.md +27 -0
- package/{extensions/prompt-snipaste → prompt-snipaste}/renderers.ts +0 -1
- package/{extensions/prompt-snipaste → prompt-snipaste}/snippets.ts +5 -2
- package/{extensions/prompt-snipaste → prompt-snipaste}/types.ts +0 -1
- package/screenshot/README.md +14 -0
- package/srp-theme/README.md +18 -0
- package/{extensions/srp-theme → srp-theme}/footer.ts +0 -1
- package/{extensions/srp-theme → srp-theme}/tps-meter.ts +0 -1
- package/{extensions/subagent → subagent}/README.md +1 -1
- package/tui-asr/README.md +21 -0
- package/{extensions/tui-asr → tui-asr}/dictation.ts +70 -3
- package/{extensions/tui-asr → tui-asr}/index.ts +2 -2
- package/{extensions/tui-asr → tui-asr}/input.ts +30 -1
- package/{extensions/tui-asr → tui-asr}/model-selector.ts +1 -1
- package/web-reach/README.md +19 -0
- package/{extensions/web-reach → web-reach}/page.ts +84 -2
- package/windows-wheel-fix/README.md +12 -0
- package/extensions/ask-u-questions/README.md +0 -32
- package/extensions/ask-u-questions/answers.ts +0 -53
- package/extensions/ask-u-questions/results.ts +0 -83
- package/extensions/ask-u-questions/schema.ts +0 -17
- package/extensions/ask-u-questions/types.ts +0 -45
- package/extensions/ask-u-questions/ui-lock.ts +0 -24
- package/extensions/continue-signal/README.md +0 -28
- package/extensions/continue-signal/renderer.ts +0 -21
- package/extensions/custom-providers/README.md +0 -28
- package/extensions/image-generate/README.md +0 -29
- package/extensions/image-generate/models.ts +0 -19
- package/extensions/model-vision/README.md +0 -28
- package/extensions/oai-subquota/README.md +0 -30
- package/extensions/oai-subquota/api.ts +0 -27
- package/extensions/oai-subquota/auth.ts +0 -34
- package/extensions/oai-subquota/cache.ts +0 -30
- package/extensions/oai-subquota/types.ts +0 -40
- package/extensions/prompt-snipaste/README.md +0 -33
- package/extensions/screenshot/README.md +0 -25
- package/extensions/srp-theme/README.md +0 -24
- package/extensions/subagent/skills/subagent/SKILL.md +0 -70
- package/extensions/tui-asr/README.md +0 -28
- package/extensions/tui-asr/audio.ts +0 -40
- package/extensions/tui-asr/clipboard.ts +0 -30
- package/extensions/tui-asr/providers.ts +0 -25
- package/extensions/web-reach/README.md +0 -37
- package/extensions/web-reach/pdf.ts +0 -42
- package/extensions/web-reach/reader.ts +0 -42
- package/extensions/windows-wheel-fix/README.md +0 -21
- /package/{extensions/custom-providers → custom-providers}/asr/handlers/dashscope.ts +0 -0
- /package/{extensions/custom-providers → custom-providers}/asr/index.ts +0 -0
- /package/{extensions/custom-providers → custom-providers}/asr/models.ts +0 -0
- /package/{extensions/custom-providers → custom-providers}/asr/types.ts +0 -0
- /package/{extensions/custom-providers → custom-providers}/chat/index.ts +0 -0
- /package/{extensions/custom-providers → custom-providers}/chat/magpie.ts +0 -0
- /package/{extensions/custom-providers → custom-providers}/chat/models.ts +0 -0
- /package/{extensions/custom-providers → custom-providers}/classifier/index.ts +0 -0
- /package/{extensions/custom-providers → custom-providers}/classifier/models.ts +0 -0
- /package/{extensions/custom-providers → custom-providers}/image/handlers/dashscope.ts +0 -0
- /package/{extensions/custom-providers → custom-providers}/image/handlers/openrouter.ts +0 -0
- /package/{extensions/custom-providers → custom-providers}/image/index.ts +0 -0
- /package/{extensions/custom-providers → custom-providers}/image/models.ts +0 -0
- /package/{extensions/custom-providers → custom-providers}/image/types.ts +0 -0
- /package/{extensions/custom-providers → custom-providers}/types.ts +0 -0
- /package/{extensions/image-generate → image-generate}/files.ts +0 -0
- /package/{extensions/memory-log → memory-log}/README.md +0 -0
- /package/{extensions/memory-log → memory-log}/agent/consolidator/prompt.ts +0 -0
- /package/{extensions/memory-log → memory-log}/agent/consolidator/tools.ts +0 -0
- /package/{extensions/memory-log → memory-log}/agent/cost.ts +0 -0
- /package/{extensions/memory-log → memory-log}/agent/index.ts +0 -0
- /package/{extensions/memory-log → memory-log}/agent/observer/prompt.ts +0 -0
- /package/{extensions/memory-log → memory-log}/agent/observer/tool.ts +0 -0
- /package/{extensions/memory-log → memory-log}/commands/compact.ts +0 -0
- /package/{extensions/memory-log → memory-log}/commands/consolidate.ts +0 -0
- /package/{extensions/memory-log → memory-log}/commands/status.ts +0 -0
- /package/{extensions/memory-log → memory-log}/config.ts +0 -0
- /package/{extensions/memory-log → memory-log}/debug-log.ts +0 -0
- /package/{extensions/memory-log → memory-log}/hooks/compaction-hook.ts +0 -0
- /package/{extensions/memory-log → memory-log}/hooks/compaction-trigger.ts +0 -0
- /package/{extensions/memory-log → memory-log}/hooks/consolidator-trigger.ts +0 -0
- /package/{extensions/memory-log → memory-log}/hooks/observer-trigger.ts +0 -0
- /package/{extensions/memory-log → memory-log}/ids.ts +0 -0
- /package/{extensions/memory-log → memory-log}/index.ts +0 -0
- /package/{extensions/memory-log → memory-log}/ledger/fold.ts +0 -0
- /package/{extensions/memory-log → memory-log}/ledger/index.ts +0 -0
- /package/{extensions/memory-log → memory-log}/ledger/pool.ts +0 -0
- /package/{extensions/memory-log → memory-log}/ledger/progress.ts +0 -0
- /package/{extensions/memory-log → memory-log}/ledger/projection.ts +0 -0
- /package/{extensions/memory-log → memory-log}/ledger/render.ts +0 -0
- /package/{extensions/memory-log → memory-log}/ledger/serialize.ts +0 -0
- /package/{extensions/memory-log → memory-log}/ledger/types.ts +0 -0
- /package/{extensions/memory-log → memory-log}/memory/index-render.ts +0 -0
- /package/{extensions/memory-log → memory-log}/memory/paths.ts +0 -0
- /package/{extensions/memory-log → memory-log}/memory/session.ts +0 -0
- /package/{extensions/memory-log → memory-log}/runtime.ts +0 -0
- /package/{extensions/memory-log → memory-log}/spawn/launch.ts +0 -0
- /package/{extensions/memory-log → memory-log}/spawn/runs.ts +0 -0
- /package/{extensions/memory-log → memory-log}/tokens.ts +0 -0
- /package/{extensions/memory-log → memory-log}/ui/status-controller.ts +0 -0
- /package/{extensions/memory-log → memory-log}/ui/timeline.ts +0 -0
- /package/{extensions/multi-harness → multi-harness}/adapters.mjs +0 -0
- /package/{extensions/multi-harness → multi-harness}/harness-done.mjs +0 -0
- /package/{extensions/multi-harness → multi-harness}/index.ts +0 -0
- /package/{extensions/multi-harness → multi-harness}/ipc.mjs +0 -0
- /package/{extensions/multi-harness → multi-harness}/opencode-plugin.mjs +0 -0
- /package/{extensions/multi-harness → multi-harness}/process-runner.mjs +0 -0
- /package/{extensions/multi-harness → multi-harness}/turn-hook.mjs +0 -0
- /package/{extensions/multi-harness → multi-harness}/worker-bridge.ts +0 -0
- /package/{extensions/prompt-snipaste → prompt-snipaste}/index.ts +0 -0
- /package/{extensions/prompt-snipaste → prompt-snipaste}/menu.ts +0 -0
- /package/{prompts → prompt-snipaste/prompts}/ask-questions.md +0 -0
- /package/{prompts → prompt-snipaste/prompts}/delegate-exploration.md +0 -0
- /package/{prompts → prompt-snipaste/prompts}/diagnose-report.md +0 -0
- /package/{prompts → prompt-snipaste/prompts}/frontend-tech-preset.md +0 -0
- /package/{prompts → prompt-snipaste/prompts}/orchestrator-mode.md +0 -0
- /package/{prompts → prompt-snipaste/prompts}/session-kickoff.md +0 -0
- /package/{prompts → prompt-snipaste/prompts}/verify-not-assume.md +0 -0
- /package/{extensions/srp-theme → srp-theme}/index.ts +0 -0
- /package/{extensions/subagent → subagent}/bridge.ts +0 -0
- /package/{extensions/subagent → subagent}/index.ts +0 -0
- /package/{extensions/subagent → subagent}/mux.ts +0 -0
- /package/{extensions/subagent → subagent}/session.ts +0 -0
- /package/{extensions/subagent → subagent}/ui.ts +0 -0
- /package/{extensions/tui-asr → tui-asr}/status.ts +0 -0
- /package/{extensions/web-reach → web-reach}/html.ts +0 -0
- /package/{extensions/web-reach → web-reach}/index.ts +0 -0
- /package/{extensions/web-reach → web-reach}/rsc.ts +0 -0
- /package/{extensions/web-reach → web-reach}/search.ts +0 -0
- /package/{extensions/web-reach → web-reach}/transport.ts +0 -0
- /package/{extensions/windows-wheel-fix → windows-wheel-fix}/index.ts +0 -0
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export interface LimitWindow {
|
|
2
|
-
usedPercent: number;
|
|
3
|
-
leftPercent: number;
|
|
4
|
-
windowSeconds?: number;
|
|
5
|
-
resetAt?: number;
|
|
6
|
-
resetAfterSeconds?: number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface RateLimit {
|
|
10
|
-
id: string;
|
|
11
|
-
name: string;
|
|
12
|
-
primary?: LimitWindow;
|
|
13
|
-
secondary?: LimitWindow;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface CreditsSnapshot {
|
|
17
|
-
hasCredits?: boolean;
|
|
18
|
-
unlimited?: boolean;
|
|
19
|
-
balance?: number | string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface ResetsSnapshot {
|
|
23
|
-
availableCount?: number;
|
|
24
|
-
applicableCount?: number;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface AccountSnapshot {
|
|
28
|
-
email?: string;
|
|
29
|
-
plan?: string;
|
|
30
|
-
accountId?: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface CodexUsageSnapshot {
|
|
34
|
-
source: "api" | "headers" | "cache";
|
|
35
|
-
fetchedAt: string;
|
|
36
|
-
account: AccountSnapshot;
|
|
37
|
-
defaultLimit?: RateLimit;
|
|
38
|
-
credits?: CreditsSnapshot;
|
|
39
|
-
resets?: ResetsSnapshot;
|
|
40
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# prompt-snipaste
|
|
2
|
-
|
|
3
|
-
Choose prompt snippets to prepend or append to the next user message, with a terminal preview and a session transcript card.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
pi install npm:@rol1n/prompt-snipaste
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Also included in `@rol1n/pi-kit`.
|
|
12
|
-
|
|
13
|
-
## Use
|
|
14
|
-
|
|
15
|
-
Open `/snipaste` or press Alt+S. Use the arrow keys to navigate, Space to toggle snippets, Tab to preview, Enter to confirm, and Escape to cancel. Selected snippets apply once to the next user input; they are then cleared.
|
|
16
|
-
|
|
17
|
-
## Prompt configuration
|
|
18
|
-
|
|
19
|
-
The picker uses Pi's resolved prompt commands, including prompts installed through packages. Package resource filters and disabled prompts are respected; a top-level `prompts: []` does not hide enabled package prompts. Personal and project prompt directories or explicit prompt paths can still be configured through Pi normally.
|
|
20
|
-
|
|
21
|
-
Markdown frontmatter controls each snippet:
|
|
22
|
-
|
|
23
|
-
```markdown
|
|
24
|
-
---
|
|
25
|
-
name: Review checklist
|
|
26
|
-
description: Add the review criteria to the next message
|
|
27
|
-
placement: append
|
|
28
|
-
order: 100
|
|
29
|
-
---
|
|
30
|
-
Check correctness, error handling, and missing validation.
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
`placement` accepts `prepend` or `append`; append is the default. Lower `order` values come first within a placement. Without frontmatter, the file name becomes the snippet name and the body is used directly. The extension's fallback loader, when used without a Pi runtime, reads conventional prompt directories and explicit prompt paths.
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# screenshot
|
|
2
|
-
|
|
3
|
-
Insert the path of the newest Windows system screenshot into Pi's editor. It references an existing image rather than taking a new screenshot.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
pi install npm:@rol1n/screenshot
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Available independently; it is not enabled in the aggregate package by default.
|
|
12
|
-
|
|
13
|
-
## Use
|
|
14
|
-
|
|
15
|
-
Take a screenshot with the system screenshot tool, then run `/screenshot` in Pi. The extension finds the newest supported image by modification time and pastes its path into the editor.
|
|
16
|
-
|
|
17
|
-
## Platform support
|
|
18
|
-
|
|
19
|
-
Native Windows checks standard and localized `Pictures/Screenshots` folders, including supported OneDrive locations, under `USERPROFILE`. WSL searches Windows profiles under the standard `/mnt/c/Users` mount. PNG, JPEG, GIF, BMP, and WebP files are supported.
|
|
20
|
-
|
|
21
|
-
On other platforms the command reports that Windows screenshots are unavailable. There is no screenshot-folder setting; a nonstandard Windows drive mount or screenshot location requires a source change. No model credentials are needed.
|
|
22
|
-
|
|
23
|
-
## Source layout
|
|
24
|
-
|
|
25
|
-
`index.ts` registers the editor command. `discovery.ts` contains platform detection, screenshot-folder discovery, and newest-image selection.
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# srp-theme
|
|
2
|
-
|
|
3
|
-
A Pi terminal presentation extension with a custom footer, prompt preview, agent-loop timing, and a tokens-per-second meter. It is an extension rather than a JSON theme package.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
pi install npm:@rol1n/srp-theme
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Also included in `@rol1n/pi-kit`.
|
|
12
|
-
|
|
13
|
-
## Commands
|
|
14
|
-
|
|
15
|
-
```text
|
|
16
|
-
/srp-theme on
|
|
17
|
-
/srp-theme off
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
These commands enable or disable the extension's footer/prompt presentation and TPS meter for the running session. The extension observes agent and turn events to update timing and throughput information.
|
|
21
|
-
|
|
22
|
-
## Requirements and customization
|
|
23
|
-
|
|
24
|
-
Use Pi's interactive terminal mode for the custom widgets. The extension uses the active Pi theme's colors and does not replace your selected JSON theme. Appearance and layout constants live in `extensions/srp-theme/footer.ts` and `extensions/srp-theme/tps-meter.ts`; lifecycle hooks and the command are wired in `extensions/srp-theme/index.ts`. There is currently no package-specific settings section. No credentials or system binaries are required by the presentation layer itself.
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: subagent
|
|
3
|
-
description: Dispatch, message, and collaborate with parallel, full-powered Pi subagent workers running in split terminal panes or silent background processes.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Subagent
|
|
7
|
-
|
|
8
|
-
Use the native `subagent` tool to delegate tasks to independent, full-powered Pi instances ("workers"). Workers run in dedicated split terminal panes (inside tmux or Zellij) or run silently as background processes (in standard terminals, VSCode, CI/CD, or headless environments). Every worker inherits all standard tools, skills, and extensions, and operates completely asynchronously.
|
|
9
|
-
|
|
10
|
-
## Spawning Workers
|
|
11
|
-
|
|
12
|
-
Call the `subagent` tool directly. The tool returns **immediately** with an acknowledgement. You do **not** need to wait or poll:
|
|
13
|
-
|
|
14
|
-
```json
|
|
15
|
-
subagent({
|
|
16
|
-
"task": "Investigate the authentication middleware in src/auth.ts and propose fixes.",
|
|
17
|
-
"name": "auth-audit"
|
|
18
|
-
})
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
- `task`: Clear, comprehensive instructions for the worker.
|
|
22
|
-
- `name`: Short, descriptive identifier (e.g. `frontend`, `db-migration`, `tester`).
|
|
23
|
-
- `model`: (Optional) Model override (e.g. a faster model for simple exploration).
|
|
24
|
-
- `cwd`: (Optional) Working directory for the worker.
|
|
25
|
-
|
|
26
|
-
### Parallel Workers
|
|
27
|
-
|
|
28
|
-
You can dispatch **multiple workers in parallel in a single turn**:
|
|
29
|
-
|
|
30
|
-
```json
|
|
31
|
-
[
|
|
32
|
-
{ "name": "subagent", "arguments": { "task": "Audit frontend router in src/routes/", "name": "frontend" } },
|
|
33
|
-
{ "name": "subagent", "arguments": { "task": "Audit database models in src/db/", "name": "backend" } }
|
|
34
|
-
]
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
All workers run concurrently in separate split panes. As each worker finishes, the system automatically injects its final result into your conversation as a **steer message**, waking you up to review the findings.
|
|
38
|
-
|
|
39
|
-
## Non-Blocking Principle
|
|
40
|
-
|
|
41
|
-
- **DO NOT** write bash scripts, `sleep` commands, `tail` logs, or polling loops to check on a worker.
|
|
42
|
-
- **DO NOT** fabricate or assume worker results before receiving the steer message.
|
|
43
|
-
- After calling `subagent`, either end your turn immediately or work on other independent tasks. The harness will wake you with the result as soon as it is ready.
|
|
44
|
-
|
|
45
|
-
## Answering Worker Questions
|
|
46
|
-
|
|
47
|
-
Workers have an `ask_question` tool. When a worker encounters ambiguity or needs a decision:
|
|
48
|
-
1. The worker pauses its work and marks itself as `waiting: ask`.
|
|
49
|
-
2. You receive a steer notification: `[Subagent "<name>" question] ...`.
|
|
50
|
-
3. Answer the worker by targeting its name:
|
|
51
|
-
|
|
52
|
-
```json
|
|
53
|
-
subagent({
|
|
54
|
-
"target": "auth-audit",
|
|
55
|
-
"task": "Use the JWT verification method rather than session cookies."
|
|
56
|
-
})
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
The worker absorbs your guidance, resumes execution, and reports back when done.
|
|
60
|
-
|
|
61
|
-
## Stopping a Worker
|
|
62
|
-
|
|
63
|
-
If a worker is no longer needed or is off-track, terminate it:
|
|
64
|
-
|
|
65
|
-
```json
|
|
66
|
-
subagent({
|
|
67
|
-
"target": "auth-audit",
|
|
68
|
-
"action": "stop"
|
|
69
|
-
})
|
|
70
|
-
```
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# tui-asr
|
|
2
|
-
|
|
3
|
-
Streaming voice dictation for Pi's terminal editor using Aliyun DashScope Paraformer. Includes a live audio-level meter and a searchable ASR model selector.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
pi install npm:@rol1n/tui-asr
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Also included in `@rol1n/pi-kit`. The extension entrypoint is `extensions/tui-asr/index.ts`; `dictation.ts` owns the recording lifecycle, with separate audio, provider/auth, clipboard, input insertion, status animation, and model-selector helpers.
|
|
12
|
-
|
|
13
|
-
## Commands and shortcuts
|
|
14
|
-
|
|
15
|
-
| Action | Command or shortcut |
|
|
16
|
-
|---|---|
|
|
17
|
-
| Start or stop dictation | `/asr` or Alt+M |
|
|
18
|
-
| Cancel dictation | Alt+N |
|
|
19
|
-
| Choose a model | `/asr model` |
|
|
20
|
-
| Select by model ID | `/asr model paraformer-realtime-v2` |
|
|
21
|
-
|
|
22
|
-
The startup model is `paraformer-realtime-v2`. Final transcripts are inserted into the focused editor/input target, with a system clipboard fallback when direct insertion is unavailable.
|
|
23
|
-
|
|
24
|
-
## Requirements and authentication
|
|
25
|
-
|
|
26
|
-
Install SoX and ensure the recorder is on PATH: Windows uses `sox` with the `waveaudio` input, while POSIX uses `rec` / `sox` with the default audio device. A usable microphone and OS recording permission are required. Clipboard fallback uses the platform's clipboard utility, such as `clip`, `pbcopy`, or Wayland/X11 tools.
|
|
27
|
-
|
|
28
|
-
Supply `DASHSCOPE_API_KEY` or `ALIYUN_API_KEY`, or authenticate through `/login dashscope` when [custom-providers](https://github.com/RolinShmily/pi-kit/tree/main/extensions/custom-providers) is loaded. Shared ASR helpers ship in this package; provider registration remains a separate extension entrypoint. Model selection is session-local.
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { spawn, type ChildProcessByStdio } from "node:child_process";
|
|
2
|
-
import type { Readable } from "node:stream";
|
|
3
|
-
|
|
4
|
-
export function rmsFromPcm16(buf: Buffer): number {
|
|
5
|
-
if (buf.length < 2) return 0;
|
|
6
|
-
const sampleCount = Math.floor(buf.length / 2);
|
|
7
|
-
let sumSquares = 0;
|
|
8
|
-
for (let i = 0; i < sampleCount; i++) {
|
|
9
|
-
const sample = buf.readInt16LE(i * 2);
|
|
10
|
-
sumSquares += sample * sample;
|
|
11
|
-
}
|
|
12
|
-
const meanSquare = sumSquares / sampleCount;
|
|
13
|
-
return Math.sqrt(meanSquare);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** Spawn the existing 16 kHz mono PCM recorder for the current platform. */
|
|
17
|
-
export function spawnRecorder(): ChildProcessByStdio<null, Readable, Readable> {
|
|
18
|
-
const commonAudioArgs = [
|
|
19
|
-
"-q",
|
|
20
|
-
"--buffer", "512",
|
|
21
|
-
"-r", "16000",
|
|
22
|
-
"-c", "1",
|
|
23
|
-
"-b", "16",
|
|
24
|
-
"-e", "signed-integer",
|
|
25
|
-
"-t", "raw",
|
|
26
|
-
"-",
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
let proc: ChildProcessByStdio<null, Readable, Readable>;
|
|
30
|
-
if (process.platform === "win32") {
|
|
31
|
-
proc = spawn("sox", ["-t", "waveaudio", "default", ...commonAudioArgs], { stdio: ["ignore", "pipe", "pipe"] });
|
|
32
|
-
} else {
|
|
33
|
-
try {
|
|
34
|
-
proc = spawn("rec", commonAudioArgs, { stdio: ["ignore", "pipe", "pipe"] });
|
|
35
|
-
} catch {
|
|
36
|
-
proc = spawn("sox", ["-d", ...commonAudioArgs], { stdio: ["ignore", "pipe", "pipe"] });
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return proc;
|
|
40
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { spawn, type ChildProcessByStdio } from "node:child_process";
|
|
2
|
-
|
|
3
|
-
export function copyToClipboard(text: string): boolean {
|
|
4
|
-
try {
|
|
5
|
-
const isWsl =
|
|
6
|
-
process.platform === "linux" &&
|
|
7
|
-
typeof process.env.WSL_DISTRO_NAME === "string";
|
|
8
|
-
|
|
9
|
-
let proc: ChildProcessByStdio<any, any, any>;
|
|
10
|
-
if (isWsl) {
|
|
11
|
-
proc = spawn("clip.exe", [], { stdio: ["pipe", "ignore", "ignore"] });
|
|
12
|
-
} else if (process.platform === "win32") {
|
|
13
|
-
proc = spawn("clip", [], { stdio: ["pipe", "ignore", "ignore"] });
|
|
14
|
-
} else if (process.platform === "darwin") {
|
|
15
|
-
proc = spawn("pbcopy", [], { stdio: ["pipe", "ignore", "ignore"] });
|
|
16
|
-
} else {
|
|
17
|
-
try {
|
|
18
|
-
proc = spawn("wl-copy", [], { stdio: ["pipe", "ignore", "ignore"] });
|
|
19
|
-
} catch {
|
|
20
|
-
proc = spawn("xclip", ["-selection", "clipboard"], { stdio: ["pipe", "ignore", "ignore"] });
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
proc.stdin.write(text);
|
|
25
|
-
proc.stdin.end();
|
|
26
|
-
return true;
|
|
27
|
-
} catch {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
|
|
3
|
-
export { ALL_ASR_MODELS, createAsrProvider, type AsrModelDefinition, type StreamingAsrProvider } from "../custom-providers/asr/index.ts";
|
|
4
|
-
|
|
5
|
-
export async function resolveProviderApiKey(provider: string, ctx?: ExtensionContext | null): Promise<string> {
|
|
6
|
-
if (ctx?.modelRegistry) {
|
|
7
|
-
const candidates = provider === "dashscope" ? ["dashscope", "aliyun"] : [provider];
|
|
8
|
-
for (const id of candidates) {
|
|
9
|
-
try {
|
|
10
|
-
const key = await ctx.modelRegistry.getApiKeyForProvider(id);
|
|
11
|
-
if (key?.trim()) return key.trim();
|
|
12
|
-
} catch {}
|
|
13
|
-
try {
|
|
14
|
-
const auth = await ctx.modelRegistry.getProviderAuth(id);
|
|
15
|
-
if (auth?.auth?.apiKey?.trim()) return auth.auth.apiKey.trim();
|
|
16
|
-
} catch {}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
const envKey = process.env[`${provider.toUpperCase()}_API_KEY`];
|
|
20
|
-
if (envKey?.trim()) return envKey.trim();
|
|
21
|
-
if (provider === "dashscope") {
|
|
22
|
-
return process.env.ALIYUN_API_KEY?.trim() || "";
|
|
23
|
-
}
|
|
24
|
-
return "";
|
|
25
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# web-reach
|
|
2
|
-
|
|
3
|
-
Web search and page extraction tools for Pi. Registers `web_search` through Exa's public MCP endpoint and `web_fetch` for readable Markdown or raw responses.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
pi install npm:@rol1n/web-reach
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Also included in `@rol1n/pi-kit`. Avoid enabling another extension that registers the same tool names unless overriding them is intentional.
|
|
12
|
-
|
|
13
|
-
## Use
|
|
14
|
-
|
|
15
|
-
```json
|
|
16
|
-
{"query":"Pi coding agent package resource filtering"}
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
```json
|
|
20
|
-
{"url":"https://example.com/docs","mode":"readable"}
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
The first object is for `web_search`; the second is for `web_fetch`. Fetch mode defaults to `readable` and also accepts `raw`. Extraction includes HTML-to-Markdown, JSON formatting, PDF handling, and a Jina Reader fallback for pages that need it. Returned text is limited to 35,000 characters.
|
|
24
|
-
|
|
25
|
-
## Configuration
|
|
26
|
-
|
|
27
|
-
| Environment variable | Default |
|
|
28
|
-
|---|---|
|
|
29
|
-
| `SRP_WEB_SEARCH_TIMEOUT_MS` | 60000 |
|
|
30
|
-
| `SRP_WEB_FETCH_TIMEOUT_MS` | 20000 |
|
|
31
|
-
| `SRP_WEB_FETCH_MAX_BYTES` | 4194304 (4 MiB) |
|
|
32
|
-
|
|
33
|
-
No separate search API key is configured; availability and rate limits depend on the public Exa and Jina services. PDF extraction optionally imports `unpdf` if it is available. Without that package the implementation falls back to a basic text extraction path, with lower PDF text quality.
|
|
34
|
-
|
|
35
|
-
## Source layout
|
|
36
|
-
|
|
37
|
-
`index.ts` registers the tools and re-exports `searchWeb` and `fetchUrl`. `search.ts` handles Exa MCP requests and response parsing; `transport.ts` shares timeout, cancellation, environment, and truncation helpers. `page.ts` coordinates page fetching and extraction, using `rsc.ts` for Next.js data, `html.ts` for semantic Markdown, `pdf.ts` for optional PDF extraction, and `reader.ts` for the Jina Reader fallback.
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export function isPdfUrl(url: string, contentType?: string): boolean {
|
|
2
|
-
if (contentType?.includes("application/pdf")) return true;
|
|
3
|
-
try {
|
|
4
|
-
return new URL(url).pathname.toLowerCase().endsWith(".pdf");
|
|
5
|
-
} catch {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export async function extractPdfBuffer(
|
|
11
|
-
buffer: ArrayBuffer,
|
|
12
|
-
url: string,
|
|
13
|
-
): Promise<{ text: string; title: string }> {
|
|
14
|
-
try {
|
|
15
|
-
const { getDocumentProxy } = await import("unpdf");
|
|
16
|
-
const pdf = await getDocumentProxy(new Uint8Array(buffer));
|
|
17
|
-
const maxPages = Math.min(pdf.numPages, 80);
|
|
18
|
-
const pages: string[] = [];
|
|
19
|
-
|
|
20
|
-
for (let i = 1; i <= maxPages; i++) {
|
|
21
|
-
const page = await pdf.getPage(i);
|
|
22
|
-
const textContent = await page.getTextContent();
|
|
23
|
-
const pageText = textContent.items
|
|
24
|
-
.map((item: unknown) => (item as { str?: string }).str || "")
|
|
25
|
-
.join(" ")
|
|
26
|
-
.replace(/\s+/g, " ")
|
|
27
|
-
.trim();
|
|
28
|
-
if (pageText) pages.push(`--- Page ${i} ---\n${pageText}`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const title = new URL(url).pathname.split("/").pop() || "PDF Document";
|
|
32
|
-
const text = `# ${title}\n\nPages: ${pdf.numPages}\n\n${pages.join("\n\n")}`;
|
|
33
|
-
return { text, title };
|
|
34
|
-
} catch {
|
|
35
|
-
// Fallback plain text extraction
|
|
36
|
-
const text = Buffer.from(buffer).toString("latin1").replace(/[^\x20-\x7E\n\r\t]/g, " ");
|
|
37
|
-
return {
|
|
38
|
-
text: `# PDF Document\n\n${text.slice(0, 8000)}`,
|
|
39
|
-
title: "PDF Document",
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_USER_AGENT, withTimeout } from "./transport.ts";
|
|
2
|
-
|
|
3
|
-
const JINA_READER_BASE = "https://r.jina.ai/";
|
|
4
|
-
|
|
5
|
-
export async function fetchViaJinaReader(
|
|
6
|
-
url: string,
|
|
7
|
-
signal?: AbortSignal,
|
|
8
|
-
): Promise<{ text: string; title: string } | null> {
|
|
9
|
-
const { ac, done } = withTimeout(30_000, "Jina Reader timed out", signal);
|
|
10
|
-
try {
|
|
11
|
-
const res = await fetch(`${JINA_READER_BASE}${url}`, {
|
|
12
|
-
headers: {
|
|
13
|
-
Accept: "text/markdown",
|
|
14
|
-
"X-No-Cache": "true",
|
|
15
|
-
"User-Agent": DEFAULT_USER_AGENT,
|
|
16
|
-
},
|
|
17
|
-
signal: ac.signal,
|
|
18
|
-
});
|
|
19
|
-
if (!res.ok) return null;
|
|
20
|
-
|
|
21
|
-
const raw = await res.text();
|
|
22
|
-
const contentIndex = raw.indexOf("Markdown Content:");
|
|
23
|
-
const markdown = contentIndex >= 0 ? raw.slice(contentIndex + 17).trim() : raw.trim();
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
markdown.length < 80 ||
|
|
27
|
-
markdown.startsWith("Loading...") ||
|
|
28
|
-
markdown.startsWith("Please enable JavaScript")
|
|
29
|
-
) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const titleMatch = markdown.match(/^#+\s+(.+)$/m);
|
|
34
|
-
const title = titleMatch?.[1]?.trim() || "";
|
|
35
|
-
|
|
36
|
-
return { text: markdown, title };
|
|
37
|
-
} catch {
|
|
38
|
-
return null;
|
|
39
|
-
} finally {
|
|
40
|
-
done();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# windows-wheel-fix
|
|
2
|
-
|
|
3
|
-
Restore mouse-wheel reporting for Pi running under Windows ConPTY/Zellij when terminal initialization causes wheel events to be translated into prompt-history navigation.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
pi install npm:@rol1n/windows-wheel-fix
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Also included in `@rol1n/pi-kit`. The entrypoint returns immediately outside native Windows, so an aggregate installation does not apply this terminal patch on Linux, WSL, or macOS.
|
|
12
|
-
|
|
13
|
-
## Behavior
|
|
14
|
-
|
|
15
|
-
The extension re-emits mouse-reporting control sequences after session startup and whenever stdin returns to raw mode. It has no slash command, settings section, credentials, or external binary requirement.
|
|
16
|
-
|
|
17
|
-
The targeted upstream issue is [earendil-works/pi#9656](https://github.com/earendil-works/pi/issues/9656). If your installed Pi/terminal versions already resolve that issue, disable the extension through Pi's package resource configuration.
|
|
18
|
-
|
|
19
|
-
## Source layout
|
|
20
|
-
|
|
21
|
-
The small, platform-specific patch stays in one `index.ts` beside this README.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|