Skip to content

Commit 05131ef

Browse files
Merge pull request #2 from anand-testcompare/feature/local-doc-search
Feature/local doc search
2 parents 94c7334 + 516bcfe commit 05131ef

26 files changed

Lines changed: 2234 additions & 80 deletions

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@ coverage/
99
.eslintcache
1010
.bun/
1111
.bun.lockb
12-
.memory/
12+
.memory/
13+
data/*.db
14+
data/*.db-shm
15+
data/*.db-wal
16+
data/*.parquet
17+
18+
.sisyphus/

.mise/tasks/build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
#MISE sources=["src/**/*"]
44
#MISE outputs=["dist/index.js"]
55

6-
bun build ./src/index.ts --outdir dist --target bun
6+
bun build ./src/index.ts --outdir dist --target bun --external "@opencode-ai/*"

.mise/tasks/dev

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
bun build ./src/index.ts \
77
--outdir dist \
88
--target bun \
9+
--external "@opencode-ai/*" \
910
--sourcemap=inline \
1011
--splitting \
1112
--entry-naming='[dir]/[name].js' \

.mise/tasks/setup

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ fi
1212

1313
bun install
1414

15+
mkdir -p node_modules/@opencode-ai
16+
ln -sf "$(pwd)/.opencode/node_modules/@opencode-ai/plugin" node_modules/@opencode-ai/plugin 2>/dev/null || true
17+
1518
echo ""
1619
echo "👍 Done"
1720
echo ""

.mise/tasks/smoke

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
#MISE description="Build and smoke-test the plugin artifact"
3+
#MISE depends=["build"]
4+
5+
bun run scripts/smoke-test.ts

.mise/tasks/watch

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
bun build ./src/index.ts \
66
--outdir dist \
77
--target bun \
8+
--external "@opencode-ai/*" \
89
--sourcemap=inline \
910
--splitting \
1011
--entry-naming='[dir]/[name].js' \

.opencode/command/test.md

Lines changed: 25 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,42 @@
11
---
2-
description: Test the Bun Module generator end-to-end
3-
---
4-
5-
# Testing the Bun Module Generator
6-
7-
You are a generator testing coordinator. Use the Task tool to delegate testing phases to specialized subagents. Execute these phases in sequence:
8-
9-
## Phase 1: Environment Setup & Prerequisites
10-
11-
Use a general subagent to verify the environment is ready:
12-
13-
**Task:** Verify prerequisites for generator testing
14-
15-
- Check Bash is installed: `bash --version`
16-
- Check git is configured: `git config user.name` and `git config user.email`
17-
- Create or use test directory
18-
- Report environment status
19-
20-
## Phase 2: Clone & Run Generator
21-
22-
Use a general subagent to:
23-
24-
- Clone template repo
25-
- Run `./setup.sh` with test inputs:
26-
- Module name: `test-module`
27-
- Description: `A test module`
28-
- Author: `Test User`
29-
- Email: `test@example.com`
30-
- Repo: `https://github.com/test/test-module`
31-
- GitHub org: `test`
32-
33-
## Phase 3: Verify Generator Output
34-
35-
Using `task(general)` to validate:
36-
37-
**Files Generated:**
2+
description: Test Palantir documentation tools
3+
---
384

39-
- `package.json`, `src/index.ts`, `README.md`, `.github/workflows/`
40-
- All expected template files present
5+
# Palantir Plugin Tool Test
416

42-
**Generator Cleanup:**
7+
You are testing the Palantir Foundry documentation tools. Follow these rules strictly:
438

44-
- `template/` removed
45-
- `setup.sh` removed
46-
- Old `.git/` replaced with fresh repo
9+
## Rules
4710

48-
**Git Repository:**
11+
1. Use ONLY the `list_all_docs` and `get_doc_page` tools. Do NOT use web search, file reading, or any other tools.
12+
2. NEVER guess a URL. Always start with `list_all_docs` to discover available pages.
13+
3. When looking for information, first list all docs, then identify candidate pages by title, then read them one at a time.
14+
4. If information spans multiple pages, read ALL relevant pages before synthesizing.
4915

50-
- `.git/` exists and initialized
51-
- On `main` branch
52-
- Initial commit exists
53-
- Remote origin configured
16+
## Test Sequence
5417

55-
**Template Rendering:**
18+
### Step 1: Verify list_all_docs
5619

57-
- `package.json` name matches `test-module` (kebab-case)
58-
- `description`, `author.name`, `author.email` correctly templated
59-
- `repository.url` set correctly
60-
- `README.md` contains module name and author info
20+
Call `list_all_docs`. Confirm it returns a list with 3,000+ pages. Report the exact count.
6121

62-
**Kebab-Case Conversion:**
22+
### Step 2: Find and read a specific topic
6323

64-
- Test with various formats: CamelCase, spaces, underscores, special chars
65-
- Verify all convert correctly to kebab-case
24+
Using ONLY the list from Step 1, find pages related to "Ontology". Identify 3+ candidate pages by their titles. Read each one using `get_doc_page` with the exact URL from the list. Summarize what you learned about Ontology from across these pages.
6625

67-
## Phase 4: Build & Verify Module
26+
### Step 3: Cross-page information retrieval
6827

