Commit graph

3 commits

Author SHA1 Message Date
Souta
de3d0d6c32 chore(security): replace personal info with generic placeholders (0.3.2)
Security check turned up three places where the maintainer's
personal info had ended up in tracked source:

- plugin/tests/AdapterPatcher.test.ts:15
  `target.greet('souta')` → `target.greet('alice')`
- plugin/tests/pathUtils.test.ts:15
  `/home/souta/work/VaultDev/` → `/home/alice/vault/`
- plugin/scripts/dev-install.mjs
  Default fallback for the dev vault path was hard-coded to
  `../../SelfArchive-dev` (the maintainer's own dev vault folder
  name). Renamed to the generic `../../dev-vault`. The
  `REMOTE_SSH_DEV_VAULT` env var still wins, and the script accepts
  a positional argv override too — the maintainer's actual
  `SelfArchive-dev` keeps working with
  `REMOTE_SSH_DEV_VAULT=/path/to/SelfArchive-dev npm run build:full`.

What stays:
- `github.com/sotashimozono/...` in every Go file's import path —
  Go module canonical URL; this matches the repo URL on GitHub
  and isn't replaceable.
- `work/VaultDev` mentions in README / docs / a couple of test
  fixtures — generic enough not to identify the maintainer
  (anyone could name a folder that), kept as-is.

No private keys / tokens / IPs / emails / hostnames were in the
tree to begin with — those live only in the user's local
`data.json` and ssh agent, not in the repo.

Bumps to 0.3.2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 11:30:25 +09:00
Souta
874e4338ae feat(plugin): auto-deploy obsidian-remote-server over SSH
The "Debug: test RPC tunnel" command now ships, restarts, and verifies
the daemon end-to-end without any manual scp + nohup steps. Build
pipeline grew an `npm run build:server` that cross-compiles the Go
daemon for Linux/amd64 and stages it next to main.js so the plugin
can find it at runtime.

ServerDeployer (plugin/src/transport/ServerDeployer.ts)
- mkdir -p ~/.obsidian-remote && chmod 700 it
- pkill any prior daemon and remove stale socket / token
- SFTP-upload the local binary, chmod +x
- nohup the daemon with --vault-root / --socket / --token-file
  / --verbose, redirect stdout+stderr to ~/.obsidian-remote/server.log,
  detach
- poll the token file for up to 5s; return the token + paths
- stop() helper for the inverse: pkill + cleanup

Built on a tiny `DeployerSshClient` interface so unit tests don't
have to bring up a real SSH session. shellQuote single-quotes every
argument so paths with spaces survive the shell.

SftpClient
- uploadFile(localPath, remotePath) — sftp.fastPut wrapper.
- exec(cmd) — runs a one-shot command, collects stdout/stderr/exit.
  Used for mkdir / pkill / chmod / nohup. Long-running streams must
  not go through here (they'd never close).

Build pipeline
- plugin/scripts/build-server.mjs cross-compiles
  ./cmd/obsidian-remote-server with GOOS=linux GOARCH=amd64
  CGO_ENABLED=0 and writes the result to plugin/server-bin/
  obsidian-remote-server-linux-amd64. Falls back to
  ~/tools/go-portable/go on the dev box when go isn't on PATH.
  REMOTE_SSH_SKIP_SERVER_BUILD=1 short-circuits for hosts without a
  Go toolchain.
- dev-install.mjs additionally copies plugin/server-bin/* into
  <vault>/.obsidian/plugins/remote-ssh/server-bin/ so the plugin
  finds the binary at runtime.
- New scripts: `npm run build:server`, `npm run build:full`
  (server + plugin + install in one shot).
- Root .gitignore now excludes plugin/server-bin/.

main.ts
- locateDaemonBinary() resolves
  <vault>/.obsidian/plugins/<id>/server-bin/obsidian-remote-server-
  linux-amd64; returns null when missing.
- debugTestRpcTunnel():
    1. locateDaemonBinary, error early when missing
    2. ServerDeployer.deploy(...) ships and starts the daemon
    3. openUnixStream + establishRpcConnection
    4. RpcRemoteFsClient.list(activeRemoteBasePath) for the smoke
       check, log each step, surface a Notice with daemon version.

Tests (vitest)
- ServerDeployer.test.ts (8 cases): order of mkdir → kill → upload
  → chmod → start → wait-for-token, killExisting=false skips the
  kill, custom remote paths flow into the start command, paths
  with spaces are single-quoted, non-zero exit on a non-tolerant
  command surfaces, token-read retries until present, deadline is
  enforced, stop() runs pkill + cleanup.

Verification
- cd plugin && npx tsc --noEmit             clean
- cd plugin && npm test                     123 / 123 pass (8 new)
- cd plugin && npm run build:full           Go cross-compile (3.75
                                            MiB) + plugin build +
                                            dev vault install all
                                            green; bundle 382 KB
                                            (+3 KB over 5-D.3).

Dogfood (after merge)
1. cd plugin && npm run build:full
2. Reload the plugin in dev vault.
3. Run "Connect to remote vault" against the Panza profile.
4. Run "Debug: test RPC tunnel against obsidian-remote-server".
   Expect: a Notice with daemon version + entry count, and a
   per-step trace in console.log. No manual scp / start steps.

Follow-ups
- Phase 5-D.4: switch SftpDataAdapter's client over to
  RpcRemoteFsClient automatically when a profile carries an
  rpcSocketPath, with a fallback to the SFTP path.
- Cross-arch staging (linux/arm64, darwin/*) for non-amd64 hosts.
- ServerDeployer.stop wired into Plugin.disconnect so daemons don't
  outlive the Obsidian session.
2026-04-25 17:40:45 +09:00
Souta
21bb70a5d0 chore: monorepo restructure (plugin/ + server/ + proto/)
Move the entire Obsidian plugin tree under plugin/ and add an empty
server/ tree (Go) and proto/ directory so the upcoming
obsidian-remote-server daemon has a home in the same repo. The plugin
remains the only thing that builds today; the server is a hello-world
skeleton that prints "not implemented yet" and exits non-zero, with a
Makefile that knows how to cross-compile for linux/darwin × amd64/arm64
once real code lands.

Background:
  Approach A (vault-adapter monkey-patch) hit structural ceilings —
  vault index frozen at startup, third-party plugins bypass DataAdapter,
  empty-remote .obsidian read failures cascade through Templater/Kanban
  etc. We are pivoting to the VS Code Remote-SSH model: a small Go
  daemon on the remote host, JSON-RPC over a SSH-tunnelled WebSocket,
  fsnotify-driven push events, attachment serving over HTTP on the same
  socket. This restructure is the first mechanical step before the
  protocol and transport land.

Mechanical changes:
- git mv all plugin sources, manifest, configs, scripts, and tests
  into plugin/.
- plugin/scripts/dev-install.mjs walks one extra parent (`pluginRoot`
  → `repoRoot` → `..` for the dev vault) so REMOTE_SSH_DEV_VAULT
  defaulting still resolves to ../SelfArchive-dev relative to the
  repo, not to plugin/.
- CI: ci.yml runs lint/test/build with `working-directory: plugin`
  and a server job that builds + tests the Go module. release.yml
  builds out of plugin/ and uploads plugin/{main.js,manifest.json,
  styles.css}.
- Dependabot: npm directory becomes /plugin; new gomod directory /server.
- Labeler: paths re-anchored to plugin/, with new plugin/server/proto
  area labels.

Verification:
  cd plugin && npm install && npx tsc --noEmit && npm test (76/76)
  cd plugin && npm run build:install (367 KB; dev vault refreshed).
  Go side waits on CI (no Go toolchain on the dev host).
2026-04-25 10:52:52 +09:00
Renamed from scripts/dev-install.mjs (Browse further)