Skip to content

Commit ca6374c

Browse files
Merge hardening update and prepare 1.0.1
2 parents 29b89d2 + 2d519dd commit ca6374c

23 files changed

Lines changed: 675 additions & 453 deletions
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Bug report
3+
about: Report a reproducible problem
4+
title: "[Bug]: "
5+
labels: bug
6+
---
7+
8+
## What happened?
9+
10+
## Steps to reproduce
11+
1.
12+
2.
13+
3.
14+
15+
## Expected behavior
16+
17+
## Environment
18+
- OS:
19+
- Version/commit:
20+
21+
## Logs or screenshots
22+
Remove secrets before pasting logs.

.github/pull_request_template.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Summary
2+
3+
## Validation
4+
- [ ] Tests/checks run
5+
- [ ] Documentation updated
6+
- [ ] No secrets committed
7+
8+
## Screenshots / notes

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
# Cancel superseded runs on the same ref to save CI minutes.
10+
concurrency:
11+
group: ci-${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build-and-test:
16+
name: Build & test (Node ${{ matrix.node }})
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
# The dev/test toolchain (vitest 4 via rolldown) requires Node 20+
22+
# (it imports `styleText` from node:util, added in Node 20). The published
23+
# CLI bundle still targets Node 18, but CI builds and tests on 20/22.
24+
node: ["20", "22"]
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Node ${{ matrix.node }}
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: ${{ matrix.node }}
33+
cache: npm
34+
35+
- name: Install dependencies
36+
run: npm ci
37+
38+
- name: Typecheck
39+
run: npm run typecheck
40+
41+
- name: Lint
42+
run: npm run lint
43+
44+
- name: Build
45+
run: npm run build
46+
47+
# The test suite is fully offline (no live AI provider calls), so no API keys are needed.
48+
- name: Test
49+
run: npm test

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Changelog
2+
3+
All notable changes to Setupr will be documented in this file. Setupr keeps a changelog because it is a versioned developer tool with user-facing CLI behavior.
4+
5+
## Unreleased
6+
7+
### Added
8+
- Added real repository visual snapshot assets generated from the current file tree.
9+
- Added public maintenance documentation updates: security policy, issue/PR templates, and repository snapshot notes.
10+
11+
### Validation
12+
- Re-ran the documented test suite during the polish pass and recorded the real test status in `docs/project-snapshot.md`.
13+
14+
## Initial Public Version
15+
16+
- Published the first public project version.

README.md

Lines changed: 105 additions & 429 deletions
Large diffs are not rendered by default.

SECURITY.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
Security fixes are handled on the default branch unless a release branch is explicitly listed.
6+
7+
## Reporting a Vulnerability
8+
9+
Please do not open a public issue for a suspected vulnerability. Email the maintainer or use GitHub's private vulnerability reporting when available. Include:
10+
11+
- Affected version or commit
12+
- Steps to reproduce
13+
- Impact and likelihood
14+
- Any relevant logs with secrets removed
15+
16+
## Secret Handling
17+
18+
Never commit API keys, Telegram tokens, OAuth credentials, database files, `.env` files, or local user exports. Use `.env.example` for placeholders only.
19+
20+
Secrets are redacted on a best-effort basis (`redactText`/`redactObject` in `src/core/engine.ts`) before commands, history, and logs are persisted. This targets common token shapes and `NAME=value` credential assignments — it is not a guarantee that no secret will ever reach a log file.
21+
22+
## Threat Model
23+
24+
Setupr runs real shell commands on your machine with your full user privileges. The command-safety
25+
layer (`src/agent/safety.ts`) is a **best-effort, defense-in-depth guard, not a sandbox.** It
26+
classifies each planned command and decides whether to allow, confirm, or block it:
27+
28+
- **Block (cannot be bypassed by `--force`)** — clearly destructive or hostile patterns such as
29+
`rm -rf /` (and `~`, `*`, `$HOME` variants), `sudo`, `chmod 777`, `chown -R`, and
30+
`curl … | sh`/`| bash` pipe-to-shell installs.
31+
- **Confirm** — high/medium-risk commands (dependency installs, commands that delete files or reset
32+
git state, commands that embed a secret value or `KEY=value` credential assignment). `--force`
33+
may proceed past a **medium**-risk confirmation using safe defaults, but **never** past a
34+
high-risk or blocked one.
35+
- **Allow** — everything else.
36+
37+
What this layer is **not**:
38+
39+
- **Not a security boundary.** Anything you could run in your shell, a command run through Setupr
40+
can run.
41+
- **The block list is a denylist, and denylists are inherently incomplete.** It catches common,
42+
obvious footguns; an obfuscated or equivalent destructive command can get past it. Treat the
43+
guard as a seatbelt, not a vault door.
44+
- **Trust the project and its AI-generated plan.** When AI planning is enabled, setup steps may be
45+
proposed by a model based on the project's contents. Review the plan — especially before using
46+
`--force` — the way you would review a shell script you downloaded.
47+
48+
Recommendations: run Setupr only against projects you trust, read the pre-execution plan before
49+
confirming, be deliberate with `--force`, and keep real secrets in `.env` files rather than inline
50+
in commands.

docs/COMMANDS.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Commands
2+
3+
Full reference of all Setupr CLI commands.
4+
5+
## TUI Commands (Rich Interactive UI)
6+
7+
| Command | Description |
8+
|---------|-------------|
9+
| `setupr` / `dashboard` | Project dashboard with health, git, env, processes, history, and quick commands |
10+
| `setup` | Full project setup — scan, install runtime, deps, env, verify |
11+
| `chat <question>` | AI director chat TUI for project questions, steering, plans, logs, and context |
12+
| `status` | Dashboard/status view with plain, JSON, or TUI output |
13+
| `start` | Start and track a managed project process |
14+
| `doctor` | Diagnose environment health (runtimes, deps, ports) |
15+
| `update` | Check for dependency updates with breaking change warnings |
16+
| `clean` | Review and remove artifacts (`--deps`, `--share`, `--all`; positional `deps`, `share`, `all` also work) |
17+
| `env` | Open the .env editor TUI or manage project .env files from .env.example |
18+
| `auth` | Manage global Setupr AI provider API keys and models |
19+
20+
## Non-TUI Commands (Plain Terminal)
21+
22+
| Command | Description |
23+
|---------|-------------|
24+
| `env init\|check\|sync\|smart` | Manage .env files in plain mode with subcommands |
25+
| `ps` | List Setupr-managed processes |
26+
| `stop [target]` | Stop one or all managed processes |
27+
| `restart [target]` | Restart a managed process |
28+
| `info` | Show project summary |
29+
| `list` | List available scripts/commands |
30+
| `run <script>` | Run a project script |
31+
| `switch <version>` | Switch runtime version |
32+
| `add <package>` | Smart add dependency |
33+
| `remove <package>` | Remove dependency |
34+
| `port [number]` | Check/find/kill port |
35+
| `deps [list\|audit\|why\|licenses]` | Dependency tree, audit summary, package reasoning, and license checks |
36+
| `config` | Manage setupr config |
37+
| `help [command]` | Show global or command-specific help |
38+
| `lock` | Snapshot environment state |
39+
| `diff` | Compare current vs locked state |
40+
| `logs [target]` | Show managed process logs, falling back to package-manager logs |
41+
| `test [run\|quick\|full\|ci\|smoke\|unit\|integration\|e2e\|watch\|coverage\|changed\|file\|failed\|doctor\|list\|report\|clean\|fix\|security]` | Run verification suites, smoke checks, and reports |
42+
| `security [scan\|quick\|deep\|deps\|secrets\|env\|docker\|ci\|code\|routes\|auth\|headers\|doctor\|report\|baseline\|ignore\|fix\|watch\|test]` | Run defensive security scans, baselines, ignores, and safe fixes |
43+
| `fix [doctor\|env\|lint\|format\|security\|all]` | Preview or run grouped safe fixes |
44+
| `release [check\|publish-check\|notes\|version]` | Release readiness checks, package dry-runs, notes, and version summaries |
45+
| `perf [startup\|scan\|context\|status]` | Measure Setupr scan/context/status performance |
46+
| `github [status\|ci\|pr\|issue]` | Show GitHub repository, Actions, PR, and issue targets |
47+
| `registry <npm\|pypi\|crates> <package>` | Look up package registry information |
48+
| `build` | Detect and run build command |
49+
| `deploy` | Run deploy scripts |
50+
| `open [repo\|ide]` | Open in browser/IDE/repo |
51+
| `git` | Git workflows plus commit-message, PR-description, branch-check, and conflict helper |
52+
| `init` | Scaffold new projects from stacks or templates |
53+
| `migrate <npm\|yarn\|pnpm\|bun>` | Migrate package manager metadata and lockfiles |
54+
| `ci <github\|gitlab\|bitbucket\|circleci>` | Generate CI/CD config |
55+
| `docker <generate\|compose\|check>` | Generate Dockerfile/compose files or check Docker readiness |
56+
| `secrets <init\|set\|get\|list\|remove\|export\|import\|rotate>` | Manage encrypted project-local secrets |
57+
| `templates <new\|list\|save\|remove>` | Create, save, list, or remove templates |
58+
| `workspace <list\|run\|exec\|add\|info\|check>` | Operate on monorepo workspaces |
59+
| `health [full\|deps\|security\|outdated\|size]` | Run project health checks |
60+
| `share <export\|import\|inspect>` | Export/import shareable setup bundles |
61+
| `notes <add\|list\|remove\|clear>` | Manage project-local notes in `.setupr` |
62+
| `history [list] [limit]` | Show recent project-local Setupr history |
63+
| `context <show\|export\|import>` | Export/import notes and history for team handoff |
64+
| `plugin <create\|validate\|doctor\|install\|remove\|list\|info\|enable\|disable>` | Manage Setupr plugins and plugin development |
65+
| `lint <run\|setup\|fix>` | Run or set up linting |
66+
| `format <run\|check\|setup>` | Run or set up formatting |
67+
68+
## Flags
69+
70+
| Flag | Description |
71+
|------|-------------|
72+
| `--force` | Skip safe prompts, install what project specifies, and stop only for blockers or destructive choices |
73+
| `--no-tui` / `--plain` | Plain terminal output for CI/CD, piping, SSH |
74+
| `--deps` | With `clean`, remove dependency/cache artifacts |
75+
| `--share` | With `clean`, remove sensitive/local-only files before sharing a project |
76+
| `--all` | With `clean`, remove dependencies, build output, caches, and local env files |
77+
78+
## TUI Navigation
79+
80+
- **Arrow keys**: Move between neighboring panels in the dashboard
81+
- **Tab / Shift+Tab**: Move to the next or previous focusable panel
82+
- **Mouse click**: Focus a panel in terminals that support SGR mouse events
83+
- **Mouse click inside focused input**: Move the text cursor where the terminal reports coordinates accurately
84+
- **Option/Alt+Arrow**: Move by word where the terminal sends a compatible sequence
85+
- **Option/Alt+Delete or Ctrl+W**: Delete the previous word
86+
- **Ctrl+A / Ctrl+E**: Jump to start/end of input
87+
- **Ctrl+U / Ctrl+K**: Clear before/after cursor
88+
- **Enter**: Confirm / submit focused inputs
89+
- **Esc**: Leave or skip the active input when supported
90+
- **q**: Quit when focus is not inside an input
91+
92+
The TUI runs in the terminal alternate screen, so exiting returns to the original shell history instead of leaving the dashboard printed in the scrollback. It enables SGR mouse reporting and bracketed paste while active, then disables both on cleanup. It does not set a background color; Terminal, iTerm2, Ghostty, and other terminal profiles keep control of their own theme/background. Panels are drawn with Unicode box-drawing characters because terminal UIs render in character cells rather than graphical window primitives.
93+
94+
Setupr TUIs share the same terminal-native style: blue uppercase panel titles, thin blue borders, yellow focused borders/actions, green success states, yellow warnings/current work, and red failures. Interactive inputs stay anchored at the bottom of their panel, wrap within the box, and scroll once long input reaches the panel's line cap. `setupr clean` opens a safety review first; type `CLEAN` to delete reviewed targets, or use `--force` only when you intentionally want Setupr to skip the review prompt.
95+
96+
## Help
97+
98+
```bash
99+
setup help
100+
setup help auth
101+
setup auth --help
102+
setup help auth set-key
103+
```
104+
105+
Global help lists every command. Command help shows subcommands, variations, options, and examples for that command.

docs/FEATURES.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Setupr Features
2+
3+
## Smart Detection
4+
5+
Setupr automatically detects:
6+
- **Languages**: TypeScript, JavaScript, Python, Rust, Go, Java, Ruby, PHP, Dart, Elixir, Swift, C#, Kotlin, Scala, and more
7+
- **Frameworks**: Next.js, Nuxt, SvelteKit, React, Vue, Angular, Express, Django, Flask, Rails, Spring Boot, and 20+ more
8+
- **Package Managers**: npm, yarn, pnpm, bun, pip, poetry, cargo, go, bundler, composer, pub, mix
9+
- **Services**: PostgreSQL, MySQL, MongoDB, Redis, RabbitMQ, Elasticsearch, Docker
10+
- **Monorepos**: npm workspaces, pnpm workspaces, Turborepo, Lerna, Nx
11+
12+
### Detection Priority
13+
14+
1. `.setupr.json` config file (explicit, highest priority)
15+
2. `package.json` "setupr" field
16+
3. File-based scanning (lock files, config files)
17+
4. Content analysis (dependency inspection)
18+
5. AI fallback (novel situations only)
19+
20+
## AI-Powered Intelligence
21+
22+
Setupr uses a 3-tier progressive intelligence system:
23+
24+
1. **Pattern Matching** (Level 0) — Free, instant. Handles ~80% of queries
25+
2. **Cached Responses** (Level 1) — Free after first hit. Smart deduplication
26+
3. **Live AI** (Level 2) — Only for novel situations. Uses compressed DSL for minimal token usage
27+
28+
The compressed DSL is internal-only. Setupr compresses docs, scan facts, and parsed user intent before sending context to a model, but generated explanations, docs, code edits, commands, and TUI messages stay in normal human-readable language.
29+
30+
Supports 7 AI providers (25+ models, plus custom GitHub Models catalog IDs):
31+
32+
| Provider | Models | Env Key |
33+
|----------|--------|---------|
34+
| OpenAI | gpt-5.4-pro, gpt-5.4-mini, gpt-4o, gpt-4o-mini | `OPENAI_API_KEY` |
35+
| Anthropic | claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5, claude-3.5-sonnet | `ANTHROPIC_API_KEY` |
36+
| Google | gemini-3.1-pro, gemini-3-flash, gemini-2.5-flash-lite | `GOOGLE_API_KEY` |
37+
| Groq (Llama) | llama-4-maverick, llama-4-scout, llama-3.3-70b | `GROQ_API_KEY` |
38+
| MiniMax | minimax-m2.7, minimax-m2.5-lightning | `MINIMAX_API_KEY` |
39+
| Moonshot (Kimi) | kimi-latest, kimi-k2-thinking, kimi-k2-turbo-preview, kimi-k2.5-vision, moonshot-v1-128k | `MOONSHOT_API_KEY` |
40+
| GitHub Models | openai/gpt-4.1, openai/gpt-4.1-mini, openai/gpt-4o, openai/gpt-4o-mini, or any GitHub catalog ID | `GITHUB_MODELS_API_KEY`, `GITHUB_TOKEN`, or `GITHUB_API_KEY` |
41+
42+
```bash
43+
# Guided setup for provider API keys
44+
setup auth login
45+
46+
# Save one provider API key globally
47+
setup auth set-key github
48+
49+
# View configured providers without printing raw keys
50+
setup auth list
51+
52+
# Test configured providers with tiny requests
53+
setup auth test
54+
55+
# View available models
56+
setup auth models
57+
58+
# Set preferred model
59+
setup auth use openai/gpt-4.1-mini
60+
```
61+
62+
Setupr stores provider API keys globally in `~/.setupr/secrets.json` with file permissions `0600`. Raw keys are never printed.
63+
64+
### AI Director Runtime
65+
66+
Setupr's AI layer is a director runtime, not a one-shot planner:
67+
68+
- Reads bounded project context from README/setup docs, `.env.example`, package scripts, Docker files, CI files, and scanner output
69+
- Compresses setup docs into compact facts before model calls
70+
- Parses user chat into compact intent facts while preserving the exact raw message for AI fallback
71+
- Caches context under `.setupr/cache` so startup stays fast
72+
- Turns failures into structured diagnosis and safe re-planning decisions
73+
- Shows plan diffs when chat steering changes the active plan
74+
- Writes agent workflow checkpoints to `.setupr/agent-workflow.json` so interrupted flows can resume
75+
76+
AI output is not treated as unrestricted shell text. The director proposes structured actions, then Setupr's executor and safety policy decide whether the action is allowed, needs confirmation, or must be blocked.
77+
78+
```bash
79+
setupr chat
80+
setupr chat "how do I start this app?"
81+
setupr chat "what failed last time?"
82+
setupr chat "switch model to moonshot-v1-128k"
83+
setupr chat --new
84+
setupr chat resume
85+
```
86+
87+
## Agent-Guided TUI Flow
88+
89+
The `setup` TUI is an agent workspace, not just a log viewer:
90+
91+
- Before the dashboard opens, Setupr prints a plain-text warning describing what it may do
92+
- Inside the TUI, the main panel shows a time-ordered timeline: system events, AI decisions, user messages, command output, warnings, and confirmations
93+
- When the agent needs input, it pauses with an option card above the persistent chat input
94+
- The AI director can act on natural language while setup is open: change models, fill env values, skip or rewrite plan steps
95+
- `--force` skips safe prompts and uses defaults where possible, but does not invent secrets and still stops for blockers
96+
97+
## Safety Policy
98+
99+
All command-like actions pass through one safety layer. Safe checks and normal dependency installs can run. Medium/high-risk actions require confirmation. Critical actions (root/home wildcard deletion, `curl | sh`, unsafe elevated commands) are blocked. `--force` never bypasses critical safety blockers.
100+
101+
## Environment Management
102+
103+
```bash
104+
setup env # Open interactive .env editor TUI
105+
setup env init # Create .env from .env.example
106+
setup env check # Check for missing variables
107+
setup env sync # Sync structure with .env.example
108+
setup env smart # Smart reorganize + auto-fill
109+
```
110+
111+
## Checkpoint & Resume
112+
113+
- Progress saved to `.setupr/checkpoint.json`
114+
- Agent workflow state saved to `.setupr/agent-workflow.json`
115+
- Setup stops on the first failed step (non-zero exit in plain mode)
116+
- Persists across terminals and reboots
117+
- Automatically cleaned up on success
118+
119+
## Verification And Security
120+
121+
```bash
122+
setupr test quick # Fast local check
123+
setupr test full --report .setupr/test-report.md # Broader check
124+
setupr test doctor # Coverage explanation
125+
setupr security scan # Defensive local scan
126+
setupr security deep --report .setupr/security-report.json
127+
```
128+
129+
## Plugin Development
130+
131+
```bash
132+
setupr plugin create team-tools
133+
setupr plugin validate .
134+
setupr plugin doctor
135+
```
136+
137+
Plugins extend Setupr with commands, scanners, planners, doctor checks, fixers, and TUI panels. Plugin-proposed work still routes through Setupr's safety systems.

0 commit comments

Comments
 (0)