pi-web-access 0.5.0 → 0.5.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/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.5.1] - 2026-02-02
8
+
9
+ ### Added
10
+ - Bundled `librarian` skill -- structured research workflow for open-source libraries with GitHub permalinks, combining fetch_content (cloning), web_search (recent info), and git operations (blame, log, show)
11
+
12
+ ### Fixed
13
+ - Session fork event handler was registered as `session_branch` (non-existent event) instead of `session_fork`, meaning forks never triggered cleanup (abort pending fetches, clear clone cache, restore session data)
14
+ - API fallback title for tree URLs with a path (e.g. `/tree/main/src`) now includes the path (`owner/repo - src`), consistent with clone-based results
15
+ - Removed unnecessary export on `getDefaultBranch` (only used internally by `fetchViaApi`)
16
+
7
17
  ## [0.5.0] - 2026-02-01
8
18
 
9
19
  ### Added
package/README.md CHANGED
@@ -140,6 +140,16 @@ Tool calls render with real-time progress:
140
140
  └───────────────────────────────────────────────────────────────────┘
141
141
  ```
142
142
 
143
+ ## Skills
144
+
145
+ Skills are bundled with the extension and available automatically after install -- no extra setup needed.
146
+
147
+ ### librarian
148
+
149
+ Structured research workflow for open-source libraries with evidence-backed answers and GitHub permalinks. Loaded automatically when the task involves understanding library internals, finding implementation details, or tracing code history.
150
+
151
+ Combines `fetch_content` (GitHub cloning), `web_search` (recent info), and git operations (blame, log, show). Pi auto-detects when to load it based on your prompt. If you have [pi-skill-palette](https://github.com/nicobailon/pi-skill-palette) installed, you can also load it explicitly via `/skill:librarian`.
152
+
143
153
  ## Commands
144
154
 
145
155
  ### /search
@@ -228,6 +238,7 @@ All `githubClone` fields are optional with the defaults shown above. Set `"enabl
228
238
  | `rsc-extract.ts` | RSC flight data parser for Next.js pages |
229
239
  | `storage.ts` | Session-aware result storage |
230
240
  | `activity.ts` | Activity tracking for observability widget |
241
+ | `skills/librarian/` | Bundled skill for library research with permalinks |
231
242
 
232
243
  ## Limitations
233
244
 
package/github-api.ts CHANGED
@@ -41,7 +41,7 @@ export async function checkRepoSize(owner: string, repo: string): Promise<number
41
41
  });
42
42
  }
43
43
 