69-
Use a general subagent to:
28+
Using ONLY the list from Step 1, find pages related to "Pipeline Builder" or "Transforms". Read at least 2 pages. Explain how Pipelines relate to the Ontology based ONLY on what the documentation says.
7029

71-
- Run `bun install`
72-
- Run `mise run build`
73-
- Run `mise run lint`
74-
- Run `mise run test`
75-
- Verify all steps succeed
30+
### Step 4: Edge cases
7631

77-
## Phase 5: Results & Reporting
32+
- Try `get_doc_page` with a URL that does NOT exist (e.g., `/nonexistent/page/`). Confirm it returns a "not found" message.
33+
- Find a page with a long URL path (3+ segments). Read it successfully.
7834

79-
Compile results from all phases:
35+
### Step 5: Report
8036

81-
- Overall pass/fail status
82-
- List of any failures or issues
83-
- Generated module path location
84-
- Next development steps for the user
37+
Summarize:
8538

86-
Execute all phases in order using the Task tool with appropriate subagent types. Provide the user with a comprehensive test report upon completion.
39+
- Total pages available
40+
- Pages successfully read
41+
- Any failures or unexpected results
42+
- Whether cross-page information retrieval worked correctly

.opencode/plugins/palantir.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../dist/index.js

README.md

Lines changed: 106 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,122 @@
11
# palantir-opencode-plugin
22

3-
Collection of tools, agents, hooks to supercharge development in Foundry.
3+
OpenCode plugin that provides Palantir Foundry documentation to AI agents via local Parquet storage.
44

5-
> Scaffolded from [bun-module](https://github.com/zenobi-us/bun-module)
5+
## Features
6+
7+
- Fetches all ~3,600 pages from Palantir's public documentation
8+
- Stores in local Parquet file for fast offline access (~17MB)
9+
- Exposes `get_doc_page` and `list_all_docs` tools for AI agents
610

711
## Setup
812

913
```bash
1014
bun install
1115
```
1216

17+
## Fetching Documentation
18+
19+
Fetch all Palantir docs into `data/docs.parquet` (~2 minutes, ~17MB file):
20+
21+
```bash
22+
bun run src/docs/fetch-cli.ts
23+
```
24+
25+
## Querying the Data
26+
27+
### Schema
28+
29+
The Parquet file contains a single row group with the following columns:
30+
31+
| Column | Type | Description |
32+
| ------------ | ------- | ----------------------------------- |
33+
| `url` | string | Page URL path (e.g. `/foundry/...`) |
34+
| `title` | string | Page title |
35+
| `content` | string | Full page content (Markdown) |
36+
| `word_count` | integer | Word count of content |
37+
| `meta` | string | JSON-encoded metadata |
38+
| `fetched_at` | string | ISO 8601 timestamp of when fetched |
39+
40+
### Bun
41+
42+
```typescript
43+
import { parquetReadObjects } from 'hyparquet';
44+
45+
const file = await Bun.file('data/docs.parquet').arrayBuffer();
46+
47+
// List all pages (url + title only)
48+
const pages = await parquetReadObjects({ file, columns: ['url', 'title'] });
49+
console.log(`${pages.length} pages`);
50+
51+
// Search by title
52+
const matches = pages.filter((p) => p.title.includes('Pipeline'));
53+
console.log(matches.slice(0, 10));
54+
55+
// Get a specific page's content by row index
56+
const urlToRow = new Map(pages.map((p, i) => [p.url, i]));
57+
const rowIndex = urlToRow.get('/foundry/ontology/overview/');
58+
if (rowIndex !== undefined) {
59+
const [page] = await parquetReadObjects({
60+
file,
61+
rowStart: rowIndex,
62+
rowEnd: rowIndex + 1,
63+
});
64+
console.log(page.content);
65+
}
66+
```
67+
68+
## OpenCode Tools
69+
70+
When installed as an OpenCode plugin, exposes:
71+
72+
- **`get_doc_page`** - Retrieve a specific doc page by URL
73+
- **`list_all_docs`** - List all available documentation pages
74+
- **`/refresh-docs`** - Command hook to re-fetch all documentation
75+
76+
### Installing in OpenCode (this project only)
77+
78+
Symlink the built artifact into the project-level auto-discovered plugins directory:
79+
80+
```bash
81+
mkdir -p .opencode/plugins
82+
```
83+
84+
```bash
85+
ln -s ../../dist/index.js .opencode/plugins/palantir.js
86+
```
87+
88+
OpenCode automatically loads any `.js`/`.ts` files in `.opencode/plugins/` at startup.
89+
1390
## Development
1491

92+
Build the plugin:
93+
94+
```bash
95+
mise run build
96+
```
97+
98+
Run tests:
99+
100+
```bash
101+
mise run test
102+
```
103+
104+
Smoke test the built artifact (build + verify tools load from `dist/index.js`):
105+
106+
```bash
107+
mise run smoke
108+
```
109+
110+
Lint code:
111+
112+
```bash
113+
mise run lint
114+
```
115+
116+
Format with Prettier:
117+
15118
```bash
16-
mise run build # Build the module
17-
mise run test # Run tests
18-
mise run lint # Lint code
19-
mise run lint:fix # Fix linting issues
20-
mise run format # Format code with Prettier
119+
mise run format
21120
```
22121

23122
## Author

bun.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)