Skip to content

feat: Add interactive template selection prompts#29

Closed
Shooksie wants to merge 1 commit intomainfrom
ao/task-201
Closed

feat: Add interactive template selection prompts#29
Shooksie wants to merge 1 commit intomainfrom
ao/task-201

Conversation

@Shooksie
Copy link
Copy Markdown
Contributor

When running 'ao init' without --template flag, users now get an interactive
template selection prompt when running in a terminal. This uses enquirer
to display available templates with arrow-key navigation.

Key changes:

  • Add enquirer dependency for interactive CLI prompts
  • Create src/utils/prompts.ts with selectTemplateInteractive function
  • Add isInteractiveTerminal helper to detect TTY environments
  • Modify initCommand to show interactive selection when:
    • No --template flag is provided
    • Running in an interactive terminal
    • Not using --force flag
  • Detection happens first, and detected type is pre-selected as default
  • Add PROMPT_CANCELLED error code for graceful handling of user cancellation
  • Add unit tests for the prompts utilities

The non-interactive behavior is preserved for CI/CD environments where
stdin is not a TTY. Users can still use --template to specify a template
non-interactively or rely on auto-detection.

Closes TASK-201

When running 'ao init' without --template flag, users now get an interactive
template selection prompt when running in a terminal. This uses enquirer
to display available templates with arrow-key navigation.

Key changes:
- Add enquirer dependency for interactive CLI prompts
- Create src/utils/prompts.ts with selectTemplateInteractive function
- Add isInteractiveTerminal helper to detect TTY environments
- Modify initCommand to show interactive selection when:
  - No --template flag is provided
  - Running in an interactive terminal
  - Not using --force flag
- Detection happens first, and detected type is pre-selected as default
- Add PROMPT_CANCELLED error code for graceful handling of user cancellation
- Add unit tests for the prompts utilities

The non-interactive behavior is preserved for CI/CD environments where
stdin is not a TTY. Users can still use --template to specify a template
non-interactively or rely on auto-detection.

Closes TASK-201
@Shooksie
Copy link
Copy Markdown
Contributor Author

Shooksie commented Mar 22, 2026

PR Review Status

PR Merge Conflict Detected

This PR has merge conflicts with the recently merged PR #28 (feat: add CLI UX flags).

Conflict Details

  • File: src/commands/init.ts - The PR uses console.log() but main now uses logger API
  • Both PRs modify the same file with conflicting changes

Code Review Findings (additional issues)

  1. ESLint Errors (2 issues in src/utils/prompts.ts):
    • Line 69: 'NodeJS' is not defined - Need to import the type
    • Line 129: 'value' is defined but never used
  2. console.log vs logger: Main branch uses logger object, PR uses console.log

Resolution Required

Manual conflict resolution and code fixes needed:

  1. Rebase your branch on the latest main:
git fetch origin
git checkout ao/task-201
git rebase origin/main
# Resolve conflicts in src/commands/init.ts
# Replace console.log with logger calls
git add src/commands/init.ts
git rebase --continue
git push --force-with-lease
  1. Fix ESLint errors:
    • Import NodeJS type or use { code: string } for error handling
    • Remove or use the unused value variable

Failed Rebase Attempt: 1/3 - This PR will be closed after 3 failed rebase attempts.

Copy link
Copy Markdown
Contributor Author

@Shooksie Shooksie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review - Issues Found

ESLint Errors (Must Fix)

  1. src/utils/prompts.ts:69 - 'NodeJS' is not defined - Import the type from @types/node or use a different approach
  2. src/utils/prompts.ts:129 - 'value' is defined but never used - Remove or use the variable

Code Quality

The PR uses console.log() directly but main has been refactored to use the logger API:

import { logger } from '../utils/logger.js';
// Instead of console.log(chalk.gray(...))
logger.info(chalk.gray(...));

What's Good

  • TypeScript types are properly defined for exported interfaces
  • Security audit passes (0 vulnerabilities)
  • Feature is well-designed with graceful cancellation handling
  • Tests are included

Next Steps

  1. Rebase on latest main (resolve merge conflict in src/commands/init.ts)
  2. Fix ESLint errors
  3. Replace console.log calls with logger API calls

@Shooksie
Copy link
Copy Markdown
Contributor Author

PR Review Summary

Status: Needs Revision (Failed Rebase Attempt: 1/3)

Code Quality Review: ✅ Good with 2 ESLint errors

The code is well-structured and functional (197 tests pass). However, there are 2 ESLint errors that must be fixed:

ESLint Errors (Must Fix)

Line Error Fix
69 'NodeJS' is not defined Use { code?: string } instead of NodeJS.ErrnoException
129 'value' is defined but never used Rename parameter to _value per ESLint config (argsIgnorePattern: '^_')

Merge Conflict

Conflicts with PR #28 (logger API changes) in . After rebasing on main:

  • Replace console.log with logger calls where main uses logging
  • Ensure the interactive selection still displays correctly

Positive Findings

  • ✅ TypeScript types are properly defined
  • ✅ Good error handling for user cancellation (PROMPT_CANCELLED)
  • ✅ Graceful degradation for non-interactive terminals
  • ✅ Tests pass (197/197)
  • ✅ No security vulnerabilities detected
  • ✅ Clean separation of concerns (prompts.ts utility)