44
- export async function getDefaultBranch(owner: string, repo: string): Promise<string | null> {
44
+ async function getDefaultBranch(owner: string, repo: string): Promise<string | null> {
45
45
  if (!(await checkGhAvailable())) return null;
46
46
 
47
47
  return new Promise((resolve) => {
@@ -186,9 +186,10 @@ export async function fetchViaApi(
186
186
 
187
187
  lines.push("This is an API-only view. Clone the repo or use `read`/`bash` for deeper exploration.");
188
188
 
189
+ const title = info.path ? `${owner}/${repo} - ${info.path}` : `${owner}/${repo}`;
189
190
  return {
190
191
  url,
191
- title: `${owner}/${repo}`,
192
+ title,
192
193
  content: lines.join("\n"),
193
194
  error: null,
194
195
  };
package/index.ts CHANGED
@@ -144,7 +144,7 @@ export default function (pi: ExtensionAPI) {
144
144
 
145
145
  pi.on("session_start", async (_event, ctx) => handleSessionChange(ctx));
146
146
  pi.on("session_switch", async (_event, ctx) => handleSessionChange(ctx));
147
- pi.on("session_branch", async (_event, ctx) => handleSessionChange(ctx));
147
+ pi.on("session_fork", async (_event, ctx) => handleSessionChange(ctx));
148
148
  pi.on("session_tree", async (_event, ctx) => handleSessionChange(ctx));
149
149
 
150
150
  pi.on("session_shutdown", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-web-access",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "keywords": ["pi-package", "pi", "pi-coding-agent", "extension", "web-search", "perplexity", "fetch", "scraping"],
6
6
  "dependencies": {
@@ -11,6 +11,7 @@
11
11
  "unpdf": "^1.4.0"
12
12
  },
13
13
  "pi": {
14
- "extensions": ["./index.ts"]
14
+ "extensions": ["./index.ts"],
15
+ "skills": ["./skills"]
15
16
  }
16
17
  }
@@ -0,0 +1,155 @@
1
+ ---
2
+ name: librarian
3
+ description: Research open-source libraries with evidence-backed answers and GitHub permalinks. Use when the user asks about library internals, needs implementation details with source code references, wants to understand why something was changed, or needs authoritative answers backed by actual code. Excels at navigating large open-source repos and providing citations to exact lines of code.
4
+ ---
5
+
6
+ # Librarian
7
+
8
+ Answer questions about open-source libraries by finding evidence with GitHub permalinks. Every claim backed by actual code.
9
+
10
+ ## Execution Model
11
+
12
+ Pi executes tool calls sequentially, even when you emit multiple calls in one turn. But batching independent calls in a single turn still saves LLM round-trips (~5-10s each). Use these patterns:
13
+
14
+ | Pattern | When | Actually parallel? |
15
+ |---------|------|-------------------|
16
+ | Batch tool calls in one turn | Independent ops (web_search + fetch_content + read) | No, but saves round-trips |
17
+ | `fetch_content({ urls: [...] })` | Multiple URLs to fetch | Yes (3 concurrent) |
18
+ | Bash with `&` + `wait` | Multiple git/gh commands | Yes (OS-level) |
19
+
20
+ ## Step 1: Classify the Request
21
+
22
+ Before doing anything, classify the request to pick the right research strategy.
23
+
24
+ | Type | Trigger | Primary Approach |
25
+ |------|---------|-----------------|
26
+ | **Conceptual** | "How do I use X?", "Best practice for Y?" | web_search + fetch_content (README/docs) |
27
+ | **Implementation** | "How does X implement Y?", "Show me the source" | fetch_content (clone) + code search |
28
+ | **Context/History** | "Why was this changed?", "History of X?" | git log + git blame + issue/PR search |
29
+ | **Comprehensive** | Complex or ambiguous requests, "deep dive" | All of the above |
30
+
31
+ ## Step 2: Research by Type
32
+
33
+ ### Conceptual Questions
34
+
35
+ Batch these in one turn:
36
+
37
+ 1. **web_search**: `"library-name topic"` via Perplexity for recent articles and discussions
38
+ 2. **fetch_content**: the library's GitHub repo URL to clone and check README, docs, or examples
39
+
40
+ Synthesize web results + repo docs. Cite official documentation and link to relevant source files.
41
+
42
+ ### Implementation Questions
43
+
44
+ The core workflow -- clone, find, permalink:
45
+
46
+ 1. **fetch_content** the GitHub repo URL -- this clones it locally and returns the file tree
47
+ 2. Use **bash** to search the cloned repo: `grep -rn "function_name"`, `find . -name "*.ts"`
48
+ 3. Use **read** to examine specific files once you've located them
49
+ 4. Get the commit SHA: `cd /tmp/pi-github-repos/owner/repo && git rev-parse HEAD`
50
+ 5. Construct permalink: `https://github.com/owner/repo/blob/<sha>/path/to/file#L10-L20`
51
+
52
+ Batch the initial calls: fetch_content (clone) + web_search (recent discussions) in one turn. Then dig into the clone with grep/read once it's available.
53
+
54
+ ### Context/History Questions
55
+
56
+ Use git operations on the cloned repo:
57
+
58
+ ```bash
59
+ cd /tmp/pi-github-repos/owner/repo
60
+
61
+ # Recent changes to a specific file
62
+ git log --oneline -n 20 -- path/to/file.ts
63
+
64
+ # Who changed what and when
65
+ git blame -L 10,30 path/to/file.ts
66
+
67
+ # Full diff for a specific commit
68
+ git show <sha> -- path/to/file.ts
69
+
70
+ # Search commit messages
71
+ git log --oneline --grep="keyword" -n 10
72
+ ```
73
+
74
+ For issues and PRs, use bash:
75
+
76
+ ```bash
77
+ # Search issues
78
+ gh search issues "keyword" --repo owner/repo --state all --limit 10
79
+
80
+ # Search merged PRs
81
+ gh search prs "keyword" --repo owner/repo --state merged --limit 10
82
+
83
+ # View specific issue/PR with comments
84
+ gh issue view <number> --repo owner/repo --comments
85
+ gh pr view <number> --repo owner/repo --comments
86
+
87
+ # Release notes
88
+ gh api repos/owner/repo/releases --jq '.[0:5] | .[].tag_name'
89
+ ```
90
+
91
+ ### Comprehensive Research
92
+
93
+ Combine everything. Batch these in one turn:
94
+
95
+ 1. **web_search**: recent articles and discussions
96
+ 2. **fetch_content**: clone the repo (or multiple repos if comparing)
97
+ 3. **bash**: `gh search issues "keyword" --repo owner/repo --limit 10 & gh search prs "keyword" --repo owner/repo --state merged --limit 10 & wait`
98
+
99
+ Then dig into the clone with grep, read, git blame, git log as needed.
100
+
101
+ ## Step 3: Construct Permalinks
102
+
103
+ Permalinks are the whole point. They make your answers citable and verifiable.
104
+
105
+ ```
106
+ https://github.com/<owner>/<repo>/blob/<commit-sha>/<filepath>#L<start>-L<end>
107
+ ```
108
+
109
+ Getting the SHA from a cloned repo:
110
+
111
+ ```bash
112
+ cd /tmp/pi-github-repos/owner/repo && git rev-parse HEAD
113
+ ```
114
+
115
+ Getting the SHA from a tag:
116
+
117
+ ```bash
118
+ gh api repos/owner/repo/git/refs/tags/v1.0.0 --jq '.object.sha'
119
+ ```
120
+
121
+ Always use full commit SHAs, not branch names. Branch links break when code changes. Permalinks don't.
122
+
123
+ ## Step 4: Cite Everything
124
+
125
+ Every code-related claim needs a permalink. Format:
126
+
127
+ ```markdown
128
+ The stale time check happens in [`notifyManager.ts`](https://github.com/TanStack/query/blob/abc123/packages/query-core/src/notifyManager.ts#L42-L50):
129
+
130
+ \`\`\`typescript
131
+ function isStale(query: Query, staleTime: number): boolean {
132
+ return query.state.dataUpdatedAt + staleTime < Date.now()
133
+ }
134
+ \`\`\`
135
+ ```
136
+
137
+ For conceptual answers, link to official docs and relevant source files. For implementation answers, every function/class reference should have a permalink.
138
+
139
+ ## Failure Recovery
140
+
141
+ | Failure | Recovery |
142
+ |---------|----------|
143
+ | grep finds nothing | Broaden the query, try concept names instead of exact function names |
144
+ | gh CLI rate limited | Use the already-cloned repo in /tmp/pi-github-repos/ for git operations |
145
+ | Repo too large to clone | fetch_content returns an API-only view automatically; use that or add `forceClone: true` |
146
+ | File not found in clone | Branch name with slashes may have misresolved; list the repo tree and navigate manually |
147
+ | Uncertain about implementation | State your uncertainty explicitly, propose a hypothesis, show what evidence you did find |
148
+
149
+ ## Guidelines
150
+
151
+ - Vary search queries when running multiple searches -- different angles, not the same pattern repeated
152
+ - Prefer recent sources; filter out outdated results when they conflict with newer information
153
+ - For version-specific questions, clone the tagged version: `fetch_content("https://github.com/owner/repo/tree/v1.0.0")`
154
+ - When the repo is already cloned from a previous fetch_content call, reuse it -- check the path before cloning again
155
+ - Answer directly. Skip preamble like "I'll help you with..." -- go straight to findings