@thurstonsand/pi-librarian 0.3.0 → 0.3.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
@@ -8,14 +8,21 @@ A GitHub research subagent for the [pi coding agent](https://github.com/badlogic
8
8
 
9
9
  ## How it works
10
10
 
11
- The `librarian` tool spawns a nested research agent with purpose-built tools:
11
+ The `librarian` tool spawns a research subagent with purpose-built tools:
12
12
 
13
- - **`checkout_repo`** — clone into a local cache; pi's own `grep`/`read`/`find` then work on real files, and `git log -S`/`blame`/`diff` cover history.
14
- - **`search_repos`** — GitHub repository discovery (stars, topics, language).
13
+ - **`checkout_repo`** — clone into a local cache, where it can be read locally, and `git log -S`/`blame`/`diff` covers history.
14
+ - **`search_repos`** — GitHub repository discovery (stars, topics, other metadata).
15
15
  - **`search_code`** — cross-repo public code search via [Grep](https://grep.app/) (regex, global discovery, repo/language/path filters).
16
16
  - **`search_github_code`** — GitHub REST code search over public code and private repositories your configured GitHub auth can access.
17
17
  - **`read_github_file`** — single-file API reads for quick peeks without cloning.
18
18
 
19
+ ## Usage
20
+
21
+ - Ask pi a question involving other repos; it asks the `librarian`.
22
+ - Ask follow-up questions to earlier librarian runs.
23
+ - `/librarian` attaches the research tools directly to your session for direct tool usage.
24
+ - Recommended: install [pi-web-access](https://pi.dev/packages/pi-web-access) (or your web search of choice, tho this one is zero-config to get started) and add `web_search`, `fetch_content`, `get_search_content` to `librarian.tools` to expand past GitHub-only research.
25
+
19
26
  ## GitHub auth for private repos
20
27
 
21
28
  Public GitHub reads work without configuration. To let the librarian search and read private GitHub repositories, provide a token in one of these ways:
@@ -23,13 +30,7 @@ Public GitHub reads work without configuration. To let the librarian search and
23
30
  1. Set `GITHUB_TOKEN` or `GH_TOKEN` in the environment before starting pi.
24
31
  2. Or authenticate the GitHub CLI so `gh auth token` returns a token:
25
32
 
26
- The token is loaded once per pi session and passed to GitHub REST calls used by `search_repos`, `search_github_code`, `checkout_repo`, and `read_github_file`. For private repositories, use a token with read access to the target repos.
27
-
28
- ## Usage
29
-
30
- - Ask pi a question involving other repos; it delegates to the `librarian` tool.
31
- - Ask follow-up questions to earlier librarian runs.
32
- - `/librarian` attaches the research tools directly to your session for manual lookups.
33
+ The token is loaded once per pi session and used for github access in `search_repos`, `search_github_code`, `checkout_repo`, and `read_github_file`. For private repositories, use a token with read access to the target repos.
33
34
 
34
35
  ## Configuration
35
36
 
@@ -40,7 +41,7 @@ In pi's global `settings.json`:
40
41
  "librarian": {
41
42
  "model": "openai-codex/gpt-5.5",
42
43
  "thinkingLevel": "off",
43
- "tools": ["search_web", "fetch_web"],
44
+ "tools": ["web_search", "fetch_content", "get_search_content"],
44
45
  "extensions": ["~/.pi/agent/extensions/parallel-web-tools"],
45
46
  "cacheDir": "/tmp/pi-librarian",
46
47
  "debug": { "persistRuns": false },
@@ -48,16 +49,16 @@ In pi's global `settings.json`:
48
49
  }
49
50
  ```
50
51
 
51
- | Setting | Recommended | Default |
52
- | ------------------- | ----------------------------------------------- | ------------------------------ |
53
- | `model` | `openai-codex/gpt-5.5` | current session model |
54
- | `thinkingLevel` | `off` | current session thinking level |
55
- | `tools` | names of extra tools to activate, when needed | `[]` |
56
- | `extensions` | escape hatch paths for tools not loaded in pi | `[]` |
57
- | `cacheDir` | `/tmp/pi-librarian` | `/tmp/pi-librarian` |
58
- | `debug.persistRuns` | persist nested session file paths for debugging | `false` |
52
+ | Setting | Recommended | Default |
53
+ | ------------------- | ------------------------------------------------ | ------------------------------ |
54
+ | `model` | `openai-codex/gpt-5.5` | current session model |
55
+ | `thinkingLevel` | `off` | current session thinking level |
56
+ | `tools` | names of extra tools to provide the librarian | `[]` |
57
+ | `extensions` | extra paths to load extensions for the librarian | `[]` |
58
+ | `cacheDir` | `/tmp/pi-librarian` | `/tmp/pi-librarian` |
59
+ | `debug.persistRuns` | persist nested session file paths for debugging | `false` |
59
60
 
60
- `librarian.tools` is the activation gate for extra tools. `librarian.extensions` only adds extension paths to the search space when a named tool is not already loaded in the main pi session; listing an extension path does not activate every tool in that bundle. Librarian runs exclude `write` and `edit`.
61
+ `librarian.extensions` dynamically loads extra extensions just for the librarian. Add any tools from that extension to `librarian.tools` for the librarian to actually be able to use them. Librarian excludes `write` and `edit`.
61
62
 
62
63
  ## Development
63
64
 
package/RELEASE.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  # Release notes
4
4
 
5
+ ## 0.3.1
6
+
7
+ ### Changed
8
+
9
+ - Sharpened the research tools' prompt snippets, guidelines, and descriptions so the librarian names each tool explicitly and reads its guidance as directive instructions.
10
+
5
11
  ## 0.3.0
6
12
 
7
13
  Hardens librarian research tools and aligns GitHub file reads with pi's native `read` tool.
@@ -29,10 +29,10 @@ export function createCheckoutRepoTool(cacheDir: string) {
29
29
  name: LIBRARIAN_TOOL_NAMES.checkoutRepo,
30
30
  label: "Checkout repo",
31
31
  description: "Clone a repo (blob-less partial clone, cached locally).",
32
- promptSnippet: "Clone a repo",
32
+ promptSnippet: "Clone a repo locally",
33
33
  promptGuidelines: [
34
- "Use when you want to deep dive on a specific repo. Follow up using grep/read/find/ls on the returned path, and `git -C <path> log/blame/diff` for history.",
35
- "Do not checkout repos directly using `git`. Always use this tool instead.",
34
+ "Use checkout_repo to deep dive on a specific repo, then grep/read/find/ls on the returned path and `git -C <path> log/blame/diff` for history.",
35
+ "Do not clone repos directly with `git`; always use checkout_repo.",
36
36
  ],
37
37
  parameters: CheckoutRepoParams,
38
38
 
@@ -46,10 +46,9 @@ export function createProvideResultsTool(onFindings: (findings: Findings) => voi
46
46
  name: LIBRARIAN_TOOL_NAMES.provideResults,
47
47
  label: "Provide results",
48
48
  description: "Report your findings in structured form.",
49
- promptSnippet: "Provide results",
49
+ promptSnippet: "Report findings",
50
50
  promptGuidelines: [
51
- "Tool must be called before the turn ends.",
52
- "After calling this tool, the turn will end.",
51
+ "provide_results ends the turn; call it once, after you've gathered your findings.",
53
52
  ],
54
53
  parameters: FindingsSchema,
55
54
 
@@ -47,11 +47,11 @@ export function createReadGitHubFileTool(githubClient: GitHubClientProvider) {
47
47
  name: LIBRARIAN_TOOL_NAMES.readGitHubFile,
48
48
  label: "Read GitHub file",
49
49
  description: `Read a single file (or list a directory) from a GitHub repo via the API, without cloning.`,
50
- promptSnippet: "Read Github file",
50
+ promptSnippet: "Read a file/directory from GitHub",
51
51
  promptGuidelines: [
52
- "For quick peeks — package.json, a README, one source file.",
53
- "For multi-file exploration prefer checkout_repo.",
54
- "Use offset/limit for larger files.",
52
+ "Use read_github_file for quick peeks — package.json, a README, one source file.",
53
+ "For multi-file exploration, prefer checkout_repo over read_github_file.",
54
+ "Use read_github_file's offset/limit for larger files.",
55
55
  ],
56
56
  parameters: ReadGitHubFileParams,
57
57
 
@@ -18,7 +18,8 @@ const SearchCodeParams = Type.Object({
18
18
  }),
19
19
  regex: Type.Optional(
20
20
  Type.Boolean({
21
- description: "Treat `pattern` as a regular expression instead of literals.",
21
+ description:
22
+ "Treat `pattern` as a regular expression instead of literals. Supports `(?s)` for multi-line patterns.",
22
23
  }),
23
24
  ),
24
25
  repo: Type.Optional(
@@ -59,11 +60,10 @@ export const searchCodeTool = defineTool<typeof SearchCodeParams, SearchCodeDeta
59
60
  name: LIBRARIAN_TOOL_NAMES.searchCode,
60
61
  label: "Search code across repos",
61
62
  description: "Cross-repo code search over public source code.",
62
- promptSnippet: "Search code across repos",
63
+ promptSnippet: "Search public code across repos",
63
64
  promptGuidelines: [
64
- "When `regex` is true, `pattern` can also use `(?s)` for multi-line patterns.",
65
- "Results are CANDIDATES to verify via checkout_repo/read_github_file never cite them directly.",
66
- "This searches public GitHub code only. Use search_github_code when private repository access matters.",
65
+ "search_code results are candidates to verify via checkout_repo/read_github_file never cite them directly.",
66
+ "search_code covers public GitHub code only; use search_github_code when private repository access is required.",
67
67
  ],
68
68
  parameters: SearchCodeParams,
69
69
 
@@ -89,10 +89,9 @@ export function createSearchGitHubCodeTool(githubClient: GitHubClientProvider) {
89
89
  label: "Search GitHub code",
90
90
  description:
91
91
  "GitHub REST code search over public code and private repositories your configured GitHub auth can access.",
92
- promptSnippet: "Search GitHub code",
92
+ promptSnippet: "Search GitHub code (incl. private repos)",
93
93
  promptGuidelines: [
94
- "Results are CANDIDATES to verify via checkout_repo/read_github_file never cite them directly.",
95
- "GitHub REST code search is literal/tokenized and does not support regex; use search_code for public regex/global code search.",
94
+ "search_github_code is literal/tokenized and does not support regex; use search_code for public regex/global search.",
96
95
  ],
97
96
  parameters: SearchGitHubCodeParams,
98
97
 
@@ -34,8 +34,8 @@ export function createSearchReposTool(githubClient: GitHubClientProvider) {
34
34
  name: LIBRARIAN_TOOL_NAMES.searchRepos,
35
35
  label: "Search repos metadata",
36
36
  description: "Discover GitHub repositories.",
37
- promptSnippet: "Search repos metadata",
38
- promptGuidelines: ["Use for questions like 'what are the popular X libraries'."],
37
+ promptSnippet: "Search GitHub repos by metadata",
38
+ promptGuidelines: ['Use search_repos for questions like "what are the popular X libraries".'],
39
39
  parameters: SearchReposParams,
40
40
 
41
41
  async execute(_toolCallId, params) {
@@ -61,7 +61,6 @@ export default function librarianExtension(pi: ExtensionAPI): void {
61
61
  for (const tool of attachableTools) {
62
62
  pi.registerTool({
63
63
  ...tool,
64
- description: `${tool.description} (Librarian tool, attached via /librarian: use for quick single lookups; delegate multi-step research to the librarian tool.)`,
65
64
  renderCall(args, theme) {
66
65
  const { verb, subject } = formatTraceLine(
67
66
  { name: tool.name, args, id: "", startedAt: 0 } satisfies TraceCall,
@@ -81,10 +80,9 @@ export default function librarianExtension(pi: ExtensionAPI): void {
81
80
  label: "Librarian",
82
81
  description:
83
82
  "Understand complex, multi-repo codebases, exploring cross-repo relationships, analyzing architectural patterns, finding implementations across codebases, understanding code evolution/commit history, diving deep on specific code bases, getting comprehensive feature explanations, and exploring end-to-end system design across within or across repositories.",
84
- promptSnippet:
85
- "librarian: research GitHub repos (implementation questions, ecosystem comparisons, usage examples) and return cited findings",
83
+ promptSnippet: "Research GitHub repos and codebases, returning cited findings",
86
84
  promptGuidelines: [
87
- "If a single file or reference must be located, you may use other means (search for downloaded dependencies, web search, etc), but for deeper queries that will take multiple steps to resolve, prefer the librarian.",
85
+ "Use librarian for deep, multi-step research across repos; for a single file or reference, prefer cheaper means (downloaded dependencies, web search or fetch).",
88
86
  ],
89
87
  parameters: LibrarianParams,
90
88
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thurstonsand/pi-librarian",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "GitHub research subagent for pi: deep-dive specific repos, discover across the ecosystem",
6
6
  "license": "MIT",