Action Required

  1. Fix ESLint errors in src/utils/prompts.ts
  2. Rebase on latest main and resolve conflicts in src/commands/init.ts
  3. Push changes with --force-with-lease

After fixes, I will merge this PR. The feature is well-implemented and adds valuable UX improvement for ao init.

@Shooksie
Copy link
Copy Markdown
Contributor Author

PR Review Status - Rebase Attempt 1/3

Status: Conflicts with main branch

Current Issues (Must Resolve)

  1. Merge Conflicts in

    • Your PR uses but main now uses API
    • Both modify the same file with incompatible changes
  2. ESLint Errors (2 issues in ):

    Line Error Fix
    ~69 'NodeJS' is not defined Use { code?: string } instead of NodeJS.ErrnoException
    ~129 'value' is defined but never used Rename parameter to _value per ESLint config

Required Actions

  1. Rebase on latest main:
git fetch origin
git checkout ao/task-201
git rebase origin/main
  1. Resolve conflict in - replace with calls

  2. Fix ESLint errors:

    • Line 69: Change (error as NodeJS.ErrnoException) to (error as { code?: string })
    • Line 129: Rename value parameter to _value
  3. Force push:

git push --force-with-lease

After fixes are pushed, I will re-review and merge if everything passes.


This is Rebase Attempt 1/3. PR will be closed after 3 failed rebase attempts.

@Shooksie
Copy link
Copy Markdown
Contributor Author

PR Review Status - Rebase Attempt 1/3

Status: Conflicts with main branch

Current Issues (Must Resolve)

  1. Merge Conflicts in src/commands/init.ts

    • Your PR uses console.log but main now uses logger API
    • Both modify the same file with incompatible changes
  2. ESLint Errors (2 issues in src/utils/prompts.ts):

    • Line 69: NodeJS is not defined - Use { code?: string } instead of NodeJS.ErrnoException
    • Line 129: value is defined but never used - Rename parameter to _value

Required Actions

  1. Rebase on latest main:
    git fetch origin
    git checkout ao/task-201
    git rebase origin/main

  2. Resolve conflict in src/commands/init.ts - replace console.log with logger calls

  3. Fix ESLint errors:

    • Change (error as NodeJS.ErrnoException) to (error as { code?: string })
    • Rename value parameter to _value
  4. Force push: git push --force-with-lease

After fixes are pushed, I will re-review and merge if everything passes.

This is Rebase Attempt 1/3. PR will be closed after 3 failed rebase attempts.

@Shooksie
Copy link
Copy Markdown
Contributor Author

PR Review Status - Current Attempt

Status: Needs Revision (Failed Rebase Attempt: 1/3)

Code Quality Review

  • ✅ Tests: 197/197 passing
  • ✅ TypeScript: Types properly defined
  • ✅ Error handling: Graceful PROMPT_CANCELLED handling
  • ❌ ESLint: 2 errors must fix
  • ❌ Merge: Conflicts with main (logger API changes)

Issues Requiring Fix

1. ESLint Errors (src/utils/prompts.ts)

Line 69: 'NodeJS' is not defined
Line 129: 'value' is defined but never used

Fix:

  • Line 69: Change (error as NodeJS.ErrnoException)(error as {code?: string})
  • Line 129: Rename value_value per ESLint config

2. Merge Conflict (src/commands/init.ts)

Rebase on main and replace console.log with logger calls:

git fetch origin
git checkout ao/task-201
git rebase origin/main
# Resolve conflicts
git push --force-with-lease

Feature Assessment

This is a well-implemented feature that adds valuable UX. Once conflicts are resolved and ESLint errors fixed, this PR is mergeable.


Automated review by ao-starter workflow

@Shooksie Shooksie closed this Mar 22, 2026
@Shooksie Shooksie deleted the ao/task-201 branch March 22, 2026 21:13
@Shooksie
Copy link
Copy Markdown
Contributor Author

PR Review Status - Rebase Attempt 2/3

Status: Still Needs Revision

I checked your latest commits and ran linting. The following issues remain:

ESLint Errors (Must Fix) in src/utils/prompts.ts

Line Error Fix
69 'NodeJS' is not defined Change (error as NodeJS.ErrnoException) to (error as { code?: string })
129 'value' is defined but never used Rename parameter to _value per ESLint config (argsIgnorePattern: '^_')

Merge Conflict with main

When rebasing on origin/main, there is a conflict in src/commands/init.ts:

  • Main imports: import { setLoggerConfig, logger } from '../utils/logger.js';
  • Your PR is missing the logger import and uses console.log

Required Actions

  1. Rebase on latest main:
    git fetch origin
    git rebase origin/main
  2. Resolve conflict in src/commands/init.ts:
    • Add import { setLoggerConfig, logger } from '../utils/logger.js'; after other imports
    • Replace console.log with logger.info() calls where appropriate
  3. Fix ESLint errors in src/utils/prompts.ts:
    • Line 69: Change (error as NodeJS.ErrnoException) to (error as { code?: string })
    • Line 129: Rename value parameter to _value
  4. Push changes:
    git push --force-with-lease

What's Working Well

  • Feature is well-designed and adds good UX
  • Proper error handling for user cancellation (PROMPT_CANCELLED)
  • Graceful degradation for non-interactive terminals
  • Tests included

After fixes are pushed, I will re-review and merge if all checks pass.


This is Rebase Attempt 2/3. PR will be closed after 3 failed rebase attempts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant