obsidian-wikilinks 0.2.0 → 0.2.2

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 (2) hide show
  1. package/README.md +122 -45
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # obsidian-wikilinks
2
2
 
3
+ [![Claude Code](https://img.shields.io/badge/Claude_Code-supported-D97757?logo=claude&logoColor=white)](#install-in-claude-code)
4
+ [![Codex](https://img.shields.io/badge/Codex-supported-000000?logoColor=white)](#install-in-codex)
5
+ [![OpenCode](https://img.shields.io/badge/OpenCode-supported-FBBF24?logo=opencode&logoColor=white)](#install-in-opencode)
6
+ [![npm](https://img.shields.io/npm/v/obsidian-wikilinks?logo=npm&logoColor=white&color=CB3837)](https://www.npmjs.com/package/obsidian-wikilinks)
7
+ [![CI](https://github.com/DepickereSven/obsidian-wikilinks/actions/workflows/ci.yml/badge.svg)](https://github.com/DepickereSven/obsidian-wikilinks/actions/workflows/ci.yml)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue)](LICENSE)
9
+
3
10
  Resolve `[[wikilinks]]` typed in a Codex, Claude Code, or OpenCode prompt to
4
11
  absolute paths in your Obsidian vault, and inject them as context so the agent
5
12
  reads the right notes.
@@ -42,11 +49,20 @@ claude plugin install obsidian-wikilinks@depickeresven-obsidian-wikilinks
42
49
 
43
50
  ### From npm (recommended)
44
51
 
52
+ The `opencode plugin` command installs the package and adds it to your config.
53
+ For every project:
54
+
55
+ ```bash
56
+ opencode plugin obsidian-wikilinks --global
57
+ ```
58
+
59
+ For one project only, run it without the flag inside that repo:
60
+
45
61
  ```bash
46
62
  opencode plugin obsidian-wikilinks
47
63
  ```
48
64
 
49
- That installs the package and adds it to your config. Or add it by hand:
65
+ You can also add it by hand:
50
66
 
51
67
  ```json
52
68
  {
@@ -58,9 +74,6 @@ That installs the package and adds it to your config. Or add it by hand:
58
74
  Use `~/.config/opencode/opencode.json` for every project, or `opencode.json` in
59
75
  a repo for that project only.
60
76
 
61
- > The package is not on npm yet. Until it is published, use one of the local
62
- > options below, or publish it yourself from a checkout with `npm publish`.
63
-
64
77
  ### From a local checkout
65
78
 
66
79
  OpenCode loads any `.js` / `.ts` file in a plugin directory, and follows
@@ -75,7 +88,7 @@ ln -s ~/.config/opencode/obsidian-wikilinks/plugin/obsidian-wikilinks.js ~/.conf
75
88
  Use `.opencode/plugin/` instead of `~/.config/opencode/plugin/` to enable it for
76
89
  a single project only.
77
90
 
78
- Alternatively, reference the checkout from your config instead of symlinking
91
+ Alternatively, reference the checkout from your config instead of symlinking.
79
92
  `plugin` entries accept `file://` URLs and paths relative to the config file:
80
93
 
81
94
  ```json
@@ -120,6 +133,30 @@ Review the notes in [[Meetings]] and prepare a weekly summary.
120
133
  When a name is ambiguous, the plugin provides up to three candidate paths. If
121
134
  there is no match, it says so instead of guessing.
122
135
 
136
+ ### What the agent receives
137
+
138
+ The injected context is plain text, one line per distinct wikilink:
139
+
140
+ ```text
141
+ Obsidian wikilink resolution (vault: /Users/you/Documents/Obsidian):
142
+ [[Website Redesign]] -> /Users/you/Documents/Obsidian/Projects/Website Redesign.md
143
+ [[Meetings]] -> /Users/you/Documents/Obsidian/Meetings/
144
+ [[Notes]] -> ambiguous, candidates: /path/Notes.md, /path/Old/Notes.md
145
+ [[Nope]] -> no match found in vault /Users/you/Documents/Obsidian
146
+ Read the resolved file(s) when their content is relevant to the request.
147
+ ```
148
+
149
+ Folder matches end in a path separator. Repeated wikilinks are resolved once.
150
+
151
+ ### What gets indexed
152
+
153
+ The whole vault is walked, notes and folders alike, with two exclusions:
154
+
155
+ - Anything whose name starts with a dot.
156
+ - The folders `.obsidian`, `.trash`, `.git`, and `.vault-meta`.
157
+
158
+ A note inside a hidden folder will therefore never resolve.
159
+
123
160
  ## Vault selection
124
161
 
125
162
  Vault path resolution order:
@@ -131,8 +168,8 @@ Vault path resolution order:
131
168
  (or `$OPENCODE_CONFIG_DIR` / `$XDG_CONFIG_HOME` when set)
132
169
  2. The other hosts' config files, as a compatibility fallback
133
170
  3. `$OBSIDIAN_VAULT` environment variable
134
- 4. Obsidian's vault registry auto-detected (prefers the open vault, else most
135
- recently opened). Cross-platform (macOS / Windows / Linux).
171
+ 4. Obsidian's vault registry, auto-detected (prefers the open vault, else the
172
+ most recently opened). Cross-platform (macOS / Windows / Linux).
136
173
  5. `~/Documents/Obsidian` (default fallback)
137
174
 
138
175
  You only need an explicit override if you have **multiple vaults** and want to
@@ -142,19 +179,53 @@ pin a specific one. Create the config file for your host with:
142
179
  { "vault": "/Users/you/Documents/Obsidian" }
143
180
  ```
144
181
 
145
- The plugin itself is identical on every device. Update Claude Code with
146
- `claude plugin update obsidian-wikilinks`. Re-run the Codex `plugin add` command
147
- to install an updated version there. For OpenCode, re-run `opencode plugin
148
- obsidian-wikilinks`, or `git pull` in the checkout.
182
+ ## Updating
183
+
184
+ The plugin itself is identical on every device.
185
+
186
+ - Claude Code: `claude plugin update obsidian-wikilinks`
187
+ - Codex: re-run the `codex plugin add` command to install a newer version.
188
+ - OpenCode: re-run `opencode plugin obsidian-wikilinks`, or `git pull` in the
189
+ checkout.
149
190
 
150
191
  ## Environment variables
151
192
 
152
- | Variable | Purpose |
153
- |---------------------------------|--------------------------------------------------------------|
154
- | `OBSIDIAN_VAULT` | Vault path, used when no host config file sets one |
155
- | `OBSIDIAN_WIKILINKS_RESOLVER` | Path to `wikilink-resolver.py` (OpenCode only) |
156
- | `OBSIDIAN_WIKILINKS_PYTHON` | Python interpreter to use (default `python3`, OpenCode only) |
157
- | `OBSIDIAN_WIKILINKS_TIMEOUT_MS` | Resolver timeout in ms (default `10000`, OpenCode only) |
193
+ | Variable | Purpose |
194
+ |---------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
195
+ | `OBSIDIAN_VAULT` | Vault path, used when no host config file sets one |
196
+ | `OBSIDIAN_WIKILINKS_HOST` | Force the host the resolver assumes: `codex`, `claude`, `opencode`. Normally auto-detected, and the OpenCode plugin sets it for you |
197
+ | `OBSIDIAN_WIKILINKS_RESOLVER` | Path to `wikilink-resolver.py` (OpenCode only) |
198
+ | `OBSIDIAN_WIKILINKS_PYTHON` | Python interpreter to use (default `python3`, OpenCode only) |
199
+ | `OBSIDIAN_WIKILINKS_TIMEOUT_MS` | Resolver timeout in ms (default `10000`, OpenCode only) |
200
+
201
+ ## Troubleshooting
202
+
203
+ The resolver is deliberately silent: on any problem it exits without output and
204
+ your prompt is passed through untouched. That makes the failure modes below look
205
+ identical from the outside, so work through them in order.
206
+
207
+ **Nothing is injected at all.**
208
+
209
+ - Check `python3 --version` in the same shell the agent runs in. No `python3` on
210
+ PATH means no resolution. On OpenCode, point `OBSIDIAN_WIKILINKS_PYTHON` at
211
+ your interpreter.
212
+ - On Codex, run `/hooks` in a new thread and confirm the plugin's
213
+ `UserPromptSubmit` hook is trusted. Untrusted hooks never execute.
214
+ - Confirm the vault directory actually exists. The resolver exits early when the
215
+ resolved path is not a directory, including for the `~/Documents/Obsidian`
216
+ fallback.
217
+
218
+ **The wrong vault is used.** Run through the resolution order above. A stale
219
+ config file for *another* host wins over `$OBSIDIAN_VAULT`, because step 2 comes
220
+ first. Delete it, or set an explicit override for your own host.
221
+
222
+ **A note resolves to `no match found`.** Check that it is not inside a hidden
223
+ folder (see [What gets indexed](#what-gets-indexed)), and that the vault in the
224
+ output line is the one you expect.
225
+
226
+ **Resolution is slow or times out on OpenCode.** The vault is walked on every
227
+ prompt containing a wikilink. On a very large vault, raise
228
+ `OBSIDIAN_WIKILINKS_TIMEOUT_MS` above its `10000` default.
158
229
 
159
230
  ## Development
160
231
 
@@ -166,42 +237,48 @@ npm run test:bun # same tests on Bun, the runtime OpenCode uses
166
237
  No dependencies to install: the plugin uses Node/Bun built-ins and the resolver
167
238
  is standard-library Python.
168
239
 
169
- ## Releasing
240
+ ### Releasing
170
241
 
171
- CI runs the test suite on Node 20/22/24 and on Bun for every push and pull
172
- request, and checks that the packed tarball ships both `plugin/` and `hooks/`.
242
+ Two workflows, chained.
173
243
 
174
- To cut a release:
244
+ `.github/workflows/ci.yml` runs the smoke tests on Node 20/22/24 and on Bun, and
245
+ checks the packed tarball ships both `plugin/` and `hooks/`. It runs on pull
246
+ requests and on pushes to `main`, not on every branch, so a pull request is
247
+ never tested twice.
175
248
 
176
- ```bash
177
- npm version patch # or minor / major
178
- git push --follow-tags
179
- gh release create "v$(node -p 'require("./package.json").version')" --generate-notes
180
- ```
249
+ `.github/workflows/publish.yml` starts only when a CI run on `main` finishes
250
+ successfully, checks out that exact commit, and asks npm whether the version in
251
+ `package.json` already exists:
252
+
253
+ - **Already on npm**: nothing is released. This is what an ordinary push to
254
+ `main` does.
255
+ - **Not on npm**: it publishes with provenance, tags the commit, and opens a
256
+ GitHub release with notes generated from the merged commits.
181
257
 
182
- `npm version` also rewrites the Claude Code and Codex manifests through
183
- `scripts/sync-versions.mjs`, so all three stay on one version. Publishing the
184
- GitHub release triggers `.github/workflows/publish.yml`, which re-runs the
185
- tests, verifies the tag matches `package.json`, refuses to overwrite a version
186
- already on npm, and publishes with provenance.
258
+ So a version bump landing on `main` *is* the release, and it can only happen
259
+ after CI has gone green on that commit.
187
260
 
188
- The workflow authenticates through **npm trusted publishing** (OIDC), so no
189
- token is stored in the repository. One-time setup: on npmjs.com, open the
190
- package's *Settings -> Trusted publishers*, and add this repository with
191
- workflow `publish.yml`.
261
+ To cut one:
192
262
 
193
- Trusted-publisher settings live on the package, so they can only be configured
194
- once the package exists. Do the **first** publish by hand from a checkout with
195
- `npm publish --access public`, then wire up the trusted publisher and let the
196
- workflow handle every release after that.
263
+ ```bash
264
+ npm version patch --no-git-tag-version # or minor / major
265
+ git commit -am "Release $(node -p 'require("./package.json").version')"
266
+ git push
267
+ ```
197
268
 
198
- To use a granular access token instead, save it as the `NPM_TOKEN` secret and
199
- uncomment the `NODE_AUTH_TOKEN` block in the workflow.
269
+ `--no-git-tag-version` matters: the workflow creates the tag, so creating one
270
+ locally would collide. The bump still runs `scripts/sync-versions.mjs`, keeping
271
+ the Claude Code and Codex manifests on the same version as `package.json`. CI
272
+ fails the build if they ever drift.
200
273
 
201
- Use the workflow's manual trigger (`workflow_dispatch`) with *dry run* enabled
202
- to rehearse a publish without releasing anything.
274
+ Use the publish workflow's manual trigger (`workflow_dispatch`) with *dry run*
275
+ enabled to rehearse a publication without releasing anything.
203
276
 
204
277
  ## Requirements
205
278
 
206
- - `python3` on PATH (standard-library only; no pip installs).
207
- - OpenCode only: no extra dependencies the plugin uses Node/Bun built-ins.
279
+ - `python3` on PATH. Standard library only, no pip installs.
280
+ - OpenCode only: no extra dependencies, the plugin uses Node/Bun built-ins.
281
+
282
+ ## License
283
+
284
+ [MIT](LICENSE) © Sven Depickere
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "obsidian-wikilinks",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Resolve Obsidian [[wikilinks]] in coding-agent prompts to local vault paths and inject them as context.",
5
5
  "type": "module",
6
6
  "main": "plugin/obsidian-wikilinks.js",