@doist/twist-cli 2.39.0 → 2.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/commands/account/current.d.ts +4 -0
  3. package/dist/commands/account/current.d.ts.map +1 -0
  4. package/dist/commands/account/current.js +46 -0
  5. package/dist/commands/account/current.js.map +1 -0
  6. package/dist/commands/account/helpers.d.ts +8 -0
  7. package/dist/commands/account/helpers.d.ts.map +1 -0
  8. package/dist/commands/account/helpers.js +18 -0
  9. package/dist/commands/account/helpers.js.map +1 -0
  10. package/dist/commands/account/index.d.ts +3 -0
  11. package/dist/commands/account/index.d.ts.map +1 -0
  12. package/dist/commands/account/index.js +30 -0
  13. package/dist/commands/account/index.js.map +1 -0
  14. package/dist/commands/account/list.d.ts +4 -0
  15. package/dist/commands/account/list.d.ts.map +1 -0
  16. package/dist/commands/account/list.js +30 -0
  17. package/dist/commands/account/list.js.map +1 -0
  18. package/dist/commands/account/remove.d.ts +4 -0
  19. package/dist/commands/account/remove.d.ts.map +1 -0
  20. package/dist/commands/account/remove.js +18 -0
  21. package/dist/commands/account/remove.js.map +1 -0
  22. package/dist/commands/account/use.d.ts +4 -0
  23. package/dist/commands/account/use.d.ts.map +1 -0
  24. package/dist/commands/account/use.js +13 -0
  25. package/dist/commands/account/use.js.map +1 -0
  26. package/dist/commands/auth/helpers.d.ts +1 -1
  27. package/dist/commands/auth/helpers.d.ts.map +1 -1
  28. package/dist/commands/auth/helpers.js.map +1 -1
  29. package/dist/commands/auth/store-wrap.d.ts +1 -1
  30. package/dist/commands/auth/store-wrap.d.ts.map +1 -1
  31. package/dist/commands/auth/store-wrap.js +16 -1
  32. package/dist/commands/auth/store-wrap.js.map +1 -1
  33. package/dist/commands/auth/token.d.ts.map +1 -1
  34. package/dist/commands/auth/token.js +19 -10
  35. package/dist/commands/auth/token.js.map +1 -1
  36. package/dist/commands/config/view.d.ts.map +1 -1
  37. package/dist/commands/config/view.js +17 -1
  38. package/dist/commands/config/view.js.map +1 -1
  39. package/dist/index.js +3 -0
  40. package/dist/index.js.map +1 -1
  41. package/dist/lib/auth-constants.d.ts +9 -0
  42. package/dist/lib/auth-constants.d.ts.map +1 -0
  43. package/dist/lib/auth-constants.js +9 -0
  44. package/dist/lib/auth-constants.js.map +1 -0
  45. package/dist/lib/auth-provider.d.ts +41 -7
  46. package/dist/lib/auth-provider.d.ts.map +1 -1
  47. package/dist/lib/auth-provider.js +179 -106
  48. package/dist/lib/auth-provider.js.map +1 -1
  49. package/dist/lib/auth.d.ts +13 -12
  50. package/dist/lib/auth.d.ts.map +1 -1
  51. package/dist/lib/auth.js +46 -238
  52. package/dist/lib/auth.js.map +1 -1
  53. package/dist/lib/config.d.ts +21 -1
  54. package/dist/lib/config.d.ts.map +1 -1
  55. package/dist/lib/config.js +62 -3
  56. package/dist/lib/config.js.map +1 -1
  57. package/dist/lib/errors.d.ts +1 -1
  58. package/dist/lib/errors.d.ts.map +1 -1
  59. package/dist/lib/errors.js.map +1 -1
  60. package/dist/lib/migrate-auth.d.ts +14 -0
  61. package/dist/lib/migrate-auth.d.ts.map +1 -0
  62. package/dist/lib/migrate-auth.js +61 -0
  63. package/dist/lib/migrate-auth.js.map +1 -0
  64. package/dist/lib/skills/content.d.ts +1 -1
  65. package/dist/lib/skills/content.d.ts.map +1 -1
  66. package/dist/lib/skills/content.js +3 -0
  67. package/dist/lib/skills/content.js.map +1 -1
  68. package/dist/lib/twist-account.d.ts +22 -0
  69. package/dist/lib/twist-account.d.ts.map +1 -0
  70. package/dist/lib/twist-account.js +23 -0
  71. package/dist/lib/twist-account.js.map +1 -0
  72. package/dist/lib/user-records.d.ts +15 -0
  73. package/dist/lib/user-records.d.ts.map +1 -0
  74. package/dist/lib/user-records.js +84 -0
  75. package/dist/lib/user-records.js.map +1 -0
  76. package/dist/postinstall.js +4 -0
  77. package/dist/postinstall.js.map +1 -1
  78. package/package.json +1 -1
@@ -3,6 +3,6 @@ export declare const SKILL_DESCRIPTION = "Twist messaging CLI. View and respond
3
3
  export declare const SKILL_AUTHOR = "Doist";
4
4
  export declare const SKILL_LICENSE = "MIT";
5
5
  export declare const SKILL_VERSION: string;
