Skip to content

Phase 20f sandbox command policy - #2

Merged
poolanithinreddy merged 8 commits into
mainfrom
phase-20f-sandbox-command-policy
Aug 11, 2026
Merged

Phase 20f sandbox command policy#2
poolanithinreddy merged 8 commits into
mainfrom
phase-20f-sandbox-command-policy

Conversation

@poolanithinreddy

@poolanithinreddy poolanithinreddy commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

Changes

Validation

  • npm run typecheck passes
  • npm run lint passes
  • npm test passes
  • relevant smoke passes (e.g. npm run smoke:dogfood)
  • npm run check:file-size passes

Safety checklist

  • No secrets added (keys via environment variables only)
  • Approval preserved before file writes and shell commands
  • No provider.chat(); provider.stream() only
  • No XML tool directive path; tools go through ToolRegistry
  • Normal-mode output stays clean; debug details still available
  • Docs updated if behavior changed

Make the first five minutes excellent and focus the product on four workflows.

- Demo mode: deterministic, no-key `apeironcode demo` with todo-app, fix-test,
  improve-ui, and review scenarios. Writes real files and runs real local
  validation; never calls a provider, model, Ollama, or the network.
- CLI help: beginner-focused `--help` (fix/build/improve/review/demo/doctor/
  setup), with `help developer` and `help advanced` for the rest. Adds the four
  headline workflow commands. Every existing command stays registered.
- Setup/doctor: intent-based `setup` menu (demo/local/cheap/best/BYO), new
  `local setup`, `local doctor`, `real setup`; doctor appends friendly next
  steps and points to demo when no real provider is configured.
- Providers: local OpenAI-compatible endpoints (localhost/127.0.0.1/0.0.0.0/
  ::1/host.docker.internal/.local) no longer require an API key; remote ones
  still require OPENAI_API_KEY and fail fast cleanly.
- Docs: README four-workflows + no-key demo sections; new docs/demo.md and
  docs/getting-started.md; providers.md documents no-key paths and that mock is
  a test/demo stub, not a real coding model.
Phase 20B: make `apeironcode fix` a real repair loop and harden file-plan parsing.

File plans (Task A/B):
- New robust parser (src/agent/filePlanParser.ts) with multi-strategy extraction
  (direct/fenced/balanced/tolerant-repair/tool-call-envelope), a zod schema
  (filePlanSchema.ts), and shape coercion/repair (filePlanRepair.ts). No single
  strict JSON.parse failure kills the workflow; failures return exact validation
  errors plus a ready-to-send correction prompt. Rejects absolute/.. paths,
  .git, .env (by default), and bad operation/content combinations.
- Legacy parseFilePlanResponse now delegates to the robust parser.

Repair workflow (Tasks C–H) under src/repair/:
- projectDetector / commandDetector / checkRunner: detect package manager,
  framework, scripts; ordered checks (build/e2e gated behind --all); redacted,
  truncated check output.
- errorParser / failureClassifier: structured issues (typecheck, lint, test,
  build, module-not-found, syntax) with file/line and confidence.
- contextBuilder: small, secret-free context packet with a selection trace.
- approvalBundle: one bundled approval with risk level; high-risk commands
  (rm -rf, sudo, curl|sh, npm publish, git push) blocked.
- checkpoint: snapshot before apply, rollback on failed apply (.apeironcode/
  checkpoints, gitignored).
- repairLoop + finalReport + repairPlanner: detect → run → propose minimal plan
  → one correction pass → bundled approval → checkpoint → apply → rerun, up to a
  mode-based limit. Safe/dry-run/all/until-green modes; --commit deferred.

CLI: `apeironcode fix [--dry-run --safe --all --until-green --commit --yes]`
wired via src/cli/fixHandler.ts; dry-run never constructs a provider or writes.

Tests: file-plan parser, detectors, error parser, checkpoint, approval bundle,
repair-loop (injected deterministic deps), and real-node fixtures under
tests/fixtures/repair. Docs: docs/fix-code.md + README/getting-started updates.
Phase 20C: make `apeironcode new` / `apeironcode build` create small apps from
deterministic templates + real validation — no API key or model required.

App builder (src/appBuilder/):
- requestParser: free-text idea → honest AppRequest (name/slug/kind/stack/style/
  features). Auth/db/billing become mock/local UI; Next.js downgrades to Vite.
- templateRegistry + templates: static-todo, static-landing, dashboard-static,
  vite-react. Shared premium design system (tokens, spacing/type scale, focus
  states, responsive, empty states).
- templateRenderer: deterministic render + path safety (no absolute/.., .git,
  .env, no writes outside the app dir).
- designQuality: static checklist (title, viewport, linked assets, button/focus
  states, labeled forms, responsive, no obvious overflow).
- appValidation: files-exist, linked-assets, node --check, design checklist;
  Vite build/typecheck detected and reported as skipped (never auto-installed,
  never faked green).
- appBuilder orchestrator + appReport: parse → select → approval bundle →
  write → validate → honest report. Non-empty dirs require --overwrite and
  existing files are never replaced. --dry-run writes nothing.

CLI: `apeironcode new`/`build [--stack --style --dir --dry-run --overwrite --yes]`
wired via src/cli/appBuilderHandler.ts; both are beginner commands. Approval is
required (auto in bypass/trusted or --yes; non-interactive declines).

