* docs: improve readme especially auth which is complex no matter what
* docs: add changeset for README overhaul
---------
Co-authored-by: jpoehnelt-bot <jpoehnelt-bot@users.noreply.github.com>
Admin-only scopes (apps.*, cloud-identity.*, ediscovery, directory.readonly,
groups) require Workspace domain-admin access and cannot be granted to personal
@gmail.com accounts — Google returns 400 invalid_scope when they're included.
Changes:
- Add is_workspace_admin_scope() helper (mirrors is_app_only_scope())
to identify scopes that fail for personal Google accounts
- Exclude these scopes from the template_selects of the 'Recommended' preset
in run_discovery_scope_picker()
- Exclude them from the resolved scope list when the Recommended template
is confirmed
- Add 8 unit tests covering the new helper
Workspace admins can still access these scopes via 'Full Access' template
or by selecting them individually in the picker.
Note: this is complementary to PR #108 which filters alertcenter scopes
at the API-discovery level. This PR handles the broader set at the
recommendation layer.
Addresses #119 (Bug 1: admin scopes in Recommended preset)
Co-authored-by: Claude <noreply@anthropic.com>
Previously used dirs::config_dir() which resolves to different paths per
OS (~/Library/Application Support/gws on macOS, %APPDATA%\gws on Windows),
contradicting the documented ~/.config/gws/ path and causing users to place
config files in the wrong location (ref #119).
Now uses ~/.config/gws/ everywhere with a fallback to the legacy OS-specific
path for existing installs. Also consolidates duplicated dirs::config_dir()
calls in auth.rs and discovery.rs to use the central config_dir() helper.
When `gcloud projects list` times out (10s limit) for users with many
projects, the picker now includes a '⌨ Enter project ID manually'
option so they can type a known project ID instead of waiting or failing.
- Add '⌨ Enter project ID manually' item to project picker
- Handle the new item by prompting for input and calling set_gcloud_project
- Add EnterProjectId variant to SetupAction (tests)
- Add test_project_select_enter_manually unit test
Fixes#116
Co-authored-by: Claude <noreply@anthropic.com>
The reject_control_chars helper rejected bytes 0x00-0x1F but allowed
the DEL character (0x7F), which is also an ASCII control character.
This could allow malformed input from LLM agents to bypass validation.
* fix: use gcloud.cmd on Windows and show platform-correct config paths
On Windows, Google Cloud SDK installs `gcloud.cmd` (not `gcloud.exe`).
Rust's `Command::new("gcloud")` does not search PATHEXT, so all gcloud
invocations failed silently. Add `gcloud_bin()` helper that returns
`gcloud.cmd` on Windows and `gcloud` elsewhere.
Also replace hardcoded `~/.config/gws/` paths in error messages with
the actual platform-resolved path (`%APPDATA%\gws\` on Windows).
* chore: add changeset for Windows gcloud compat fix
* feat: add Linux ARM64 build targets (gnu + musl)
Add aarch64-unknown-linux-gnu and aarch64-unknown-linux-musl to
cargo-dist targets, enabling prebuilt binaries for ARM64 Linux
users via npm, the shell installer, and GitHub Releases.
* chore: trigger CLA recheck
* fix: filter alertcenter scopes from user OAuth login flow
The `apps.alerts` scope is restricted to service accounts with
domain-wide delegation and fails with `400 invalid_scope` when
used in the standard 3-legged OAuth consent flow. Filter it out
alongside the existing chat.app/chat.bot/keep exclusions.
Fixes#73
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: also filter apps.alerts in is_app_only_scope()
The scope filter exists in two locations: setup.rs (fetch_scopes_for_apis)
and auth_commands.rs (is_app_only_scope). Both need the apps.alerts
exclusion to prevent it from appearing in the interactive scope picker.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore: retrigger CLA check
* chore: retrigger CI after CLA signing
---------
Co-authored-by: Andrew Barnes <andrew.jaguars@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* fix: replace unwrap() calls with proper error handling in MCP server
Replace four serde_json::to_string().unwrap() calls in the MCP server
that could panic the process if serialization ever fails. Instead, log
the error to stderr and skip the response gracefully.
Also propagate serialization errors for params/body via the ? operator,
and log a warning when authentication silently falls back to
unauthenticated mode so users are aware of degraded state.
* fix: resolve clippy redundant_closure warnings
Replace `.map(|v| serde_json::to_string(v))` with
`.map(serde_json::to_string)` per clippy's redundant_closure lint.
* fix: harden URL and path construction across helper modules
Closes#87
- gmail/watch.rs: encode msg_id with encode_path_segment(), use
.query() for format and history params instead of format!
- modelarmor.rs: validate template with validate_resource_name() in
handle_sanitize, validate project/location/template_id in
parse_create_template_args, encode all path segments in
build_create_template_url
- discovery.rs: validate service/version with validate_api_identifier()
before use in cache filenames and discovery URLs, encode path segments
- validate.rs: add validate_api_identifier() for safe API name chars
- Add tests for all new validation and encoding paths
* refactor: pass API version as a query parameter for alternative discovery URLs.
The list_gcloud_projects() function piped stdout from `gcloud projects
list` but only read it after the child process exited. When a user has
enough GCP projects that the output exceeds the OS pipe buffer (~64KB),
gcloud blocks on write, the parent blocks waiting for exit, and neither
side makes progress — hitting the 10s timeout.
Spawn a thread to drain stdout concurrently so the pipe buffer never
fills up while the main thread polls for process completion.
Fixesgoogleworkspace/cli#96
* feat: multi-account support with --account flag, per-account credential storage
- Add --account global flag and GOOGLE_WORKSPACE_CLI_ACCOUNT env var
- Per-account encrypted credential files (credentials.<b64-email>.enc)
- Per-account token cache (token_cache.<b64-email>.json)
- accounts.json registry with default account tracking
- New auth subcommands: list, default, per-account logout
- login_hint in OAuth URL for account pre-selection
- Email validation via Google userinfo after OAuth flow
- 12 new unit tests (380 total)
BREAKING CHANGE: Existing users must run 'gws auth login' again.
Credential storage changed from single credentials.enc to per-account files.
* refactor: Improve error handling for file system operations, rename `GWS_ACCOUNT` to `GOOGLE_WORKSPACE_CLI_ACCOUNT`, and refine service account token cache path generation.
* fix: clean up per-account token caches on logout
---------
Co-authored-by: jpoehnelt-bot <jpoehnelt-bot@users.noreply.github.com>
Two bugs fixed:
1. `auth_commands.rs` — `gws auth export` masking used `s[..4]` which
panics on strings shorter than 4 characters, and `s[s.len().min(4)..]`
which evaluates to `s[4..]` on long strings — showing the entire
secret instead of masking it. Replaced with a `mask_secret()` helper
that safely shows only the first 4 and last 4 characters, or "***"
for short strings.
2. `token_storage.rs` — `save_to_disk` silently discarded the return
value of `atomic_write_async` with `let _`, causing the function to
return `Ok(())` even when the write failed. Token persistence failures
now properly propagate via `?`.
* fix: enable APIs individually and surface gcloud errors
Previously, `gws auth setup` used a single batch `gcloud services enable`
call for all 22 Workspace APIs. If any one API failed, the entire batch
was marked as failed. Additionally, stderr was piped to /dev/null, so
users never saw why APIs failed to enable.
Changes:
- Enable each API individually so one failure doesn't block the rest
- Capture stderr from gcloud and include error messages in output
- Show failure details with ⚠ warnings in the wizard status
- Include structured error objects in JSON output (apis_failed array)
Fixes#75
* address review: parallelize API enablement with tokio, remove clone
- Use tokio::process::Command + futures_util::stream::buffer_unordered(5)
for parallel, non-blocking API enablement
- Remove unnecessary failed_apis.clone() by moving into ctx.failed first
- Add changeset
* test: add coverage for enable_apis and JSON output structure
- test_enable_apis_all_already_enabled: empty input returns empty results
- test_enable_apis_with_invalid_project: verifies errors are captured (not swallowed)
- test_failed_apis_json_structure: validates {api, error} JSON shape
- test_failed_apis_json_empty: empty failures produce empty array
* Update src/setup.rs
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
---------
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* feat: add `gws version` bare subcommand
* refactor: extract help and version flag checks into dedicated functions and add test coverage guidance to AGENTS.md
---------
Co-authored-by: jpoehnelt-bot <jpoehnelt-bot@users.noreply.github.com>
* feat: smarter truncation of method/resource descriptions
- Add shared truncate_description() in src/text.rs with configurable
limits and optional markdown link stripping
- Named constants: CLI_DESCRIPTION_LIMIT (200), FRONTMATTER_DESCRIPTION_LIMIT (120),
SKILL_BODY_DESCRIPTION_LIMIT (500)
- CLI help and frontmatter strip markdown links to save space
- Skill body preserves URLs so agents can follow references
- Truncation prefers sentence boundaries, falls back to word boundaries
- Reads full descriptions from discovery doc for skill body text
Fixes#64
* fix: address PR review comments and improve coverage
- Fix sentence boundary detection at exact end of prefix (HIGH)
- Use extend() for link text emission (MEDIUM)
- Idiomatic find_char_from with position/map (MEDIUM)
- Idiomatic rfind_char_boundary with rposition (MEDIUM)
- Add 18 new tests for generate_skills.rs coverage:
truncate_desc, lookup_method_description, capitalize_first,
product_name_from_title
- Add sentence_boundary_at_exact_limit and zero_max_chars tests
---------
Co-authored-by: jpoehnelt-bot <jpoehnelt-bot@users.noreply.github.com>
* feat: Implement hourly cron and manual trigger for the generate-skills workflow to auto-sync skills via pull requests and downgrade CI drift check to a warning.
* chore: regenerate skills [skip ci]
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
clawhub CLI requires explicit `clawhub login --token` call rather
than reading the CLAWHUB_TOKEN env var directly. Split the publish
step into separate authenticate and sync steps.
* feat: add gws mcp server
Adds a new `gws mcp` subcommand that starts a Model Context Protocol
(MCP) server over stdio, exposing Google Workspace APIs as structured
tools to any MCP-compatible client.
- New `src/mcp_server.rs`: JSON-RPC stdio transport, handles
`initialize`, `tools/list`, and `tools/call`
- Tool discovery dynamically builds schemas from Google Discovery Docs
- Filtering via `-s <services>` flag (e.g. `-s drive,gmail` or `-s all`)
- `-w/--workflows` and `-e/--helpers` flags for optional extras
- stderr startup warning when no services are configured
- Refactored `executor::execute_method` to support output capture
(returns `Option<Value>` instead of printing to stdout) so the MCP
transport is not corrupted
- Updated README.md with MCP Server section and usage examples
* fix: address PR review comments
- Add stderr warning when discovery doc fails to load (mcp_server.rs)
- Remove redundant 'all' string check in service validation (mcp_server.rs)
- Validate upload path to prevent arbitrary file reads - security fix (mcp_server.rs)
- Remove redundant inner capture_output check in handle_binary_response (executor.rs)
- Add changeset for minor version bump
* fix: resolve CI lint, fmt, and test failures
- cargo fmt: format all changed files
- clippy: add #[allow(clippy::too_many_arguments)] on private handle_json_response
- clippy: collapse else { if } to else if in executor.rs
- clippy: replace svc_name.clone() with std::slice::from_ref in mcp_server.rs
- clippy: replace index-based loop with iterator in walk path resolution
- test: add ::<()> turbofish annotation to handle_error_response test calls
to fix E0282 type inference errors