From b24baeb78af6e0702644e3af60a962bcedac5170 Mon Sep 17 00:00:00 2001 From: Scott Fradkin Date: Tue, 21 Apr 2026 13:28:36 -0500 Subject: [PATCH] docs: update opencode-work shell function with credential check and session resume --- LOCAL_AWS_SETUP.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/LOCAL_AWS_SETUP.md b/LOCAL_AWS_SETUP.md index d6442b13d5f4..541edaf27fed 100644 --- a/LOCAL_AWS_SETUP.md +++ b/LOCAL_AWS_SETUP.md @@ -123,10 +123,26 @@ Add to `~/.zshrc` or `~/.bashrc`: ```bash opencode-work() { local profile="AdministratorAccess" + local opencode_args=() + + # If first arg looks like a session ID, convert it to -s + if [[ -n "$1" && "$1" != -* ]]; then + opencode_args=(-s "$1") + shift + fi + opencode_args+=("$@") + + # Check if existing env credentials are still valid + if [[ -n "$AWS_ACCESS_KEY_ID" ]] && aws sts get-caller-identity &>/dev/null; then + echo "Using existing AWS credentials" + /path/to/opencode/packages/opencode/dist/opencode-darwin-arm64/bin/opencode "${opencode_args[@]}" + return + fi + echo "Logging in to AWS SSO ($profile)..." aws sso login --profile "$profile" || return 1 eval "$(aws configure export-credentials --profile "$profile" --format env)" - /path/to/opencode/packages/opencode/dist/opencode-darwin-arm64/bin/opencode "$@" + /path/to/opencode/packages/opencode/dist/opencode-darwin-arm64/bin/opencode "${opencode_args[@]}" } ``` @@ -138,6 +154,9 @@ Replace `/path/to/opencode` with where you cloned the repo (e.g. `~/Code/persona # Login and launch opencode-work +# Resume a previous session +opencode-work ses_2541da06dffeSyfI3ed4qvC7Tv + # Re-running after SSO session expires — just run again, it will re-authenticate opencode-work ```