@openontology/opencode-palantir 0.1.4 → 0.1.5-next.9

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.
Files changed (3) hide show
  1. package/README.md +161 -117
  2. package/dist/index.js +1051 -446
  3. package/package.json +12 -12
package/README.md CHANGED
@@ -1,30 +1,61 @@
1
1
  # opencode-palantir
2
2
 
3
- OpenCode plugin that provides **Palantir Foundry documentation** to AI agents via a local Parquet
4
- database.
3
+ [![npm](https://img.shields.io/npm/v/@openontology/opencode-palantir?logo=npm&label=npm)](https://www.npmjs.com/package/@openontology/opencode-palantir)
4
+ [![downloads](https://img.shields.io/npm/dm/@openontology/opencode-palantir?logo=npm&label=downloads)](https://www.npmjs.com/package/@openontology/opencode-palantir)
5
+ ![CI](https://img.shields.io/github/actions/workflow/status/anand-testcompare/opencode-palantir/pr.yml?branch=main&label=CI&logo=github)
6
+ ![bun](https://img.shields.io/badge/bun-1.3.2-000000?logo=bun&logoColor=white)
7
+ ![@opencode-ai/plugin](https://img.shields.io/github/package-json/dependency-version/anand-testcompare/opencode-palantir/dev/%40opencode-ai%2Fplugin?label=opencode%20plugin%20api&logo=npm)
8
+ ![palantir-mcp](https://img.shields.io/npm/v/palantir-mcp?logo=npm&label=palantir-mcp)
9
+ ![hyparquet](https://img.shields.io/github/package-json/dependency-version/anand-testcompare/opencode-palantir/hyparquet?label=hyparquet&logo=npm)
5
10
 
6
- ## Features
11
+ OpenCode plugin that provides:
7
12
 
8
- - Fetches all ~3,600 pages from Palantir's public documentation
9
- - Stores in a local Parquet file for fast offline access (~17MB)
10
- - Exposes `get_doc_page` and `list_all_docs` tools for AI agents
13
+ - Palantir public documentation tools backed by a local Parquet database
14
+ - Foundry MCP bootstrapping helpers (commands, agents, and optional auto-bootstrap)
11
15
 
12
- ## Quick start (OpenCode users)
16
+ NPM package: https://www.npmjs.com/package/@openontology/opencode-palantir
13
17
 
14
- ### 1) Enable the plugin in `opencode.json` / `opencode.jsonc`
18
+ ## Supported OS
15
19
 
16
- Add the plugin to your OpenCode config:
20
+ - Supported: macOS, Linux
21
+ - Windows: not supported (WSL2 might work, but we don’t debug Windows-specific issues)
22
+
23
+ ## Install (OpenCode)
24
+
25
+ Add the plugin in your OpenCode config (`opencode.jsonc`):
17
26
 
18
27
  ```jsonc
19
28
  {
20
29
  "$schema": "https://opencode.ai/config.json",
21
- "plugin": ["@openontology/opencode-palantir@^0.1.1"]
30
+ "plugin": ["@openontology/opencode-palantir@^0.1.4"]
22
31
  }
23
32
  ```
24
33
 
25
34
  Restart OpenCode.
26
35
 
27
- ### 2) (Optional) Install per-project
36
+ After enabling the plugin, OpenCode will automatically register:
37
+
38
+ - Tools: `get_doc_page`, `list_all_docs`
39
+ - Commands: `/refresh-docs`, `/refresh-docs-rescrape`, `/setup-palantir-mcp`, `/rescan-palantir-mcp-tools`
40
+ - Agents: `foundry-librarian`, `foundry`
41
+
42
+ ### Versions: how to get the latest
43
+
44
+ Prefer **pinned** or **semver range** installs (like `@^0.1.4`), and update intentionally.
45
+
46
+ Avoid using `@latest` in config:
47
+
48
+ - it can make startup slower (npm resolution/install on startup)
49
+ - it makes behavior less deterministic
50
+ - depending on caching, you may not get the upgrade behavior you expect
51
+
52
+ To find the newest version and changelog:
53
+
54
+ - NPM versions: https://www.npmjs.com/package/@openontology/opencode-palantir
55
+ - GitHub releases: https://github.com/anand-testcompare/opencode-palantir/releases
56
+ - Repo changelog: `CHANGELOG.md`
57
+
58
+ ### (Optional) Install per-project
28
59
 
29
60
  In your project repo, add the plugin as a dependency inside `.opencode/` (keeps plugin deps separate
30
61
  from your app deps):
@@ -35,7 +66,7 @@ mkdir -p .opencode
35
66
  cat > .opencode/package.json <<'EOF'
36
67
  {
37
68
  "dependencies": {
38
- "@openontology/opencode-palantir": "^0.1.1"
69
+ "@openontology/opencode-palantir": "^0.1.4"
39
70
  }
40
71
  }
41
72
  EOF
@@ -45,8 +76,6 @@ EOF
45
76
 
46
77
  Then create a tiny wrapper file in `.opencode/plugins/`:
47
78
 
48
- Create a tiny wrapper file in `.opencode/plugins/`:
49
-
50
79
  ```bash
51
80
  mkdir -p .opencode/plugins
52
81
 
@@ -59,62 +88,149 @@ EOF
59
88
 
60
89
  OpenCode automatically loads `.js`/`.ts` files from `.opencode/plugins/` at startup.
61
90
 
62
- > If your OpenCode setup uses an `opencode.json` / `opencode.jsonc` that restricts plugin loading,
63
- > make sure `.opencode/plugins/` (or the specific plugin file) is included.
91
+ ## Environment variables (Foundry MCP)
92
+
93
+ This plugin never writes secrets to disk. In `opencode.jsonc`, the token is always referenced as
94
+ `{env:FOUNDRY_TOKEN}`.
95
+
96
+ ### Variables
97
+
98
+ - `FOUNDRY_URL`
99
+ - Foundry base URL (used for auto-bootstrap and can be used as a default for `/setup-palantir-mcp`)
100
+ - Example: `https://YOUR-STACK.palantirfoundry.com`
101
+ - `FOUNDRY_TOKEN`
102
+ - Foundry token used by `palantir-mcp` for tool discovery
103
+ - Must be exported (not just set in a shell)
104
+
105
+ ### Recommended setup (zsh, macOS/Linux)
106
+
107
+ Use your existing shell secrets file. For example, if you already source `~/.shell_secrets` from
108
+ `~/.zshrc`, add:
109
+
110
+ ```zsh
111
+ export FOUNDRY_URL='https://YOUR-STACK.palantirfoundry.com'
112
+ export FOUNDRY_TOKEN='YOUR_TOKEN'
113
+ ```
114
+
115
+ Lock it down:
116
+
117
+ ```bash
118
+ chmod 600 ~/.shell_secrets
119
+ ```
120
+
121
+ Ensure `~/.zshrc` sources it:
122
+
123
+ ```zsh
124
+ if [ -f "$HOME/.shell_secrets" ]; then
125
+ source "$HOME/.shell_secrets"
126
+ fi
127
+ ```
128
+
129
+ If you still see “token not exported” errors, verify `echo $FOUNDRY_TOKEN` prints a value and that
130
+ it’s `export`ed in the environment where OpenCode is launched.
64
131
 
65
- ### 3) Get `docs.parquet`
132
+ ## Docs tools (Palantir public docs)
66
133
 
67
- This package does **not** ship with docs bundled. You have two options:
134
+ The docs DB is a local file:
68
135
 
69
- #### Option A (recommended): fetch inside OpenCode
136
+ - `data/docs.parquet` (in your repo root)
70
137
 
71
- In OpenCode, run:
138
+ ### First-run behavior
72
139
 
73
- - `/refresh-docs`
140
+ On startup and tool usage, the plugin automatically ensures `data/docs.parquet` exists by using a
141
+ prebuilt snapshot (download/copy). In most repos, docs tools should work without any manual setup.
74
142
 
75
- This downloads the docs and writes them to `data/docs.parquet` in your project root.
143
+ ### Refresh commands
76
144
 
77
- #### Option B: download a prebuilt Parquet file
145
+ - `/refresh-docs` (recommended)
146
+ - Force refresh from a prebuilt snapshot (no live rescrape)
147
+ - `/refresh-docs-rescrape` (unsafe/experimental fallback)
148
+ - Live-rescrapes palantir.com docs and rebuilds `data/docs.parquet`
149
+ - Use only when snapshot download/copy is blocked
78
150
 
79
- Download `data/docs.parquet` from this GitHub repo and place it at:
151
+ ### Tools
80
152
 
81
- - `<your-project>/data/docs.parquet`
153
+ - `get_doc_page`
154
+ - Retrieve a doc page by URL, or fuzzy match by query
155
+ - `list_all_docs`
156
+ - List docs with pagination and optional query/scope filtering
82
157
 
83
- ## Using the tools
158
+ ## Foundry MCP helpers
84
159
 
85
- When installed, this plugin exposes:
160
+ This plugin registers Foundry commands and agents automatically at startup (config-driven).
86
161
 
87
- - **`get_doc_page`** - Retrieve a specific doc page by URL
88
- - **`list_all_docs`** - List all available documentation pages
162
+ ### Auto-bootstrap (no command required)
89
163
 
90
- If `data/docs.parquet` is missing, both tools will instruct you to run `/refresh-docs`.
164
+ If you set both `FOUNDRY_TOKEN` and `FOUNDRY_URL`, the plugin will automatically and idempotently
165
+ patch repo-root `opencode.jsonc` to initialize:
91
166
 
92
- ## Foundry MCP setup helpers
167
+ - `mcp.palantir-mcp` local server config
168
+ - global tool deny: `tools.palantir-mcp_* = false`
169
+ - per-agent allow/deny toggles under `foundry-librarian` and `foundry`
93
170
 
94
- This plugin also provides two OpenCode commands to set up `palantir-mcp` with project-scoped tool
95
- gating and Foundry sub-agents:
171
+ ### Guided setup and maintenance
96
172
 
97
- - **`/setup-palantir-mcp <foundry_api_url>`**
173
+ - `/setup-palantir-mcp <foundry_api_url>`
98
174
  - Creates/patches repo-root `opencode.jsonc`
99
175
  - Adds `mcp.palantir-mcp` (if missing) as a local `npx palantir-mcp --foundry-api-url ...` server
100
176
  - Enforces global deny: `tools.palantir-mcp_* = false`
101
177
  - Creates `foundry-librarian` and `foundry` agents
102
- - Dynamically discovers the current `palantir-mcp` tool list and writes explicit `true/false`
103
- per-tool toggles under each Foundry agent
104
- - **`/rescan-palantir-mcp-tools`**
105
- - Re-discovers the `palantir-mcp` tool list and adds any missing explicit toggles
178
+ - Discovers `palantir-mcp` tools and writes explicit `true/false` toggles under each agent
179
+ - `/rescan-palantir-mcp-tools`
180
+ - Re-discovers the `palantir-mcp` tool list and adds missing explicit toggles
106
181
  - Never overwrites existing `palantir-mcp_*` toggles
107
182
 
108
- Auth is always env-only. The token is referenced as `{env:FOUNDRY_TOKEN}` and is never written to
109
- disk.
183
+ ### About palantir-mcp versions (important)
184
+
185
+ The generated MCP server uses `npx -y palantir-mcp ...` by default.
110
186
 
111
- ## Setup (this repo)
187
+ Notes:
188
+
189
+ - First run can be slow (npx may need to download/install).
190
+ - `@latest` / unpinned installs are less deterministic.
191
+
192
+ Recommendation: once you’re set up, pin the version in `opencode.jsonc`:
193
+
194
+ ```jsonc
195
+ {
196
+ "mcp": {
197
+ "palantir-mcp": {
198
+ "type": "local",
199
+ "command": [
200
+ "npx",
201
+ "-y",
202
+ "palantir-mcp@<version>",
203
+ "--foundry-api-url",
204
+ "https://YOUR-STACK.palantirfoundry.com"
205
+ ]
206
+ }
207
+ }
208
+ }
209
+ ```
210
+
211
+ ## Development (this repo)
212
+
213
+ ### Setup
112
214
 
113
215
  ```bash
114
- bun install
216
+ mise run setup
115
217
  ```
116
218
 
117
- ## Fetching Documentation
219
+ ### Common tasks
220
+
221
+ - Build: `mise run build`
222
+ - Test: `mise run test`
223
+ - Lint: `mise run lint`
224
+ - Typecheck: `mise run typecheck`
225
+ - Format: `mise run format`
226
+
227
+ ### Smoke test the built artifact
228
+
229
+ ```bash
230
+ mise run smoke
231
+ ```
232
+
233
+ ### Fetch docs parquet (local dev)
118
234
 
119
235
  Fetch all Palantir docs into `data/docs.parquet` (~2 minutes, ~17MB file):
120
236
 
@@ -122,9 +238,7 @@ Fetch all Palantir docs into `data/docs.parquet` (~2 minutes, ~17MB file):
122
238
  bun run src/docs/fetch-cli.ts
123
239
  ```
124
240
 
125
- ## Querying the Data
126
-
127
- ### Schema
241
+ ### Parquet schema (local dev)
128
242
 
129
243
  The Parquet file contains a single row group with the following columns:
130
244
 
@@ -137,7 +251,7 @@ The Parquet file contains a single row group with the following columns:
137
251
  | `meta` | string | JSON-encoded metadata |
138
252
  | `fetched_at` | string | ISO 8601 timestamp of when fetched |
139
253
 
140
- ### Bun
254
+ Example (Bun):
141
255
 
142
256
  ```typescript
143
257
  import { parquetReadObjects } from 'hyparquet';
@@ -147,76 +261,6 @@ const file = await Bun.file('data/docs.parquet').arrayBuffer();
147
261
  // List all pages (url + title only)
148
262
  const pages = await parquetReadObjects({ file, columns: ['url', 'title'] });
149
263
  console.log(`${pages.length} pages`);
150
-
151
- // Search by title
152
- const matches = pages.filter((p) => p.title.includes('Pipeline'));
153
- console.log(matches.slice(0, 10));
154
-
155
- // Get a specific page's content by row index
156
- const urlToRow = new Map(pages.map((p, i) => [p.url, i]));
157
- const rowIndex = urlToRow.get('/foundry/ontology/overview/');
158
- if (rowIndex !== undefined) {
159
- const [page] = await parquetReadObjects({
160
- file,
161
- rowStart: rowIndex,
162
- rowEnd: rowIndex + 1,
163
- });
164
- console.log(page.content);
165
- }
166
- ```
167
-
168
- ## OpenCode Tools
169
-
170
- When installed as an OpenCode plugin, exposes:
171
-
172
- - **`get_doc_page`** - Retrieve a specific doc page by URL
173
- - **`list_all_docs`** - List all available documentation pages
174
- - **`/refresh-docs`** - Command hook to re-fetch all documentation
175
-
176
- ### Installing in OpenCode (this repo only)
177
-
178
- For local development against `dist/`, you can point the wrapper at the built artifact:
179
-
180
- ```bash
181
- mkdir -p .opencode/plugins
182
-
183
- cat > .opencode/plugins/opencode-palantir.js <<'EOF'
184
- import plugin from '../../dist/index.js';
185
-
186
- export default plugin;
187
- EOF
188
- ```
189
-
190
- ## Development
191
-
192
- Build the plugin:
193
-
194
- ```bash
195
- mise run build
196
- ```
197
-
198
- Run tests:
199
-
200
- ```bash
201
- mise run test
202
- ```
203
-
204
- Smoke test the built artifact (build + verify tools load from `dist/index.js`):
205
-
206
- ```bash
207
- mise run smoke
208
- ```
209
-
210
- Lint code:
211
-
212
- ```bash
213
- mise run lint
214
- ```
215
-
216
- Format with Prettier:
217
-
218
- ```bash
219
- mise run format
220
264
  ```
221
265
 
222
266
  ## Release notes