6
- export declare const SKILL_CONTENT = "# Twist CLI (tw)\n\nAccess Twist messaging via the `tw` CLI. Use when the user asks about their Twist workspaces, threads, messages, or wants to interact with Twist in any way.\n\n## Setup\n\n```bash\ntw auth login # OAuth login (opens browser, read-write)\ntw auth login --read-only # OAuth login with read-only scope\ntw auth login --callback-port <n># Override the local OAuth callback port (default 8766)\ntw auth login --json # Emit a JSON envelope for scripted / agent use\ntw auth login --ndjson # Emit an NDJSON envelope for scripted / agent use\ntw auth token # Save API token manually (prompts securely; scope unknown, assumed write-capable)\ntw auth status # Verify authentication + show mode\ntw auth status --json # Full status payload as JSON (--ndjson also supported)\ntw auth status --user <ref> # Target a specific stored account (id, id:<n>, or display name)\ntw --user <ref> auth <status|logout|token view> # Equivalent to passing --user after the subcommand; other commands accept the flag but ignore it\ntw auth logout # Remove saved token and auth metadata\ntw auth logout --json # Emits `{\"ok\": true}` (--ndjson is silent)\ntw auth logout --user <ref> # Target a specific stored account; mismatched ref errors with ACCOUNT_NOT_FOUND\ntw auth token view # Print the saved token to stdout (pipe-safe; refuses if TWIST_API_TOKEN is set)\ntw auth token view --user <ref> # Print the saved token for a specific stored account\ntw workspaces # List available workspaces\ntw workspace use <ref> # Set current workspace\ntw completion install # Install shell completions\ntw config view # Show the current CLI configuration file (token masked)\ntw config set <key> <value> # Set a user preference (e.g. unarchive-new-threads true)\ntw doctor # Diagnose CLI setup and environment issues\ntw update # Update CLI to latest version\ntw changelog # Show recent changelog entries\n```\n\nStored auth uses the system credential manager when available. If secure storage is unavailable, `tw` warns and falls back to `~/.config/twist-cli/config.json`. `TWIST_API_TOKEN` always takes priority over the stored token, and legacy plaintext config tokens are migrated automatically when secure storage is available.\n\nIn read-only mode (`tw auth login --read-only`), commands that modify Twist data (reply, archive, react, delete, etc.) are blocked by the CLI. Externally provided tokens (`TWIST_API_TOKEN` or `tw auth token`) are treated as unknown scope and assumed write-capable.\n\n## View by URL\n\n```bash\ntw view <url> # View any Twist entity by URL\n```\n\nRoutes automatically based on URL structure:\n- Message URL \u2192 `tw msg view`\n- Conversation URL \u2192 `tw conversation view`\n- Thread+comment URL \u2192 `tw thread view` (comment ID extracted from URL)\n- Thread URL \u2192 `tw thread view`\n\nAll target command flags pass through (e.g. `--json`, `--raw`, `--full`).\n\n## Inbox\n\n```bash\ntw inbox # Show inbox threads\ntw inbox --unread # Only unread threads\ntw inbox --archive-filter all # Show active + done threads\ntw inbox --archive-filter archived # Show only done threads\ntw inbox --channel <filter> # Filter by channel name (fuzzy)\ntw inbox --since <date> # Filter by date (ISO format)\ntw inbox --limit <n> # Max items (default: 50)\n```\n\n## Threads\n\n```bash\ntw thread <thread-ref> # View thread (shorthand for view)\ntw thread view <thread-ref> # View thread with comments\ntw thread view <ref> --comment <id> # View a specific comment\ntw thread view <url-with-/c/id> # Comment ID extracted from URL\ntw thread view <ref> --unread # Show only unread comments\ntw thread view <ref> --context 3 # Include 3 read comments before unread\ntw thread view <ref> --limit 20 # Limit number of comments\ntw thread view <ref> --since <date> # Comments newer than date\ntw thread view <ref> --raw # Show raw markdown\ntw thread create <channel-ref> \"Title\" \"content\" # Create a new thread\ntw thread create <channel-ref> \"Title\" \"content\" --json # Create and return as JSON\ntw thread create <channel-ref> \"Title\" \"content\" --json --full # Include all thread fields\ntw thread create <channel-ref> \"Title\" \"content\" --notify 123,456 # Notify specific users\ntw thread create <channel-ref> \"Title\" \"content\" --unarchive # Land thread in author's Inbox (overrides default Twist auto-archive)\ntw thread create <channel-ref> \"Title\" \"content\" --no-unarchive # Force archive even when userSettings.unarchiveNewThreads=true\ntw thread create <channel-ref> \"Title\" \"content\" --dry-run # Preview without posting\ntw thread reply <ref> \"content\" # Post a comment (notifies EVERYONE_IN_THREAD by default)\ntw thread reply <ref> \"content\" --notify EVERYONE # Notify all workspace members\ntw thread reply <ref> \"content\" --notify 123,id:456 # Notify specific user IDs\ntw thread reply <ref> \"content\" --json # Post and return comment as JSON\ntw thread reply <ref> \"content\" --json --full # Include all comment fields\ntw thread reply <ref> \"content\" --close # Reply and close the thread\ntw thread reply <ref> \"content\" --reopen # Reply and reopen a closed thread\ntw thread done <ref> # Archive thread (mark done)\ntw thread done <ref> --json # Archive and return status as JSON\ntw thread mute <ref> # Mute thread for 60 minutes (default)\ntw thread mute <ref> --minutes 480 # Mute for custom duration\ntw thread mute <ref> --json # Mute and return { id, mutedUntil } as JSON\ntw thread mute <ref> --json --full # Mute and return full thread as JSON\ntw thread unmute <ref> # Unmute a muted thread\ntw thread unmute <ref> --json # Unmute and return { id, mutedUntil } as JSON\ntw thread delete <ref> # Preview thread deletion (requires --yes to execute)\ntw thread delete <ref> --yes # Permanently delete a thread\ntw thread delete <ref> --yes --json # Delete and return status as JSON\ntw thread rename <ref> \"New title\" # Rename a thread (change its title)\ntw thread rename <ref> \"New title\" --json # Rename and return { id, title } as JSON\ntw thread rename <ref> \"New title\" --json --full # Rename and return full thread as JSON\ntw thread update <ref> \"New body\" # Update a thread's body (the first post)\necho \"New body\" | tw thread update <ref> # Update body from stdin\ntw thread update <ref> \"New body\" --dry-run # Preview without updating\ntw thread update <ref> \"New body\" --json # Update and return { id, content } as JSON\ntw thread update <ref> \"New body\" --json --full # Update and return full thread as JSON\n```\n\nDefault `--notify` for reply is EVERYONE_IN_THREAD, which may notify more people than intended. Before posting, confirm with the user whether specific people should be notified instead (via `--notify <user-ids>`). Options: EVERYONE, EVERYONE_IN_THREAD, or comma-separated ID refs.\n\n`--notify` automatically resolves IDs: group IDs are routed to the `groups` API field, user IDs to `recipients`. No special syntax needed.\n\n## Thread Comments\n\n```bash\ntw comment <comment-ref> # View a comment (shorthand for view)\ntw comment view <comment-ref> # View a single thread comment\ntw comment view <comment-ref> --raw # Show raw markdown\ntw comment view <comment-ref> --json # Output as JSON\ntw comment view <comment-ref> --ndjson # Output as newline-delimited JSON\ntw comment view <comment-ref> --json --full # Include all fields in JSON output\ntw comment update <comment-ref> \"new content\" # Update a thread comment\ntw comment update <comment-ref> \"content\" --json # Update and return updated comment as JSON\ntw comment update <comment-ref> \"content\" --json --full # Include all comment fields\ntw comment delete <comment-ref> # Delete a thread comment\ntw comment delete <comment-ref> --json # Delete and return status as JSON\n```\n\n## Conversations (DMs/Groups)\n\n```bash\ntw conversation unread # List unread conversations\ntw conversation <conversation-ref> # View conversation (shorthand for view)\ntw conversation view <conversation-ref> # View conversation messages\ntw conversation with <user-ref> # Find your 1:1 DM with a user\ntw conversation with <user-ref> --snippet # Include the latest message preview\ntw conversation with <user-ref> --include-groups # List any conversations with that user\ntw conversation reply <ref> \"content\" # Send a message\ntw conversation reply <ref> \"content\" --json # Send and return message as JSON\ntw conversation reply <ref> \"content\" --json --full # Include all message fields\ntw conversation done <ref> # Archive conversation\ntw conversation done <ref> --json # Archive and return status as JSON\ntw conversation mute <ref> # Mute conversation for 60 minutes (default)\ntw conversation mute <ref> --minutes 480 # Mute for custom duration\ntw conversation mute <ref> --json # Mute and return { id, mutedUntil } as JSON\ntw conversation mute <ref> --json --full # Mute and return full conversation as JSON\ntw conversation unmute <ref> # Unmute a muted conversation\ntw conversation unmute <ref> --json # Unmute and return { id, mutedUntil } as JSON\n```\n\nAlias: `tw convo` works the same as `tw conversation`.\n\n## Conversation Messages\n\n```bash\ntw msg <message-ref> # View a message (shorthand for view)\ntw msg view <message-ref> # View a single conversation message\ntw msg update <ref> \"content\" # Edit a conversation message\ntw msg update <ref> \"content\" --json # Edit and return updated message as JSON\ntw msg update <ref> \"content\" --json --full # Include all message fields\ntw msg delete <ref> # Delete a conversation message\ntw msg delete <ref> --json # Delete and return status as JSON\n```\n\nAlias: `tw message` works the same as `tw msg`.\n\n## Search\n\n```bash\ntw mentions # Show content mentioning current user\ntw mentions --since 2026-04-01 --all # Fetch every mention since a date\ntw mentions --type threads --json # Limit mentions to threads\ntw search \"query\" # Search content\ntw search \"query\" --type threads # Filter: threads, messages, or all\ntw search \"query\" --author <ref> # Filter by author\ntw search \"query\" --to <ref> # Messages sent to user\ntw search \"query\" --title-only # Search thread titles only\ntw search \"query\" --mention-me # Results mentioning current user\ntw search \"query\" --conversation <refs> # Limit to conversations (comma-separated refs)\ntw search \"query\" --since <date> # Content from date\ntw search \"query\" --until <date> # Content until date\ntw search \"query\" --channel <refs> # Filter by channel refs (comma-separated)\ntw search \"query\" --limit <n> # Max results (default: 50)\ntw search \"query\" --cursor <cur> # Pagination cursor\ntw search \"query\" --all # Fetch all result pages\n```\n\n## Users, Channels & Groups\n\n```bash\ntw user # Show current user info\ntw user --json # JSON output\ntw user --json --full # Include all fields in JSON output\ntw users # List workspace users\ntw users --search <text> # Filter by name/email\ntw channels # List active joined workspace channels (alias of: tw channel list)\ntw channels --state all # Include archived joined channels too\ntw channels --scope discoverable # Active public channels you can see but have not joined\ntw channels --scope public --state all --json # All visible public channels, with joined status\ntw channel threads <channel-ref> # List threads in a channel (fuzzy name, id:, numeric ID, or URL)\ntw channel threads \"general\" --unread # Only unread threads\ntw channel threads <ref> --archive-filter all # Include archived threads (active|archived|all)\ntw channel threads <ref> --since 2026-01-01 # Filter by last-updated date (ISO)\ntw channel threads <ref> --limit 20 # Max threads per page (default: 50)\ntw channel threads <ref> --limit 20 --cursor <cursor-from-prev> # Paginate\ntw channel threads <ref> --json # { results, nextCursor } with isUnread + url\ntw groups # List workspace groups\ntw groups --search \"frontend\" # Filter groups by name (case-insensitive)\ntw groups --json # JSON output\ntw groups --json --full # Include all fields in JSON output\ntw groups view <group-ref> # Show group with member details\ntw groups view <ref> --json # JSON output with id, name, workspaceId, members\ntw groups view <ref> --json --full # Include all fields in JSON output\ntw groups create \"Name\" # Create a new group\ntw groups create \"Name\" --users alice@doist.com,bob@doist.com # Create with members\ntw groups create \"Name\" --json # Output created group as JSON\ntw groups rename <group-ref> \"New name\" # Rename a group\ntw groups rename <ref> \"Name\" --json # Output renamed group as JSON\ntw groups delete <group-ref> --yes # Delete a group (requires --yes)\ntw groups delete <ref> --dry-run # Preview deletion\ntw groups add-user <group-ref> user1 user2 # Add users to a group\ntw groups add-user <ref> a@d.com,b@d.com # Comma-separated refs\ntw groups add-user <ref> id:123 --json # Output result as JSON\ntw groups remove-user <group-ref> user1 user2 # Remove users from a group\ntw groups remove-user <ref> id:123,id:456 # Comma-separated ID refs\n```\n\nIf a channel is not found in `tw channels`, widen with broader listings such as `tw channels --scope public`, then `tw channels --scope public --state all`. Check `tw channels --help` for other available filters.\n\n`tw channel threads` returns every thread in the channel; pagination filters (`--limit`, `--cursor`, `--since`, `--until`, `--unread`) are applied client-side after fetch. `--archive-filter` is applied server-side. Results are sorted newest-first by last activity. In `--json` / `--ndjson`, the response includes a `nextCursor` string (opaque) you can pass via `--cursor` to fetch the next page; NDJSON emits the cursor as a final `{ \"_meta\": true, \"nextCursor\": \"...\" }` line.\n\n## Away Status\n\n```bash\ntw away # Show current away status\ntw away set <type> [until] # Set away (type: vacation, parental, sickleave, other)\ntw away set vacation 2026-03-20 # Away until March 20\ntw away set vacation 2026-03-20 --from 2026-03-15 # Custom start date\ntw away clear # Clear away status\n```\n\n## Reactions\n\n```bash\ntw react thread <ref> \uD83D\uDC4D # Add reaction to thread\ntw react comment <ref> +1 # Add reaction (shortcode)\ntw react message <ref> heart # Add reaction to DM message\ntw react thread <ref> \uD83D\uDC4D --json # Output result as JSON\ntw unreact thread <ref> \uD83D\uDC4D # Remove reaction\ntw unreact thread <ref> \uD83D\uDC4D --json # Output result as JSON\n```\n\nSupported shortcodes: +1, -1, heart, tada, smile, laughing, thinking, fire, check, x, eyes, pray, clap, rocket, wave\n\n## Shell Completions\n\n```bash\ntw completion install # Install tab completions (prompts for shell)\ntw completion install bash # Install for specific shell\ntw completion install zsh\ntw completion install fish\ntw completion uninstall # Remove completions\n```\n\n### Diagnostics\n\n```bash\ntw doctor # Run local + network diagnostics\ntw doctor --offline # Skip Twist and npm network checks\ntw doctor --json # JSON output with per-check results\n```\n\n### Configuration\n\n```bash\ntw config view # Pretty-printed config, token masked, labels actual token source\ntw config view --json # Raw JSON, token masked\ntw config view --show-token # Include the full token\ntw config set unarchive-new-threads true # Persist: always unarchive new threads so they land in your Inbox\ntw config set unarchive-new-threads false # Persist: keep Twist's default (thread auto-archived for author)\n```\n\nUser preferences are stored under `userSettings` in the config file. Currently supported keys: `unarchive-new-threads`. The flag on `tw thread create` (`--unarchive` / `--no-unarchive`) overrides this default per-invocation.\n\n### Update\n\n```bash\ntw update # Update CLI to latest version\ntw update --check # Check for updates without installing, show channel\ntw update --check --json # Same, JSON envelope\ntw update --check --ndjson # Same, newline-delimited JSON envelope\ntw update --channel # Show current update channel\ntw update switch --stable # Switch to stable release channel\ntw update switch --pre-release # Switch to pre-release (next) channel\ntw update switch --pre-release --json # Same, JSON envelope\ntw update switch --pre-release --ndjson # Same, newline-delimited JSON envelope\n```\n\n### Changelog\n```bash\ntw changelog # Show last 5 versions\ntw changelog -n 3 # Show last 3 versions\ntw changelog --count 10 # Show last 10 versions\n```\n\n## Global Options\n\n```bash\n--no-spinner # Disable loading animations\n--progress-jsonl # Machine-readable progress events (JSONL to stderr)\n--progress-jsonl=<path> # Same, but write events to <path> instead of stderr\n--progress-jsonl <path> # Same as above (space-separated form also accepted)\n--accessible # Add text labels to color-coded output (also: TW_ACCESSIBLE=1)\n--non-interactive # Disable interactive prompts (auto-detected when stdin is not a TTY)\n--interactive # Force interactive mode even when stdin is not a TTY\n```\n\n## Output Formats\n\nAll list/view commands support:\n\n```bash\n--json # Output as JSON\n--ndjson # Output as newline-delimited JSON (for streaming)\n--full # Include all fields (default shows essential fields only)\n```\n\n## Dry Run\n\nMutating commands accept `--dry-run` to preview the operation without making the change. Where a command performs pre-flight validation (e.g. fetching the target thread to check channel access or ownership), those checks still run in dry-run \u2014 only the mutating write is skipped. Commands that have no pre-flight validation parse the reference and print the preview without hitting the API. The preview is structured:\n\n```\n[dry-run] Would <action>:\n <Key>: <resolved value>\n ...\nRun without --dry-run to execute.\n```\n\n## Reference System\n\nCommands accept flexible references:\n- **Numeric IDs**: `123` or `id:123`\n- **Twist URLs**: Full `https://twist.com/...` URLs (parsed automatically)\n- **Fuzzy names**: For workspaces/users - `\"My Workspace\"` or partial matches\n\n## Piping Content\n\nCommands that accept content (`thread create`, `thread reply`, `comment update`, `conversation reply`, `msg update`) auto-detect piped stdin:\n\n```bash\ncat notes.md | tw thread reply <ref>\ntw thread create <channel-ref> \"Title\" < body.md\necho \"Quick reply\" | tw conversation reply <ref>\n```\n\nIf no content argument is provided and no stdin is piped, the CLI opens `$EDITOR` for interactive input. In non-TTY environments (e.g. when called by an agent or in a pipeline), the editor is automatically skipped and the command fails fast with an actionable error message. Use `--non-interactive` to force this behavior even in a TTY, or `--interactive` to override auto-detection.\n\n## Common Workflows\n\n**View by URL (auto-routes to the right command):**\n```bash\ntw view https://twist.com/a/1585/ch/100/t/200 # View thread\ntw view https://twist.com/a/1585/ch/100/t/200/c/300 # View comment\ntw view https://twist.com/a/1585/msg/400 # View conversation\ntw view https://twist.com/a/1585/msg/400/m/500 --json # View message as JSON\n```\n\n**Check inbox and respond:**\n```bash\ntw inbox --unread --json\ntw thread view <id> --unread\ntw thread reply <id> \"Thanks, I'll look into this.\"\ntw thread done <id>\n```\n\n**Search and review:**\n```bash\ntw mentions --since 2026-04-01 --all --json\ntw search \"deployment\" --type threads --json\ntw thread view <thread-id>\n```\n\n**Check DMs:**\n```bash\ntw conversation unread --json\ntw conversation view <conversation-id>\ntw conversation with \"Alice Example\"\ntw conversation reply <id> \"Got it, thanks!\"\n```\n";
6
+ export declare const SKILL_CONTENT = "# Twist CLI (tw)\n\nAccess Twist messaging via the `tw` CLI. Use when the user asks about their Twist workspaces, threads, messages, or wants to interact with Twist in any way.\n\n## Setup\n\n```bash\ntw auth login # OAuth login (opens browser, read-write)\ntw auth login --read-only # OAuth login with read-only scope\ntw auth login --callback-port <n># Override the local OAuth callback port (default 8766)\ntw auth login --json # Emit a JSON envelope for scripted / agent use\ntw auth login --ndjson # Emit an NDJSON envelope for scripted / agent use\ntw auth token # Save API token manually (prompts securely; scope unknown, assumed write-capable)\ntw auth status # Verify authentication + show mode\ntw auth status --json # Full status payload as JSON (--ndjson also supported)\ntw auth status --user <ref> # Target a specific stored account (id, id:<n>, or display name)\ntw --user <ref> auth <status|logout|token view> # Equivalent to passing --user after the subcommand; other commands accept the flag but ignore it\ntw auth logout # Remove saved token and auth metadata\ntw auth logout --json # Emits `{\"ok\": true}` (--ndjson is silent)\ntw auth logout --user <ref> # Target a specific stored account; mismatched ref errors with ACCOUNT_NOT_FOUND\ntw auth token view # Print the saved token to stdout (pipe-safe; refuses if TWIST_API_TOKEN is set)\ntw auth token view --user <ref> # Print the saved token for a specific stored account\ntw account [list|current|use <ref>|remove <ref>] # Manage stored accounts; all support --json/--ndjson\n # current's payload is {id, label, authMode, authScope, source:\"config\"} | {source:\"env\"} | {source:\"legacy\"}\ntw auth login # Re-running auth login with a different OAuth grant adds a NEW account; default stays pinned unless none was set\ntw workspaces # List available workspaces\ntw workspace use <ref> # Set current workspace\ntw completion install # Install shell completions\ntw config view # Show the current CLI configuration file (token masked)\ntw config set <key> <value> # Set a user preference (e.g. unarchive-new-threads true)\ntw doctor # Diagnose CLI setup and environment issues\ntw update # Update CLI to latest version\ntw changelog # Show recent changelog entries\n```\n\nStored auth uses the system credential manager when available. If secure storage is unavailable, `tw` warns and falls back to `~/.config/twist-cli/config.json`. `TWIST_API_TOKEN` always takes priority over the stored token, and legacy plaintext config tokens are migrated automatically when secure storage is available.\n\nIn read-only mode (`tw auth login --read-only`), commands that modify Twist data (reply, archive, react, delete, etc.) are blocked by the CLI. Externally provided tokens (`TWIST_API_TOKEN` or `tw auth token`) are treated as unknown scope and assumed write-capable.\n\n## View by URL\n\n```bash\ntw view <url> # View any Twist entity by URL\n```\n\nRoutes automatically based on URL structure:\n- Message URL \u2192 `tw msg view`\n- Conversation URL \u2192 `tw conversation view`\n- Thread+comment URL \u2192 `tw thread view` (comment ID extracted from URL)\n- Thread URL \u2192 `tw thread view`\n\nAll target command flags pass through (e.g. `--json`, `--raw`, `--full`).\n\n## Inbox\n\n```bash\ntw inbox # Show inbox threads\ntw inbox --unread # Only unread threads\ntw inbox --archive-filter all # Show active + done threads\ntw inbox --archive-filter archived # Show only done threads\ntw inbox --channel <filter> # Filter by channel name (fuzzy)\ntw inbox --since <date> # Filter by date (ISO format)\ntw inbox --limit <n> # Max items (default: 50)\n```\n\n## Threads\n\n```bash\ntw thread <thread-ref> # View thread (shorthand for view)\ntw thread view <thread-ref> # View thread with comments\ntw thread view <ref> --comment <id> # View a specific comment\ntw thread view <url-with-/c/id> # Comment ID extracted from URL\ntw thread view <ref> --unread # Show only unread comments\ntw thread view <ref> --context 3 # Include 3 read comments before unread\ntw thread view <ref> --limit 20 # Limit number of comments\ntw thread view <ref> --since <date> # Comments newer than date\ntw thread view <ref> --raw # Show raw markdown\ntw thread create <channel-ref> \"Title\" \"content\" # Create a new thread\ntw thread create <channel-ref> \"Title\" \"content\" --json # Create and return as JSON\ntw thread create <channel-ref> \"Title\" \"content\" --json --full # Include all thread fields\ntw thread create <channel-ref> \"Title\" \"content\" --notify 123,456 # Notify specific users\ntw thread create <channel-ref> \"Title\" \"content\" --unarchive # Land thread in author's Inbox (overrides default Twist auto-archive)\ntw thread create <channel-ref> \"Title\" \"content\" --no-unarchive # Force archive even when userSettings.unarchiveNewThreads=true\ntw thread create <channel-ref> \"Title\" \"content\" --dry-run # Preview without posting\ntw thread reply <ref> \"content\" # Post a comment (notifies EVERYONE_IN_THREAD by default)\ntw thread reply <ref> \"content\" --notify EVERYONE # Notify all workspace members\ntw thread reply <ref> \"content\" --notify 123,id:456 # Notify specific user IDs\ntw thread reply <ref> \"content\" --json # Post and return comment as JSON\ntw thread reply <ref> \"content\" --json --full # Include all comment fields\ntw thread reply <ref> \"content\" --close # Reply and close the thread\ntw thread reply <ref> \"content\" --reopen # Reply and reopen a closed thread\ntw thread done <ref> # Archive thread (mark done)\ntw thread done <ref> --json # Archive and return status as JSON\ntw thread mute <ref> # Mute thread for 60 minutes (default)\ntw thread mute <ref> --minutes 480 # Mute for custom duration\ntw thread mute <ref> --json # Mute and return { id, mutedUntil } as JSON\ntw thread mute <ref> --json --full # Mute and return full thread as JSON\ntw thread unmute <ref> # Unmute a muted thread\ntw thread unmute <ref> --json # Unmute and return { id, mutedUntil } as JSON\ntw thread delete <ref> # Preview thread deletion (requires --yes to execute)\ntw thread delete <ref> --yes # Permanently delete a thread\ntw thread delete <ref> --yes --json # Delete and return status as JSON\ntw thread rename <ref> \"New title\" # Rename a thread (change its title)\ntw thread rename <ref> \"New title\" --json # Rename and return { id, title } as JSON\ntw thread rename <ref> \"New title\" --json --full # Rename and return full thread as JSON\ntw thread update <ref> \"New body\" # Update a thread's body (the first post)\necho \"New body\" | tw thread update <ref> # Update body from stdin\ntw thread update <ref> \"New body\" --dry-run # Preview without updating\ntw thread update <ref> \"New body\" --json # Update and return { id, content } as JSON\ntw thread update <ref> \"New body\" --json --full # Update and return full thread as JSON\n```\n\nDefault `--notify` for reply is EVERYONE_IN_THREAD, which may notify more people than intended. Before posting, confirm with the user whether specific people should be notified instead (via `--notify <user-ids>`). Options: EVERYONE, EVERYONE_IN_THREAD, or comma-separated ID refs.\n\n`--notify` automatically resolves IDs: group IDs are routed to the `groups` API field, user IDs to `recipients`. No special syntax needed.\n\n## Thread Comments\n\n```bash\ntw comment <comment-ref> # View a comment (shorthand for view)\ntw comment view <comment-ref> # View a single thread comment\ntw comment view <comment-ref> --raw # Show raw markdown\ntw comment view <comment-ref> --json # Output as JSON\ntw comment view <comment-ref> --ndjson # Output as newline-delimited JSON\ntw comment view <comment-ref> --json --full # Include all fields in JSON output\ntw comment update <comment-ref> \"new content\" # Update a thread comment\ntw comment update <comment-ref> \"content\" --json # Update and return updated comment as JSON\ntw comment update <comment-ref> \"content\" --json --full # Include all comment fields\ntw comment delete <comment-ref> # Delete a thread comment\ntw comment delete <comment-ref> --json # Delete and return status as JSON\n```\n\n## Conversations (DMs/Groups)\n\n```bash\ntw conversation unread # List unread conversations\ntw conversation <conversation-ref> # View conversation (shorthand for view)\ntw conversation view <conversation-ref> # View conversation messages\ntw conversation with <user-ref> # Find your 1:1 DM with a user\ntw conversation with <user-ref> --snippet # Include the latest message preview\ntw conversation with <user-ref> --include-groups # List any conversations with that user\ntw conversation reply <ref> \"content\" # Send a message\ntw conversation reply <ref> \"content\" --json # Send and return message as JSON\ntw conversation reply <ref> \"content\" --json --full # Include all message fields\ntw conversation done <ref> # Archive conversation\ntw conversation done <ref> --json # Archive and return status as JSON\ntw conversation mute <ref> # Mute conversation for 60 minutes (default)\ntw conversation mute <ref> --minutes 480 # Mute for custom duration\ntw conversation mute <ref> --json # Mute and return { id, mutedUntil } as JSON\ntw conversation mute <ref> --json --full # Mute and return full conversation as JSON\ntw conversation unmute <ref> # Unmute a muted conversation\ntw conversation unmute <ref> --json # Unmute and return { id, mutedUntil } as JSON\n```\n\nAlias: `tw convo` works the same as `tw conversation`.\n\n## Conversation Messages\n\n```bash\ntw msg <message-ref> # View a message (shorthand for view)\ntw msg view <message-ref> # View a single conversation message\ntw msg update <ref> \"content\" # Edit a conversation message\ntw msg update <ref> \"content\" --json # Edit and return updated message as JSON\ntw msg update <ref> \"content\" --json --full # Include all message fields\ntw msg delete <ref> # Delete a conversation message\ntw msg delete <ref> --json # Delete and return status as JSON\n```\n\nAlias: `tw message` works the same as `tw msg`.\n\n## Search\n\n```bash\ntw mentions # Show content mentioning current user\ntw mentions --since 2026-04-01 --all # Fetch every mention since a date\ntw mentions --type threads --json # Limit mentions to threads\ntw search \"query\" # Search content\ntw search \"query\" --type threads # Filter: threads, messages, or all\ntw search \"query\" --author <ref> # Filter by author\ntw search \"query\" --to <ref> # Messages sent to user\ntw search \"query\" --title-only # Search thread titles only\ntw search \"query\" --mention-me # Results mentioning current user\ntw search \"query\" --conversation <refs> # Limit to conversations (comma-separated refs)\ntw search \"query\" --since <date> # Content from date\ntw search \"query\" --until <date> # Content until date\ntw search \"query\" --channel <refs> # Filter by channel refs (comma-separated)\ntw search \"query\" --limit <n> # Max results (default: 50)\ntw search \"query\" --cursor <cur> # Pagination cursor\ntw search \"query\" --all # Fetch all result pages\n```\n\n## Users, Channels & Groups\n\n```bash\ntw user # Show current user info\ntw user --json # JSON output\ntw user --json --full # Include all fields in JSON output\ntw users # List workspace users\ntw users --search <text> # Filter by name/email\ntw channels # List active joined workspace channels (alias of: tw channel list)\ntw channels --state all # Include archived joined channels too\ntw channels --scope discoverable # Active public channels you can see but have not joined\ntw channels --scope public --state all --json # All visible public channels, with joined status\ntw channel threads <channel-ref> # List threads in a channel (fuzzy name, id:, numeric ID, or URL)\ntw channel threads \"general\" --unread # Only unread threads\ntw channel threads <ref> --archive-filter all # Include archived threads (active|archived|all)\ntw channel threads <ref> --since 2026-01-01 # Filter by last-updated date (ISO)\ntw channel threads <ref> --limit 20 # Max threads per page (default: 50)\ntw channel threads <ref> --limit 20 --cursor <cursor-from-prev> # Paginate\ntw channel threads <ref> --json # { results, nextCursor } with isUnread + url\ntw groups # List workspace groups\ntw groups --search \"frontend\" # Filter groups by name (case-insensitive)\ntw groups --json # JSON output\ntw groups --json --full # Include all fields in JSON output\ntw groups view <group-ref> # Show group with member details\ntw groups view <ref> --json # JSON output with id, name, workspaceId, members\ntw groups view <ref> --json --full # Include all fields in JSON output\ntw groups create \"Name\" # Create a new group\ntw groups create \"Name\" --users alice@doist.com,bob@doist.com # Create with members\ntw groups create \"Name\" --json # Output created group as JSON\ntw groups rename <group-ref> \"New name\" # Rename a group\ntw groups rename <ref> \"Name\" --json # Output renamed group as JSON\ntw groups delete <group-ref> --yes # Delete a group (requires --yes)\ntw groups delete <ref> --dry-run # Preview deletion\ntw groups add-user <group-ref> user1 user2 # Add users to a group\ntw groups add-user <ref> a@d.com,b@d.com # Comma-separated refs\ntw groups add-user <ref> id:123 --json # Output result as JSON\ntw groups remove-user <group-ref> user1 user2 # Remove users from a group\ntw groups remove-user <ref> id:123,id:456 # Comma-separated ID refs\n```\n\nIf a channel is not found in `tw channels`, widen with broader listings such as `tw channels --scope public`, then `tw channels --scope public --state all`. Check `tw channels --help` for other available filters.\n\n`tw channel threads` returns every thread in the channel; pagination filters (`--limit`, `--cursor`, `--since`, `--until`, `--unread`) are applied client-side after fetch. `--archive-filter` is applied server-side. Results are sorted newest-first by last activity. In `--json` / `--ndjson`, the response includes a `nextCursor` string (opaque) you can pass via `--cursor` to fetch the next page; NDJSON emits the cursor as a final `{ \"_meta\": true, \"nextCursor\": \"...\" }` line.\n\n## Away Status\n\n```bash\ntw away # Show current away status\ntw away set <type> [until] # Set away (type: vacation, parental, sickleave, other)\ntw away set vacation 2026-03-20 # Away until March 20\ntw away set vacation 2026-03-20 --from 2026-03-15 # Custom start date\ntw away clear # Clear away status\n```\n\n## Reactions\n\n```bash\ntw react thread <ref> \uD83D\uDC4D # Add reaction to thread\ntw react comment <ref> +1 # Add reaction (shortcode)\ntw react message <ref> heart # Add reaction to DM message\ntw react thread <ref> \uD83D\uDC4D --json # Output result as JSON\ntw unreact thread <ref> \uD83D\uDC4D # Remove reaction\ntw unreact thread <ref> \uD83D\uDC4D --json # Output result as JSON\n```\n\nSupported shortcodes: +1, -1, heart, tada, smile, laughing, thinking, fire, check, x, eyes, pray, clap, rocket, wave\n\n## Shell Completions\n\n```bash\ntw completion install # Install tab completions (prompts for shell)\ntw completion install bash # Install for specific shell\ntw completion install zsh\ntw completion install fish\ntw completion uninstall # Remove completions\n```\n\n### Diagnostics\n\n```bash\ntw doctor # Run local + network diagnostics\ntw doctor --offline # Skip Twist and npm network checks\ntw doctor --json # JSON output with per-check results\n```\n\n### Configuration\n\n```bash\ntw config view # Pretty-printed config, token masked, labels actual token source\ntw config view --json # Raw JSON, token masked\ntw config view --show-token # Include the full token\ntw config set unarchive-new-threads true # Persist: always unarchive new threads so they land in your Inbox\ntw config set unarchive-new-threads false # Persist: keep Twist's default (thread auto-archived for author)\n```\n\nUser preferences are stored under `userSettings` in the config file. Currently supported keys: `unarchive-new-threads`. The flag on `tw thread create` (`--unarchive` / `--no-unarchive`) overrides this default per-invocation.\n\n### Update\n\n```bash\ntw update # Update CLI to latest version\ntw update --check # Check for updates without installing, show channel\ntw update --check --json # Same, JSON envelope\ntw update --check --ndjson # Same, newline-delimited JSON envelope\ntw update --channel # Show current update channel\ntw update switch --stable # Switch to stable release channel\ntw update switch --pre-release # Switch to pre-release (next) channel\ntw update switch --pre-release --json # Same, JSON envelope\ntw update switch --pre-release --ndjson # Same, newline-delimited JSON envelope\n```\n\n### Changelog\n```bash\ntw changelog # Show last 5 versions\ntw changelog -n 3 # Show last 3 versions\ntw changelog --count 10 # Show last 10 versions\n```\n\n## Global Options\n\n```bash\n--no-spinner # Disable loading animations\n--progress-jsonl # Machine-readable progress events (JSONL to stderr)\n--progress-jsonl=<path> # Same, but write events to <path> instead of stderr\n--progress-jsonl <path> # Same as above (space-separated form also accepted)\n--accessible # Add text labels to color-coded output (also: TW_ACCESSIBLE=1)\n--non-interactive # Disable interactive prompts (auto-detected when stdin is not a TTY)\n--interactive # Force interactive mode even when stdin is not a TTY\n```\n\n## Output Formats\n\nAll list/view commands support:\n\n```bash\n--json # Output as JSON\n--ndjson # Output as newline-delimited JSON (for streaming)\n--full # Include all fields (default shows essential fields only)\n```\n\n## Dry Run\n\nMutating commands accept `--dry-run` to preview the operation without making the change. Where a command performs pre-flight validation (e.g. fetching the target thread to check channel access or ownership), those checks still run in dry-run \u2014 only the mutating write is skipped. Commands that have no pre-flight validation parse the reference and print the preview without hitting the API. The preview is structured:\n\n```\n[dry-run] Would <action>:\n <Key>: <resolved value>\n ...\nRun without --dry-run to execute.\n```\n\n## Reference System\n\nCommands accept flexible references:\n- **Numeric IDs**: `123` or `id:123`\n- **Twist URLs**: Full `https://twist.com/...` URLs (parsed automatically)\n- **Fuzzy names**: For workspaces/users - `\"My Workspace\"` or partial matches\n\n## Piping Content\n\nCommands that accept content (`thread create`, `thread reply`, `comment update`, `conversation reply`, `msg update`) auto-detect piped stdin:\n\n```bash\ncat notes.md | tw thread reply <ref>\ntw thread create <channel-ref> \"Title\" < body.md\necho \"Quick reply\" | tw conversation reply <ref>\n```\n\nIf no content argument is provided and no stdin is piped, the CLI opens `$EDITOR` for interactive input. In non-TTY environments (e.g. when called by an agent or in a pipeline), the editor is automatically skipped and the command fails fast with an actionable error message. Use `--non-interactive` to force this behavior even in a TTY, or `--interactive` to override auto-detection.\n\n## Common Workflows\n\n**View by URL (auto-routes to the right command):**\n```bash\ntw view https://twist.com/a/1585/ch/100/t/200 # View thread\ntw view https://twist.com/a/1585/ch/100/t/200/c/300 # View comment\ntw view https://twist.com/a/1585/msg/400 # View conversation\ntw view https://twist.com/a/1585/msg/400/m/500 --json # View message as JSON\n```\n\n**Check inbox and respond:**\n```bash\ntw inbox --unread --json\ntw thread view <id> --unread\ntw thread reply <id> \"Thanks, I'll look into this.\"\ntw thread done <id>\n```\n\n**Search and review:**\n```bash\ntw mentions --since 2026-04-01 --all --json\ntw search \"deployment\" --type threads --json\ntw thread view <thread-id>\n```\n\n**Check DMs:**\n```bash\ntw conversation unread --json\ntw conversation view <conversation-id>\ntw conversation with \"Alice Example\"\ntw conversation reply <id> \"Got it, thanks!\"\n```\n";
7
7
  export declare const SKILL_FILE_CONTENT: string;