Tests: requestParser, templateRegistry/renderer (+path safety), designQuality,
appValidation (broken JS / missing CSS / skipped Vite), orchestrator (create/
dry-run/overwrite-protection/rejection), and docs/packaging honesty.
Docs: new docs/build-apps.md (packaged) + README "Build an app" section.
Phase 20D: generated apps prove they actually render via an optional Playwright
browser smoke. No API key or model required; Playwright is optional and never
fake-passes.

UI smoke (src/uiSmoke/):
- targetDetector: static / Vite / unknown via .apeironcode/app.json metadata,
  index.html, or package.json. staticServer: tiny local file server with
  path-traversal protection.
- SmokePage/BrowserLauncher abstraction so unit tests use a deterministic fake;
  playwrightRunner dynamically imports playwright (no hard dependency) and
  returns null → "skipped" when Chromium is unavailable.
- interactionChecks: template specs (static-todo add-task, dashboard cards/rows,
  landing hero/CTA/nav) + generic checks. uiReport: text/JSON, redacts secrets,
  saves .apeironcode/ui-smoke/{latest.json,latest.png,runs/<ts>/...}.
- runUiSmoke orchestrator: detect → serve → browser → checks/interactions →
  screenshot; honest skip for no-browser / Vite (deps) / unknown targets.

CLI: `apeironcode test-ui [path] [--json --screenshot --port --timeout]`
(src/cli/testUiHandler.ts); exits nonzero only on real failure.

App builder integration: writes .apeironcode/app.json; `new`/`build` gain
--ui-smoke / --no-ui-smoke / --require-ui-smoke. Reports show UI smoke
passed/skipped/failed honestly; --require-ui-smoke fails the build when the
browser is unavailable/fails.

improve: attaches the latest UI smoke report as context (Task F).

Tests: targetDetector, staticServer (traversal), runner (passed/failed/skipped
via mocked launcher), report (redaction/latest.json), interactions, app-builder
integration, improve context, docs/packaging — plus an opt-in real-browser e2e
(APEIRONCODE_RUN_BROWSER_E2E=1 npm run test:ui-smoke). Docs: docs/ui-smoke.md.
Phase 20E: make fix/build/new/test-ui/improve/review feel premium with a shared
progress board, friendlier approvals, diff preview, command log, rollback, and a
beginner root screen — without rewriting the Ink app or breaking non-interactive
mode.

- Progress model (src/progress/): UI-agnostic ProgressRun (tasks/files/commands/
  approvals/artifacts) + ProgressStore + compact plain-text formatter. Symbols
  ✓→○✗–; failure excerpts short in normal mode, full in verbose.
- Approval bundle 2.0 (src/safety/): shared risk classifier (high-risk commands
  never bundled/auto-approved), compact bundle builder with Files-only option,
  and a redacted diff preview (create/modify/delete/rename, binary/huge summary).
- Rollback (src/cli/rollbackHandler.ts + checkpoint list/load): `apeironcode
  rollback list | --last | <id>`, confirmation unless --yes, only touches files
  in the checkpoint, graceful when none exist.
- Review (src/review/): deterministic, provider-free git-diff review
  (bugs/tests/security/maintainability/next steps); routes to the agent for a
  deeper review only when a real provider is configured; no-diff/non-repo handled.
- Root home (src/ui/rootHome.ts): beginner "What do you want to do?" menu shown
  at interactive startup (TTY only; non-interactive unaffected).
- App report surfaces UI smoke screenshot/report paths + a `test-ui` next step.

Tests: progress transitions/formatting, risk/approval/diff, rollback round-trip,
deterministic review heuristics, root menu, docs/packaging. Docs:
docs/terminal-ux.md (packaged) + README. Updated help test for review/rollback.
Phase 20E.5: make the Phase 20E premium UX real in live workflows (not just
helper tests), without rewriting the Ink app or breaking non-interactive mode.

App builder (new/build):
- Approval shows the bundle 2.0 format (compact summary + risk + validation +
  options) plus a redacted diff preview of the files to be created.
- Build report renders a Plan checklist (parse → template → approve → write →
  validate → UI smoke) derived from a real ProgressRun, plus the existing
  completion panel (files/validation/artifacts/next, incl. test-ui).

Fix:
- Repair approval bundle now includes a redacted diff preview (old vs planned
  content) via safety/diffPreview, with [Approve all]/[View diff]/[Reject].
- High-risk commands are still stripped from the applied plan even under --yes.
- After the run, fix prints a completion/failure panel (src/cli/fixProgress.ts +
  progress/completionPanel.ts) with next actions (fix --until-green, rollback
  --last, test-ui) and surfaces the checkpoint.

Shared: new src/progress/completionPanel.ts renders honest Done/Stopped panels.

Tests: app-builder bundle 2.0 + diff + Plan checklist + reject-changes-nothing;
fix repair-bundle diff preview + failure/green completion panels; repair loop
strips high-risk commands under approval. Docs: terminal-ux/fix-code/build-apps
note the live wiring.
@poolanithinreddy
poolanithinreddy merged commit db518db into main Aug 11, 2026
1 of 4 checks passed
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