-
Notifications
You must be signed in to change notification settings - Fork 0
[DX-1115] 1 command installer #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6627794
chore: add tar dependency for skill bundle extraction
umair-ably 7e5739e
feat: add tool-detector service for AI coding tools
umair-ably b34a846
feat: add skills-downloader service
umair-ably 467f042
feat: add skills-installer and claude-plugin-installer services
umair-ably f809263
feat(skills): add ably skills install command
umair-ably 72fc553
feat: add ably init for 1-command onboarding
umair-ably 2981a55
test(e2e): cover ably skills install end-to-end
umair-ably ae4ee8b
chore: drop Zed from supported skill targets
umair-ably 8178b8f
refactor: replace stringly-typed install status/method with enums
umair-ably 8861cc1
feat(accounts:login): add hidden --skip-logo flag
umair-ably d091c2a
refactor: extract resolveSkillsTargets helper
umair-ably da8b91d
feat(skills): verify SLSA attestation on downloaded tarballs
umair-ably d2a548d
fix: allow skills:install inside the interactive shell
umair-ably 4a709cd
fix(skills): correct vscode and windsurf install paths
umair-ably 35b4162
fix(skills): tighten install flow — pin manifest, dedupe JSON termina…
umair-ably 449299a
test(claude-plugin-installer): pass explicit ref and assert it reache…
umair-ably File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| import { Flags } from "@oclif/core"; | ||
| import chalk from "chalk"; | ||
|
|
||
| import { AblyBaseCommand } from "../base-command.js"; | ||
| import { coreGlobalFlags } from "../flags.js"; | ||
| import { | ||
| runSkillsInstall, | ||
| SkillsInstallOutput, | ||
| } from "../services/skills-install-runner.js"; | ||
| import { TARGET_CONFIGS } from "../services/skills-installer.js"; | ||
| import { resolveSkillsTargets } from "../services/skills-target-prompt.js"; | ||
| import { BaseFlags } from "../types/cli.js"; | ||
| import { displayLogo } from "../utils/logo.js"; | ||
| import { formatHeading, formatResource } from "../utils/output.js"; | ||
| import isTestMode from "../utils/test-mode.js"; | ||
|
|
||
| export default class Init extends AblyBaseCommand { | ||
| static override description = | ||
| "Set up Ably for AI-powered development — authenticate and install Agent Skills"; | ||
|
|
||
| static override examples = [ | ||
| "<%= config.bin %> <%= command.id %>", | ||
| "<%= config.bin %> <%= command.id %> --target claude-code", | ||
| "<%= config.bin %> <%= command.id %> --target cursor --target windsurf", | ||
| "<%= config.bin %> <%= command.id %> --target auto", | ||
| "<%= config.bin %> <%= command.id %> --json", | ||
| ]; | ||
|
|
||
| static override flags = { | ||
| ...coreGlobalFlags, | ||
| target: Flags.string({ | ||
| char: "t", | ||
| multiple: true, | ||
| options: ["auto", ...Object.keys(TARGET_CONFIGS)], | ||
| default: ["auto"], | ||
| description: "Target IDE(s) to install skills for", | ||
| }), | ||
| }; | ||
|
|
||
| async run(): Promise<void> { | ||
| const { flags } = await this.parse(Init); | ||
| const jsonMode = this.shouldOutputJson(flags); | ||
|
|
||
| if (flags.target.includes("auto") && flags.target.length > 1) { | ||
| this.fail( | ||
| new Error( | ||
| "--target auto cannot be combined with explicit targets. Use either auto-detect or named targets, not both.", | ||
| ), | ||
| flags, | ||
| "init", | ||
| ); | ||
| } | ||
|
|
||
| if (!jsonMode) { | ||
| displayLogo(this.log.bind(this)); | ||
| } | ||
|
|
||
| await this.runAuth(flags); | ||
|
|
||
| const resolvedTargets = await resolveSkillsTargets({ | ||
| flags, | ||
| jsonMode, | ||
| log: this.log.bind(this), | ||
| warn: (msg) => this.logWarning(msg, flags), | ||
| exit: () => this.exit(130), | ||
| }); | ||
| if (resolvedTargets === null) { | ||
| if (!jsonMode) this.displayGettingStarted(); | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| await runSkillsInstall( | ||
| { target: resolvedTargets }, | ||
| this.buildInstallOutput(flags), | ||
| ); | ||
| } catch (error) { | ||
| this.fail(error, flags, "init"); | ||
| } | ||
|
|
||
| if (!jsonMode) { | ||
| this.displayGettingStarted(); | ||
| } | ||
| } | ||
|
|
||
| private buildInstallOutput(flags: BaseFlags): SkillsInstallOutput { | ||
| return { | ||
| jsonMode: this.shouldOutputJson(flags), | ||
| progress: (msg) => this.logProgress(msg, flags), | ||
| success: (msg) => this.logSuccessMessage(msg, flags), | ||
| warning: (msg) => this.logWarning(msg, flags), | ||
| log: (msg) => this.log(msg), | ||
| emitResult: (data) => this.logJsonResult(data, flags), | ||
| }; | ||
| } | ||
|
|
||
| private displayGettingStarted(): void { | ||
| const $ = chalk.green("$"); | ||
| const cmd = (s: string) => chalk.cyan(s); | ||
| const note = (s: string) => chalk.dim(s); | ||
|
|
||
| this.log(`${formatHeading("Getting started with the Ably CLI")}\n`); | ||
| this.log( | ||
| "The Ably CLI lets you publish messages, subscribe to channels, manage", | ||
| ); | ||
| this.log("apps and keys, and explore Ably from your terminal.\n"); | ||
|
|
||
| this.log("Try it — open two terminals and run:"); | ||
| this.log( | ||
| ` ${$} ${cmd("ably channels subscribe my-channel")} ${note("# terminal 1")}`, | ||
| ); | ||
| this.log( | ||
| ` ${$} ${cmd('ably channels publish my-channel "hello world"')} ${note("# terminal 2")}\n`, | ||
| ); | ||
|
|
||
| this.log("Useful next steps:"); | ||
| this.log( | ||
| ` ${$} ${cmd("ably --help")} ${note("# browse all commands")}\n`, | ||
| ); | ||
|
|
||
| this.log("Docs: https://ably.com/docs/cli\n"); | ||
| } | ||
|
|
||
| private async runAuth(flags: BaseFlags): Promise<void> { | ||
| if (this.hasControlApiAccess()) { | ||
| if (!this.shouldOutputJson(flags)) { | ||
| const account = this.configManager.getCurrentAccount(); | ||
| const label = account?.accountName | ||
| ? `${account.accountName}${account.accountId ? ` (${account.accountId})` : ""}` | ||
| : "stored credentials"; | ||
| this.logSuccessMessage( | ||
| `Already authenticated with ${formatResource(label)}.`, | ||
| flags, | ||
| ); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| if (!this.shouldOutputJson(flags)) { | ||
| this.log(`\n${formatHeading("Authenticate with Ably")}\n`); | ||
| } | ||
|
|
||
| // accounts:login handles JSON mode natively — emitting an | ||
| // awaiting_authorization event with userCode + verificationUri so | ||
| // headless callers can render the device-flow prompt themselves. | ||
| // We pass --skip-logo to avoid printing the Ably ASCII art twice | ||
| // (init already printed it above). | ||
| const loginArgv: string[] = ["--skip-logo"]; | ||
| if (flags.json) loginArgv.push("--json"); | ||
| else if (flags["pretty-json"]) loginArgv.push("--pretty-json"); | ||
| // Suppress accounts:login's terminal {status:"completed"} JSON line so | ||
| // init's own terminator in finally() is the only one in the stream. | ||
| if (flags.json || flags["pretty-json"]) { | ||
| loginArgv.push("--skip-completed-status"); | ||
| } | ||
|
|
||
| // Test hook: intercept the accounts:login delegation so unit tests can | ||
| // verify init's unauthenticated branch without spinning up the real | ||
| // OAuth device-code flow. Tests set globalThis.__TEST_MOCKS__.runLogin to | ||
| // a recording function or one that throws. | ||
| const loginRunner = | ||
| isTestMode() && globalThis.__TEST_MOCKS__?.runLogin | ||
| ? ( | ||
| globalThis.__TEST_MOCKS__ as { | ||
| runLogin: (argv: string[]) => Promise<void>; | ||
| } | ||
| ).runLogin | ||
| : (argv: string[]) => this.config.runCommand("accounts:login", argv); | ||
|
|
||
| try { | ||
| await loginRunner(loginArgv); | ||
| } catch (error) { | ||
| this.fail(error, flags, "init"); | ||
| } | ||
| } | ||
|
|
||
| // Checks for Control API auth (account-level OAuth access token), which is | ||
| // what `accounts:login` provides. Data-plane env vars (ABLY_API_KEY / | ||
| // ABLY_TOKEN) intentionally do NOT count here — they only authenticate the | ||
| // realtime/REST product API and don't grant Control API access (apps, keys, | ||
| // queues, integrations, etc.) that the rest of the CLI relies on. | ||
| private hasControlApiAccess(): boolean { | ||
| if (process.env.ABLY_ACCESS_TOKEN) return true; | ||
| return Boolean(this.configManager.getAccessToken()); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { BaseTopicCommand } from "../../base-topic-command.js"; | ||
|
|
||
| export default class Skills extends BaseTopicCommand { | ||
| protected topicName = "skills"; | ||
| protected commandGroup = "Agent Skills"; | ||
|
|
||
| static override description = "Install Ably Agent Skills for AI coding tools"; | ||
|
|
||
| static override examples = [ | ||
| "<%= config.bin %> <%= command.id %> install", | ||
| "<%= config.bin %> <%= command.id %> install --target claude-code", | ||
| ]; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { Flags } from "@oclif/core"; | ||
|
|
||
| import { AblyBaseCommand } from "../../base-command.js"; | ||
| import { coreGlobalFlags } from "../../flags.js"; | ||
| import { | ||
| runSkillsInstall, | ||
| SkillsInstallOutput, | ||
| } from "../../services/skills-install-runner.js"; | ||
| import { TARGET_CONFIGS } from "../../services/skills-installer.js"; | ||
| import { resolveSkillsTargets } from "../../services/skills-target-prompt.js"; | ||
| import { BaseFlags } from "../../types/cli.js"; | ||
|
|
||
| export default class SkillsInstall extends AblyBaseCommand { | ||
| static override description = | ||
| "Install Ably Agent Skills into AI coding tools"; | ||
|
|
||
| static override examples = [ | ||
| "<%= config.bin %> <%= command.id %>", | ||
| "<%= config.bin %> <%= command.id %> --target claude-code", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Examples for other options? |
||
| "<%= config.bin %> <%= command.id %> --target cursor --target windsurf", | ||
| "<%= config.bin %> <%= command.id %> --target auto", | ||
| "<%= config.bin %> <%= command.id %> --json", | ||
| ]; | ||
|
|
||
| static override flags = { | ||
| ...coreGlobalFlags, | ||
| target: Flags.string({ | ||
| char: "t", | ||
| multiple: true, | ||
| options: ["auto", ...Object.keys(TARGET_CONFIGS)], | ||
| default: ["auto"], | ||
| description: "Target IDE(s) to install skills for", | ||
| }), | ||
| }; | ||
|
|
||
| async run(): Promise<void> { | ||
| const { flags } = await this.parse(SkillsInstall); | ||
| const jsonMode = this.shouldOutputJson(flags); | ||
|
|
||
| if (flags.target.includes("auto") && flags.target.length > 1) { | ||
| this.fail( | ||
| new Error( | ||
| "--target auto cannot be combined with explicit targets. Use either auto-detect or named targets, not both.", | ||
| ), | ||
| flags, | ||
| "skillsInstall", | ||
| ); | ||
| } | ||
|
|
||
| const resolvedTargets = await resolveSkillsTargets({ | ||
| flags, | ||
| jsonMode, | ||
| log: this.log.bind(this), | ||
| warn: (msg) => this.logWarning(msg, flags), | ||
| exit: () => this.exit(130), | ||
| }); | ||
| if (resolvedTargets === null) return; | ||
|
|
||
| try { | ||
| await runSkillsInstall( | ||
| { target: resolvedTargets }, | ||
| this.buildInstallOutput(flags), | ||
| ); | ||
| } catch (error) { | ||
| this.fail(error, flags, "skillsInstall"); | ||
| } | ||
| } | ||
|
|
||
| protected buildInstallOutput(flags: BaseFlags): SkillsInstallOutput { | ||
| return { | ||
| jsonMode: this.shouldOutputJson(flags), | ||
| progress: (msg) => this.logProgress(msg, flags), | ||
| success: (msg) => this.logSuccessMessage(msg, flags), | ||
| warning: (msg) => this.logWarning(msg, flags), | ||
| log: (msg) => this.log(msg), | ||
| emitResult: (data) => this.logJsonResult(data, flags), | ||
| }; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running this you get a double Ably logo, probably should do just one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed - ensured it also still shows the Ably logo if someone uses login in isolation too