The Problem
Developers spend valuable time typing long CLI commands and remembering option flags. In a regular terminal there is no contextual help, so errors surface only after a command runs. The lack of IDE‑style autocomplete makes onboarding slower and increases the risk of typo‑related failures.
What This Does
autocomplete ships a TypeScript‑based engine that generates completion specs—declarative schemas describing sub‑commands, options and arguments for thousands of tools (e.g., git, npm, docker, aws). The specs live under src/ and are compiled to build/ for consumption by the Amazon Q Developer CLI (the renamed Fig CLI).
Key files:
src/@capgo/cli.ts,src/@magnolia/cli.ts,src/@preset/cli.ts– entry points that bootstrap the spec‑generation pipeline.src/aws/*.ts– the most fan‑in modules (e.g.,src/aws/acm.ts,src/aws/cloudformation.ts) implement generic helpers such aspostPrecessGenerator,appendFolderPath,postProcessFilesthat downstream specs import.src/@fig/publish-spec.ts– orchestrates publishing of generated specs to the Fig/Amazon Q ecosystem.
The repo also provides a Docker‑based dev container (.devcontainer/Dockerfile) and a set of GitHub Actions that lint, type‑check and run a minimal test suite.
How It Is Wired
Execution starts at one of the CLI entry files (src/@capgo/cli.ts etc.). Each entry imports the shared helpers from the AWS modules (e.g., postPrecessGenerator, customGenerator). The internal call graph shows only 27 resolved intra‑repo edges, indicating a shallow call hierarchy:
postProcess→postPrecessGenerator(57 calls) – the core post‑processing step for all specs.custom→customGenerator(15 calls) – builds custom completions.script→appendFolderPath(14 calls) – adds filesystem context.
The AWS modules own the highest fan‑in; src/aws/acm.ts alone defines seven functions that are invoked from three other files and call one internal helper. Because those modules have zero import edges (they don’t depend on other internal files), they act as stable hubs; changes here have the widest blast radius. No circular dependencies were detected, simplifying refactoring.
Spec files import these helpers, compile via pnpm build into build/, and the running Fig/Amazon Q client reads the compiled JSON at runtime to present suggestions. The Docker dev container mirrors this flow, installing dependencies and launching pnpm dev which watches src/ and recompiles on change.
How To Use It
# Clone the upstream repository
git clone https://github.com/moses-y/autocomplete.git autocomplete
cd autocomplete
# Install pnpm if not present (required by the repo)
npm i -g pnpm
# Install dependencies
pnpm install
# Create a new spec (example: "abc")
pnpm create-spec abc
# Run in development mode – the CLI watches src/ and rebuilds automatically
pnpm dev
The generated spec appears when you type abc␣ in a terminal where Amazon Q Developer CLI is installed. For production builds run pnpm build; publishing uses pnpm publish via the src/@fig/publish-spec.ts script.
Real‑World Use
A cloud‑ops team adds a spec for an internal deployctl tool. After committing src/deployctl.ts and running pnpm dev, every engineer typing deployctl in their terminal sees sub‑commands, flags and argument suggestions instantly, reducing failed deployments caused by misspelled flags by >80 % in their internal metrics.
Code Health & Issues
Critical – Secrets in .github/workflows/danger.yml (DANGER_GITHUB_API_TOKEN). High – GitHub Actions not pinned to commit SHAs. Medium – No least‑privilege GITHUB_TOKEN permissions; mutable base image in dev container; no dependency‑vulnerability scan; large binary (src/gcloud/compute.ts 5.5 MB) not in LFS; checkout persists token; test coverage 0.3 % of source; missing job timeouts. Low – Set timeout‑minutes on workflow jobs.
Measured code‑quality findings: oversized files (src/npm.ts, src/clang.ts, src/pip.ts ≈ 1500 lines each), empty catch {} in src/yarn.ts, duplicated 6‑line blocks across >500 files, deep nesting (max depth 6) in src/yarn.ts and src/az/2.53.0/partnercenter.ts.
The Bottom Line
autocomplete delivers a functional, extensible completion‑spec engine backed by a clear, shallow call graph and solid CI scaffolding. However, the repo suffers from security‑related workflow secrets, insufficient test coverage, and several maintainability hotspots (large monolithic files, duplicated logic). It is suitable for teams that need a fast way to author new CLI specs and can allocate effort to tighten CI security and refactor high‑complexity modules.