Skip to content

feat(cli): implement vcs auth + stack detect (fixes all Greptile issues)#576

Open
threebeats wants to merge 4 commits into
profullstack:masterfrom
threebeats:feat/config-payments-auth
Open

feat(cli): implement vcs auth + stack detect (fixes all Greptile issues)#576
threebeats wants to merge 4 commits into
profullstack:masterfrom
threebeats:feat/config-payments-auth

Conversation

@threebeats
Copy link
Copy Markdown

What

Implements two CLI commands that were stubs:

  • config vcs auth — interactive token setup, persists to local vault
  • config stack detect — auto-detects stack from project files

Fixes from previous attempt

  • ✅ Removed stray }); that broke config module parse
  • ✅ Fixed vcs auth command chain (was attached to wrong parent)
  • ✅ Fixed Bun detection priority (bun.lock before package.json)
  • ✅ Removed unused imports

Authorize edits

Allow edits from maintainers enabled.

Elias Sentinel added 2 commits June 4, 2026 11:29
- vcs auth: interactive token setup wizard with provider selection
  and vault persistence via setSecretInLocal
- stack detect: auto-detect language/framework from project files
  (package.json, bun.lock, pyproject.toml, Cargo.toml, etc.)

Both commands previously existed as stubs with [stub] placeholders.
This PR replaces them with real implementations that persist to
the local vault and match the patterns established by login.ts
and the existing vault API.

Related: profullstack#564
- Fixed stray }); that caused config module to crash
- Fixed vcs auth command being chained under wrong parent
- Fixed Bun detection priority (bun.lock checked before package.json)
- Removed unused imports (readFileSync)
- All three issues from Greptile review are addressed
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 4, 2026

Greptile Summary

This PR replaces two CLI stubs with working implementations: config stack detect (file-based stack auto-detection) and config vcs auth (interactive token setup with vault persistence). Issues called out in the previous review round — silent invalid-provider mapping and unhandled vault-write rejection — are both fixed here.

  • stack detect: scans --cwd for well-known marker files in priority order (bun.lock before package.json), uses readdirSync for glob patterns and existsSync for exact names, exits on first match.
  • vcs auth: prompts for provider if --provider is omitted, maps to the correct env-var key with explicit null guard, checks for an existing env var before writing, and wraps the vault write in try/catch with process.exit(1) on failure.

Confidence Score: 5/5

Safe to merge — the two new implementations are self-contained CLI actions with no shared-state mutations; both interactive flows handle cancellation and I/O errors cleanly.

Both commands replace stubs with straightforward prompt-and-persist flows. The previously flagged issues (provider null fallback, unhandled vault rejection) are addressed. Remaining notes are style-level: a fragile slice(1) glob expansion and an ambiguous 'Using environment' message on CTRL+C. Neither affects correctness for any currently defined input.

packages/cli/src/commands/config.ts — the only changed file; the glob expansion logic in detect is worth a second look if new wildcard patterns are added in the future.

Important Files Changed

Filename Overview
packages/cli/src/commands/config.ts Implements stack detect and vcs auth commands replacing stubs; provider null-check and vault write error handling from previous threads are now addressed; minor fragility remains in glob expansion logic

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["sh1pt config vcs auth"] --> B{"--provider flag?"}
    B -- Yes --> C["Use provided value"]
    B -- No --> D["prompts: select provider"]
    D --> E{"User selected?"}
    E -- No --> F["return"]
    C --> G["Compute envVar"]
    E -- Yes --> G
    G --> H{"envVar is null?"}
    H -- Yes --> I["error + exit 1"]
    H -- No --> J{"Env var already set?"}
    J -- Yes --> K["prompts: overwrite confirm"]
    K --> L{"Confirmed?"}
    L -- No --> M["log using env + return"]
    L -- Yes --> N["prompts: password input"]
    J -- No --> N
    N --> O{"Token entered?"}
    O -- No --> P["log no token + return"]
    O -- Yes --> Q["setSecretInLocal"]
    Q --> R{"Write ok?"}
    R -- Yes --> S["log success"]
    R -- No --> T["error + exit 1"]
Loading

Reviews (3): Last reviewed commit: "fix: wrap setSecretInLocal in try/catch ..." | Re-trigger Greptile

Comment thread packages/cli/src/commands/config.ts Outdated
Comment on lines +163 to +166
.action(async (opts: { cwd: string }) => {
const { existsSync } = await import("node:fs");
const { join } = await import("node:path");
const cwd = opts.cwd;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Redundant dynamic imports shadow top-level statics

existsSync and join are already statically imported at the top of the file (lines 4-5). Re-importing them dynamically inside the action creates shadowing local bindings and redundant await import calls, even though they resolve from the module cache.

Suggested change
.action(async (opts: { cwd: string }) => {
const { existsSync } = await import("node:fs");
const { join } = await import("node:path");
const cwd = opts.cwd;
.action(async (opts: { cwd: string }) => {
const cwd = opts.cwd;

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment thread packages/cli/src/commands/config.ts Outdated
- Fix: invalid provider fallthrough now shows error instead of silently
  assigning GITEA_TOKEN
- Fix: bare catch {} now logs a debug message
Comment thread packages/cli/src/commands/config.ts Outdated
@threebeats
Copy link
Copy Markdown
Author

All Greptile feedback has been addressed:

  • Invalid provider fallthrough → error message with process.exit
  • setSecretInLocal wrapped in try/catch
  • Bare catch {} now logs a debug message
  • Stray }); removed, proper vcsCmd chain, Bun detection priority fixed

Confidence score went from 1/5 → 3/5 → 4/5. Ready for merge when you are.

@threebeats
Copy link
Copy Markdown
Author

Also submitted PR #578 (git URL normalization fix for #499) while waiting. Both PRs are clean and tested. Happy to rebase if needed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant