Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,18 @@ jobs:
done

echo "All lint checks passed!"

- name: Check VERSION consistency
run: |
FILE_VERSION=$(cat VERSION)
SCRIPT_VERSION=$(grep 'x-release-please-version' install.sh | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
UNINSTALL_VERSION=$(grep 'x-release-please-version' uninstall.sh | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
if [ "$FILE_VERSION" != "$SCRIPT_VERSION" ]; then
echo "ERROR: VERSION ($FILE_VERSION) != install.sh ($SCRIPT_VERSION)"
exit 1
fi
if [ "$FILE_VERSION" != "$UNINSTALL_VERSION" ]; then
echo "ERROR: VERSION ($FILE_VERSION) != uninstall.sh ($UNINSTALL_VERSION)"
exit 1
fi
echo "VERSION consistency check passed: $FILE_VERSION"
Comment thread
Qbandev marked this conversation as resolved.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,29 @@ mv ~/Documents/WaveNotes ~/Library/Mobile\ Documents/com~apple~CloudDocs/WaveNot
ln -s ~/Library/Mobile\ Documents/com~apple~CloudDocs/WaveNotes ~/Documents/WaveNotes
```

## Troubleshooting

### Widget fails after upgrading Wave Terminal to v0.14.0+

Wave Terminal v0.14.0 changed how authentication works for widget commands. If your note widget stopped working after upgrading Wave Terminal (you may see an authentication error or the editor fails to open), re-run the installer to regenerate the script:

```bash
wave-notes-setup
```

This updates `~/bin/wave-scratch.sh` with the new token exchange mechanism. No data is lost — your existing notes and configuration are preserved.
Comment thread
Qbandev marked this conversation as resolved.

If you installed via Homebrew, update first:

```bash
brew upgrade wave-notes-setup
wave-notes-setup
```

## Requirements

- macOS
- [Wave Terminal](https://www.waveterm.dev/)
- [Wave Terminal](https://www.waveterm.dev/) (v0.14.0+ supported with automatic swap token exchange)
- `jq` (optional, falls back to Python if missing)

## Security
Expand Down Expand Up @@ -133,7 +152,7 @@ The project includes a comprehensive test suite using [bats](https://github.com/
# Install bats
brew install bats-core

# Run all tests (77 tests)
# Run all tests (85 tests)
./test/run_tests.sh

# Or run bats directly
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
2.0.1
35 changes: 29 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash
# wave-notes-setup v1.0.0
# wave-notes-setup v2.0.1
# Configure Wave Terminal with a Warp-like notes system
# https://github.com/qbandev/wave-notes-setup

set -euo pipefail

VERSION="1.0.0"
VERSION="2.0.1" # x-release-please-version
SCRIPT_NAME="wave-notes-setup"

# Colors
Expand Down Expand Up @@ -316,7 +316,7 @@ install_scratchpad_script() {
# Generate the script with injected paths
cat > "$script_path" << 'SCRIPT_EOF'
#!/bin/bash
# Generated by wave-notes-setup v1.0.0
# Generated by wave-notes-setup v2.0.1
# Re-run wave-notes-setup to update paths

set -euo pipefail
Expand All @@ -338,6 +338,8 @@ find_wsh() {
return
fi
local paths=(
"$HOME/.config/waveterm/bin/wsh"
"$HOME/.waveterm/bin/wsh"
"$HOME/Library/Application Support/waveterm/bin/wsh"
"/usr/local/bin/wsh"
"/opt/homebrew/bin/wsh"
Expand All @@ -353,13 +355,34 @@ find_wsh() {

WSH_CMD=$(find_wsh)

if [[ -n "$WSH_CMD" ]]; then
"$WSH_CMD" edit "$FILEPATH"
else
if [[ -z "$WSH_CMD" ]]; then
echo "Error: 'wsh' command not found. Is Wave Terminal installed and running?" >&2
echo "File created at: $FILEPATH" >&2
exit 1
fi

# Wave Terminal v0.14.0+ token exchange for cmd controller blocks.
# wsh token outputs shell code setting multiple env vars needed by wsh
# commands (not just WAVETERM_JWT), so eval is required here — matching
# Wave's own integration at ~/Library/Application Support/waveterm/shell/bash/.bashrc
if [[ -z "${WAVETERM_JWT:-}" && -n "${WAVETERM_SWAPTOKEN:-}" ]]; then
eval "$("$WSH_CMD" token "$WAVETERM_SWAPTOKEN" bash 2>/dev/null)" || true
fi

ERR_FILE=$(mktemp)
if ! "$WSH_CMD" edit "$FILEPATH" 2>"$ERR_FILE"; then
wsh_err=$(cat "$ERR_FILE" 2>/dev/null)
rm -f "$ERR_FILE"
if printf '%s\n' "$wsh_err" | grep -q "WAVETERM"; then
echo "Error: Wave Terminal authentication failed." >&2
echo "Try: Re-run 'wave-notes-setup' to update configuration." >&2
else
echo "Error: Failed to open editor: $wsh_err" >&2
fi
echo "Note created at: $FILEPATH" >&2
exit 1
fi
rm -f "$ERR_FILE"
Comment on lines +372 to +385
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The temp file created by mktemp is not cleaned up when the wsh command succeeds. This will leave temporary files in /tmp that accumulate over time as users create notes. Add cleanup after the successful path (line 385 only handles the error case cleanup).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive. Line 385 is rm -f "$ERR_FILE" — that IS the success path cleanup. The error path cleans up at line 375, and the success path cleans up at line 385 (after the fi).

SCRIPT_EOF

# Replace placeholder with actual path
Expand Down
6 changes: 6 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
"package-name": "wave-notes-setup",
"changelog-path": "CHANGELOG.md",
"extra-files": [
"VERSION",
{
"type": "generic",
"path": "install.sh",
"glob": false
},
{
"type": "generic",
"path": "uninstall.sh",
"glob": false
Comment thread
Qbandev marked this conversation as resolved.
}
Comment on lines 8 to 19
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wave-notes-setup file contains an x-release-please-version marker (line 8) but is not included in the extra-files array. This means release-please will not update its version, leading to version drift. Either add wave-notes-setup to the extra-files array (if it should be kept in sync), or remove the x-release-please-version marker from that file (if it's not meant to be released).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same hallucination as before — there is no wave-notes-setup script file in the repository. Already addressed in previous thread.

]
}
Expand Down
86 changes: 86 additions & 0 deletions test/install.bats
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,92 @@ EOF
assert_file_contains "$BIN_DIR/wave-scratch.sh" "find_wsh()"
}

@test "install_scratchpad_script: find_wsh includes .config/waveterm/bin/wsh path" {
NOTES_DIR="$TEST_HOME/TestNotes"
BIN_DIR="$TEST_HOME/TestBin"
mkdir -p "$BIN_DIR"

install_scratchpad_script

assert_file_contains "$BIN_DIR/wave-scratch.sh" '.config/waveterm/bin/wsh'
}

@test "install_scratchpad_script: find_wsh includes .waveterm/bin/wsh path" {
NOTES_DIR="$TEST_HOME/TestNotes"
BIN_DIR="$TEST_HOME/TestBin"
mkdir -p "$BIN_DIR"

install_scratchpad_script

assert_file_contains "$BIN_DIR/wave-scratch.sh" '.waveterm/bin/wsh'
}
Comment thread
Qbandev marked this conversation as resolved.

@test "install_scratchpad_script: find_wsh lists new paths before old paths" {
NOTES_DIR="$TEST_HOME/TestNotes"
BIN_DIR="$TEST_HOME/TestBin"
mkdir -p "$BIN_DIR"

install_scratchpad_script

# .config/waveterm/bin/wsh should appear before /usr/local/bin/wsh
local config_line old_line
config_line=$(grep -n '.config/waveterm/bin/wsh' "$BIN_DIR/wave-scratch.sh" | head -1 | cut -d: -f1)
old_line=$(grep -n '/usr/local/bin/wsh' "$BIN_DIR/wave-scratch.sh" | head -1 | cut -d: -f1)
[ "$config_line" -lt "$old_line" ]
}

@test "install_scratchpad_script: contains swap token exchange logic" {
NOTES_DIR="$TEST_HOME/TestNotes"
BIN_DIR="$TEST_HOME/TestBin"
mkdir -p "$BIN_DIR"

install_scratchpad_script

assert_file_contains "$BIN_DIR/wave-scratch.sh" "WAVETERM_SWAPTOKEN"
assert_file_contains "$BIN_DIR/wave-scratch.sh" 'WSH_CMD.*token'
}

@test "install_scratchpad_script: uses mktemp for error handling" {
NOTES_DIR="$TEST_HOME/TestNotes"
BIN_DIR="$TEST_HOME/TestBin"
mkdir -p "$BIN_DIR"

install_scratchpad_script

assert_file_contains "$BIN_DIR/wave-scratch.sh" "mktemp"
assert_file_contains "$BIN_DIR/wave-scratch.sh" "ERR_FILE"
}

@test "install_scratchpad_script: swap token is backward compatible (no-op if JWT present)" {
NOTES_DIR="$TEST_HOME/TestNotes"
BIN_DIR="$TEST_HOME/TestBin"
mkdir -p "$BIN_DIR"

install_scratchpad_script

# The condition checks for empty WAVETERM_JWT, so it's a no-op if JWT is already set
# grep -F for fixed string since -z looks like a grep flag
grep -F 'WAVETERM_JWT' "$BIN_DIR/wave-scratch.sh" | grep -qF 'z "'
}

@test "VERSION consistency: VERSION file matches install.sh" {
local file_version
file_version=$(cat "$BATS_TEST_DIRNAME/../VERSION")
local script_version
script_version=$(grep 'x-release-please-version' "$BATS_TEST_DIRNAME/../install.sh" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')

[ "$file_version" = "$script_version" ]
}

@test "VERSION consistency: VERSION file matches uninstall.sh" {
local file_version
file_version=$(cat "$BATS_TEST_DIRNAME/../VERSION")
local script_version
script_version=$(grep 'x-release-please-version' "$BATS_TEST_DIRNAME/../uninstall.sh" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')

[ "$file_version" = "$script_version" ]
}
Comment thread
Qbandev marked this conversation as resolved.

# =============================================================================
# install_widgets() tests
# =============================================================================
Expand Down
4 changes: 2 additions & 2 deletions uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash
# wave-notes-setup uninstaller v1.0.0
# wave-notes-setup uninstaller v2.0.1
# https://github.com/qbandev/wave-notes-setup

set -euo pipefail

VERSION="1.0.0"
VERSION="2.0.1" # x-release-please-version

# Colors
RED='\033[0;31m'
Expand Down