8
8
  //# sourceMappingURL=content.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/lib/skills/content.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,cAAc,CAAA;AAErC,eAAO,MAAM,iBAAiB,2TAC8R,CAAA;AAE5T,eAAO,MAAM,YAAY,UAAU,CAAA;AAEnC,eAAO,MAAM,aAAa,QAAQ,CAAA;AAElC,eAAO,MAAM,aAAa,QAAsB,CAAA;AAEhD,eAAO,MAAM,aAAa,inpBAsYzB,CAAA;AAED,eAAO,MAAM,kBAAkB,QASd,CAAA"}
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/lib/skills/content.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,cAAc,CAAA;AAErC,eAAO,MAAM,iBAAiB,2TAC8R,CAAA;AAE5T,eAAO,MAAM,YAAY,UAAU,CAAA;AAEnC,eAAO,MAAM,aAAa,QAAQ,CAAA;AAElC,eAAO,MAAM,aAAa,QAAsB,CAAA;AAEhD,eAAO,MAAM,aAAa,ogqBAyYzB,CAAA;AAED,eAAO,MAAM,kBAAkB,QASd,CAAA"}
@@ -26,6 +26,9 @@ tw auth logout --json # Emits \`{"ok": true}\` (--ndjson is silent)
26
26
  tw auth logout --user <ref> # Target a specific stored account; mismatched ref errors with ACCOUNT_NOT_FOUND
