feat: prefer workspace key path for google maps

This commit is contained in:
Stefano Fiorini
2026-03-10 00:35:25 -05:00
parent 7361b31c7c
commit d3a2b9faae
4 changed files with 142 additions and 7 deletions

View File

@@ -18,7 +18,10 @@ Google Maps traffic/ETA helper CLI using Geocoding API and Routes API.
Preferred: Preferred:
- `GOOGLE_MAPS_API_KEY` environment variable - `GOOGLE_MAPS_API_KEY` environment variable
Fallback key file: Preferred key file:
- `~/.openclaw/workspace/.clawdbot/credentials/google-maps/apikey.txt`
Legacy fallback key file:
- `~/.openclaw/credentials/google-maps/apikey.txt` - `~/.openclaw/credentials/google-maps/apikey.txt`
Required Google APIs for the key: Required Google APIs for the key:

View File

@@ -0,0 +1,33 @@
# Google Maps Workspace Key Repo Sync Design
**Problem:** The live local `google-maps` integration was updated to prefer the workspace credential path for the API key, but the repository source copy still points at the legacy path. The docs were partially updated, and the repo needs to be the source of truth again before committing and pushing.
## Current state
- Live local integration [traffic.js](/Users/stefano/.openclaw/workspace/integrations/google-maps/traffic.js) prefers:
- `~/.openclaw/workspace/.clawdbot/credentials/google-maps/apikey.txt`
- with legacy fallback `~/.openclaw/credentials/google-maps/apikey.txt`
- Repo copy [traffic.js](/Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/integrations/google-maps/traffic.js) still points only at the legacy path.
- Repo doc [google-maps.md](/Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/docs/google-maps.md) now documents the new canonical path and legacy fallback.
## Approaches considered
1. Recommended: sync the repo source copy to match the live integration exactly and keep the docs aligned.
- Minimal change.
- Restores source/runtime consistency.
- Safe to commit and push.
2. Revert the live integration to match the repo.
- Wrong direction because the live behavior is already verified and desired.
3. Update only docs and leave source drift.
- Not acceptable because the repository would remain misleading.
## Selected design
- Update the repo copy of `integrations/google-maps/traffic.js` to match the live integration behavior:
- prefer `~/.openclaw/workspace/.clawdbot/credentials/google-maps/apikey.txt`
- keep `~/.openclaw/credentials/google-maps/apikey.txt` as legacy fallback
- Keep the repo docs aligned with that behavior.
- Verify the repo copy via code inspection and a live ETA command using the runtime integration.
- Commit only the repo changes and push to `origin/main`.

View File

@@ -0,0 +1,92 @@
# Google Maps Workspace Key Repo Sync Implementation Plan
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
**Goal:** Sync the `stef-openclaw-skills` repository source and docs with the verified Google Maps workspace-key behavior, then commit and push the change.
**Architecture:** Apply the same path-resolution change from the live integration to the repo copy, keep the docs aligned, and verify behavior with inspection plus a live ETA command. Commit only the repo files that reflect this feature.
**Tech Stack:** Node.js CLI, local file path resolution, git
---
### Task 1: Sync repo source copy
**Files:**
- Modify: `/Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/integrations/google-maps/traffic.js`
**Step 1: Write the failing check**
Run:
```bash
sed -n '1,50p' /Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/integrations/google-maps/traffic.js
```
Expected: only the legacy path is present and there is no workspace credential fallback array.
**Step 2: Write minimal implementation**
Apply the same path lookup logic as the live local integration:
- prefer `~/.openclaw/workspace/.clawdbot/credentials/google-maps/apikey.txt`
- keep `~/.openclaw/credentials/google-maps/apikey.txt` as fallback
- keep `GOOGLE_MAPS_API_KEY` support unchanged
**Step 3: Verify source sync**
Run:
```bash
sed -n '1,60p' /Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/integrations/google-maps/traffic.js
```
Expected: workspace path is primary and legacy path remains fallback.
### Task 2: Verify docs alignment
**Files:**
- Modify or confirm: `/Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/docs/google-maps.md`
**Step 1: Verify doc text**
Run:
```bash
sed -n '1,80p' /Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/docs/google-maps.md
```
Expected: docs show workspace key path as preferred and legacy path as fallback.
### Task 3: Verify behavior and publish
**Files:**
- Commit: `/Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/integrations/google-maps/traffic.js`
- Commit: `/Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/docs/google-maps.md`
- Commit: `/Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/docs/plans/2026-03-10-google-maps-workspace-key-repo-sync-design.md`
- Commit: `/Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/docs/plans/2026-03-10-google-maps-workspace-key-repo-sync.md`
**Step 1: Run live verification**
Run:
```bash
node /Users/stefano/.openclaw/workspace/integrations/google-maps/traffic.js eta --from "DFW Airport" --to "Downtown Dallas" --departAt now
```
Expected: JSON ETA output succeeds with the workspace key file.
**Step 2: Inspect git diff**
Run:
```bash
git -C /Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills diff -- integrations/google-maps/traffic.js docs/google-maps.md docs/plans/2026-03-10-google-maps-workspace-key-repo-sync-design.md docs/plans/2026-03-10-google-maps-workspace-key-repo-sync.md
```
Expected: only the intended repo sync changes appear.
**Step 3: Commit**
Run:
```bash
git -C /Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills add integrations/google-maps/traffic.js docs/google-maps.md docs/plans/2026-03-10-google-maps-workspace-key-repo-sync-design.md docs/plans/2026-03-10-google-maps-workspace-key-repo-sync.md && git -C /Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills commit -m "docs: sync google maps workspace key path"
```
Expected: commit succeeds.
**Step 4: Push**
Run:
```bash
git -C /Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills push origin main
```
Expected: push succeeds.

View File

@@ -2,7 +2,11 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const DEFAULT_KEY_PATH = path.join(process.env.HOME || '', '.openclaw/credentials/google-maps/apikey.txt'); const DEFAULT_KEY_PATH = path.join(process.env.HOME || '', '.openclaw/workspace/.clawdbot/credentials/google-maps/apikey.txt');
const FALLBACK_KEY_PATHS = [
DEFAULT_KEY_PATH,
path.join(process.env.HOME || '', '.openclaw/credentials/google-maps/apikey.txt'),
];
function parseArgs(argv) { function parseArgs(argv) {
const out = { _: [] }; const out = { _: [] };
@@ -44,11 +48,14 @@ function must(opts, keys) {
function readApiKey(opts) { function readApiKey(opts) {
if (process.env.GOOGLE_MAPS_API_KEY) return process.env.GOOGLE_MAPS_API_KEY.trim(); if (process.env.GOOGLE_MAPS_API_KEY) return process.env.GOOGLE_MAPS_API_KEY.trim();
const p = opts.keyPath || DEFAULT_KEY_PATH; const candidates = opts.keyPath ? [opts.keyPath] : FALLBACK_KEY_PATHS;
if (!fs.existsSync(p)) throw new Error(`API key file not found: ${p}`); for (const p of candidates) {
if (!fs.existsSync(p)) continue;
const key = fs.readFileSync(p, 'utf8').trim(); const key = fs.readFileSync(p, 'utf8').trim();
if (!key) throw new Error(`API key file is empty: ${p}`); if (!key) throw new Error(`API key file is empty: ${p}`);
return key; return key;
}
throw new Error(`API key file not found. Checked: ${candidates.join(', ')}`);
} }
async function geocode(address, key) { async function geocode(address, key) {