27
27
  tw auth token view # Print the saved token to stdout (pipe-safe; refuses if TWIST_API_TOKEN is set)
28
28
  tw auth token view --user <ref> # Print the saved token for a specific stored account
29
+ tw account [list|current|use <ref>|remove <ref>] # Manage stored accounts; all support --json/--ndjson
30
+ # current's payload is {id, label, authMode, authScope, source:"config"} | {source:"env"} | {source:"legacy"}
31
+ tw auth login # Re-running auth login with a different OAuth grant adds a NEW account; default stays pinned unless none was set
29
32
  tw workspaces # List available workspaces
30
33
  tw workspace use <ref> # Set current workspace
31
34
  tw completion install # Install shell completions
@@ -1 +1 @@
1
- {"version":3,"file":"content.js","sourceRoot":"","sources":["../../../src/lib/skills/content.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,uBAAuB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAErE,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAA;AAErC,MAAM,CAAC,MAAM,iBAAiB,GAC1B,wTAAwT,CAAA;AAE5T,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAA;AAEnC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAA;AAElC,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAA;AAEh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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyY5B,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;QAC1B,UAAU;eACH,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC;WACrC,aAAa;;YAEZ,YAAY;aACX,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;;;EAGxC,aAAa,EAAE,CAAA"}
@@ -0,0 +1,22 @@
1
+ import type { TwistAccount } from './auth-provider.js';
2
+ import type { AuthMode } from './config.js';
3
+ /** Canonical `TwistAccount` factory. Applies the `'unknown'` / `''` defaults. */
4
+ export declare function makeTwistAccount(input: {
5
+ id: string;
6
+ label: string;
7
+ authMode?: AuthMode;
8
+ authScope?: string;
9
+ }): TwistAccount;
10
+ /**
11
+ * Adapt a Twist `getSessionUser` payload to a `TwistAccount`. Lives in its
12
+ * own module so `migrate-auth.ts` can import it without pulling in
13
+ * `auth-provider.ts`'s runtime graph.
14
+ */
15
+ export declare function toTwistAccount(sessionUser: {
16
+ id: number;
17
+ name: string;
18
+ }, metadata?: {
19
+ authMode?: AuthMode;
20
+ authScope?: string;
21
+ }): TwistAccount;
22
+ //# sourceMappingURL=twist-account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"twist-account.d.ts","sourceRoot":"","sources":["../../src/lib/twist-account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACpC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,YAAY,CAOf;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC1B,WAAW,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACzC,QAAQ,GAAE;IAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAC3D,YAAY,CAOd"}
@@ -0,0 +1,23 @@
1
+ /** Canonical `TwistAccount` factory. Applies the `'unknown'` / `''` defaults. */
2
+ export function makeTwistAccount(input) {
3
+ return {
4
+ id: input.id,
5
+ label: input.label,
6
+ authMode: input.authMode ?? 'unknown',
7
+ authScope: input.authScope ?? '',
8
+ };
9
+ }
10
+ /**
11
+ * Adapt a Twist `getSessionUser` payload to a `TwistAccount`. Lives in its
12
+ * own module so `migrate-auth.ts` can import it without pulling in
13
+ * `auth-provider.ts`'s runtime graph.
14
+ */
15
+ export function toTwistAccount(sessionUser, metadata = {}) {
16
+ return makeTwistAccount({
17
+ id: String(sessionUser.id),
18
+ label: sessionUser.name,
19
+ authMode: metadata.authMode,
20
+ authScope: metadata.authScope,
21
+ });
22
+ }
23
+ //# sourceMappingURL=twist-account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"twist-account.js","sourceRoot":"","sources":["../../src/lib/twist-account.ts"],"names":[],"mappings":"AAGA,iFAAiF;AACjF,MAAM,UAAU,gBAAgB,CAAC,KAKhC;IACG,OAAO;QACH,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,SAAS;QACrC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,EAAE;KACnC,CAAA;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC1B,WAAyC,EACzC,WAAwD,EAAE;IAE1D,OAAO,gBAAgB,CAAC;QACpB,EAAE,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;QAC1B,KAAK,EAAE,WAAW,CAAC,IAAI;QACvB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,SAAS,EAAE,QAAQ,CAAC,SAAS;KAChC,CAAC,CAAA;AACN,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { UserRecord, UserRecordStore } from '@doist/cli-core/auth';
2
+ import type { TwistAccount } from './auth-provider.js';
3
+ import { type Config } from './config.js';
4
+ /**
5
+ * `UserRecordStore` adapter over `config.users[]`. `StoredUser.token` is
6
+ * surfaced as `fallbackToken` — cli-core's name for the plaintext copy
7
+ * persisted only when the keyring is unreachable.
8
+ */
9
+ export declare function createTwistUserRecordStore(): UserRecordStore<TwistAccount>;
10
+ /**
11
+ * Resolve the default-or-first `UserRecord` from an already-loaded config.
12
+ * Returns `null` when no users are stored.
13
+ */
14
+ export declare function getDefaultUserRecord(config: Config): UserRecord<TwistAccount> | null;
15
+ //# sourceMappingURL=user-records.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-records.d.ts","sourceRoot":"","sources":["../../src/lib/user-records.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,KAAK,MAAM,EAA4C,MAAM,aAAa,CAAA;AAGnF;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI,eAAe,CAAC,YAAY,CAAC,CAmC1E;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,YAAY,CAAC,GAAG,IAAI,CAMpF"}
@@ -0,0 +1,84 @@
1
+ import { getConfig, updateConfig } from './config.js';
2
+ import { makeTwistAccount } from './twist-account.js';
3
+ /**
4
+ * `UserRecordStore` adapter over `config.users[]`. `StoredUser.token` is
5
+ * surfaced as `fallbackToken` — cli-core's name for the plaintext copy
6
+ * persisted only when the keyring is unreachable.
7
+ */
8
+ export function createTwistUserRecordStore() {
9
+ return {
10
+ async list() {
11
+ const config = await getConfig();
12
+ return (config.users ?? []).map(toRecord);
13
+ },
14
+ async upsert(record) {
15
+ const config = await getConfig();
16
+ const existing = config.users ?? [];
17
+ const next = fromRecord(record);
18
+ const index = existing.findIndex((u) => u.id === record.account.id);
19
+ const users = index >= 0
20
+ ? [...existing.slice(0, index), next, ...existing.slice(index + 1)]
21
+ : [...existing, next];
22
+ await updateConfig({ users });
23
+ },
24
+ async remove(id) {
25
+ const config = await getConfig();
26
+ const existing = config.users ?? [];
27
+ const index = existing.findIndex((u) => u.id === id);
28
+ if (index < 0)
29
+ return;
30
+ const users = [...existing.slice(0, index), ...existing.slice(index + 1)];
31
+ const updates = { users };
32
+ if (config.defaultUserId === id)
33
+ updates.defaultUserId = undefined;
34
+ await updateConfig(updates);
35
+ },
36
+ async getDefaultId() {
37
+ const config = await getConfig();
38
+ return config.defaultUserId ?? null;
39
+ },
40
+ async setDefaultId(id) {
41
+ await updateConfig({ defaultUserId: id ?? undefined });
42
+ },
43
+ };
44
+ }
45
+ /**
46
+ * Resolve the default-or-first `UserRecord` from an already-loaded config.
47
+ * Returns `null` when no users are stored.
48
+ */
49
+ export function getDefaultUserRecord(config) {
50
+ const users = config.users ?? [];
51
+ if (users.length === 0)
52
+ return null;
53
+ const defaultId = config.defaultUserId;
54
+ const user = (defaultId && users.find((u) => u.id === defaultId)) || users[0];
55
+ return toRecord(user);
56
+ }
57
+ function toRecord(user) {
58
+ const account = makeTwistAccount({
59
+ id: user.id,
60
+ label: user.name,
61
+ authMode: user.authMode,
62
+ authScope: user.authScope,
63
+ });
64
+ const trimmed = user.token?.trim();
65
+ const record = { account };
66
+ if (trimmed)
67
+ record.fallbackToken = trimmed;
68
+ return record;
69
+ }
70
+ function fromRecord(record) {
71
+ // Replace, don't merge: an absent `fallbackToken` strips the plaintext
72
+ // slot so it can't shadow a fresh keyring-backed write. cli-core contract.
73
+ const trimmed = record.fallbackToken?.trim();
74
+ const next = {
75
+ id: record.account.id,
76
+ name: record.account.label,
77
+ authMode: record.account.authMode,
78
+ authScope: record.account.authScope,
79
+ };
80
+ if (trimmed && trimmed.length > 0)
81
+ next.token = trimmed;
82
+ return next;
83
+ }
84
+ //# sourceMappingURL=user-records.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-records.js","sourceRoot":"","sources":["../../src/lib/user-records.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgC,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD;;;;GAIG;AACH,MAAM,UAAU,0BAA0B;IACtC,OAAO;QACH,KAAK,CAAC,IAAI;YACN,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAA;YAChC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAC7C,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,MAAM;YACf,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAA;YAChC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAA;YACnC,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;YAC/B,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,C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MAAM,CAAC,OAAO,CAAC,QAAQ;QACjC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS;KACtC,CAAA;IACD,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAA;IACvD,OAAO,IAAI,CAAA;AACf,CAAC"}
@@ -1,3 +1,7 @@
1
+ import { runMigrateLegacyAuth } from './lib/migrate-auth.js';
1
2
  import { updateAllInstalledSkills } from './lib/skills/update-installed.js';
3
+ // Failures must not break `npm install`. `createTwistTokenStore` re-runs the
4
+ // migration lazily for users who installed with `--ignore-scripts`.
2
5
  updateAllInstalledSkills({ local: false }).catch(() => { });
6
+ runMigrateLegacyAuth({ silent: true }).catch(() => { });
3
7
  //# sourceMappingURL=postinstall.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"postinstall.js","sourceRoot":"","sources":["../src/postinstall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAA;AAE3E,wBAAwB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"postinstall.js","sourceRoot":"","sources":["../src/postinstall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAA;AAE3E,6EAA6E;AAC7E,oEAAoE;AACpE,wBAAwB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;AAC1D,oBAAoB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/twist-cli",
3
- "version": "2.39.0",
3
+ "version": "2.41.0",
4
4
  "description": "TypeScript CLI for Twist",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",