agents init --yes does not reset an already-initialized environment — undocumented --force flag required #9744

Open
opened 2026-04-15 08:33:00 +00:00 by hurui200320 · 4 comments
Member

Metadata

  • Commit Message: fix(cli): make agents init --yes reset existing environment without requiring --force
  • Branch: fix/init-yes-reset-existing-env

Background

The spec defines agents init as:

"Initialize or reset the global CleverAgents environment. This wipes any existing data and re-creates the global config and database."

The --yes flag is the standard non-interactive confirmation for this destructive reset — consistent with common CLI conventions where --yes means "I know this is destructive, proceed." No second flag should be required.

However, when a config file already exists (the environment has been initialized before), agents init --yes errors out instead of wiping and reinitializing. A separate undocumented --force flag is needed to actually perform the reset, making the two-flag combination (--yes --force) the only functional path — and neither flag's documentation nor the spec mentions this requirement.


Current Behavior

Given an already-initialized environment (config present at e.g. /app/.cleveragents/config.toml):

agents init --yes

Actual output:

Error [422] VALIDATION_FAILED: Project already initialized at /app
  path: /app
  use_force: Add --force to reinitialize

Exit code: 1

The --force workaround:

agents init --yes --force
# Works — wipes and reinitializes

How to Reproduce

# Step 1 — initialize for the first time (or ensure config already exists)
agents init --yes --force

# Step 2 — attempt to reset with just --yes
agents init --yes
# Expected: clean reset; output shows Schema: v3, Tables: N created, backup path
# Actual:   Error [422] VALIDATION_FAILED: Project already initialized at /app
#           Exit code: 1

Expected Behavior

agents init --yes should perform the full reset without requiring any additional flags, producing output matching the spec:

Environment Reset
  Config: /home/devuser/.cleveragents/config.toml
  Database: /home/devuser/.cleveragents/cleveragents.db
  Backup: /home/devuser/.cleveragents.backup-YYYY-MM-DD
  Status: ready

Schema
  Version: v3
  Tables: N created
  Migrations: up to date

[OK] Environment initialized

Exit code: 0.


Acceptance Criteria

  • agents init --yes exits 0 on an already-initialized environment and performs the full wipe + reinit
  • Existing data directory, config, and database are wiped and recreated
  • A backup of the previous state is created and its path is reported in the output
  • Output includes Schema version, table count, and backup path as specified
  • agents init (no flags) continues to prompt interactively for confirmation
  • No regression: a fresh (never-initialized) environment still works with agents init --yes

Supporting Information

  • Discovered during test plan rune-actor.md, Call 4 (2026-04-15)
  • The CLI error hint itself acknowledges the workaround: use_force: Add --force to reinitialize, confirming --force exists but is undocumented
  • Related issues (different symptoms, same command): #783 (closed — established --yes for fresh init), #4098 (migration noise on stdout), #5752 (--force/-f flag conflict with --format/-f)

Subtasks

  • Locate the init command handler and identify where the 422 "already initialized" guard is raised
  • Update the guard: when --yes is passed, bypass the "already initialized" check and proceed with the wipe
  • Implement backup-before-wipe: snapshot the existing data dir to a timestamped backup path before deleting
  • Update output to match spec format: Environment Reset, Schema, backup path sections
  • Tests (Behave): scenario — agents init --yes on an existing environment wipes and reinitializes successfully
  • Tests (Behave): scenario — agents init --yes on a fresh environment initializes successfully (regression)
  • Tests (Robot): integration test covering the full init → wipe → reinit lifecycle
  • Verify coverage ≥ 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional implementation details.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
## Metadata - **Commit Message**: `fix(cli): make agents init --yes reset existing environment without requiring --force` - **Branch**: `fix/init-yes-reset-existing-env` --- ## Background The spec defines `agents init` as: > "Initialize or **reset** the global CleverAgents environment. This wipes any existing data and re-creates the global config and database." The `--yes` flag is the standard non-interactive confirmation for this destructive reset — consistent with common CLI conventions where `--yes` means "I know this is destructive, proceed." No second flag should be required. However, when a config file already exists (the environment has been initialized before), `agents init --yes` **errors out** instead of wiping and reinitializing. A separate undocumented `--force` flag is needed to actually perform the reset, making the two-flag combination (`--yes --force`) the only functional path — and neither flag's documentation nor the spec mentions this requirement. --- ## Current Behavior Given an already-initialized environment (config present at e.g. `/app/.cleveragents/config.toml`): ```bash agents init --yes ``` **Actual output:** ``` Error [422] VALIDATION_FAILED: Project already initialized at /app path: /app use_force: Add --force to reinitialize ``` **Exit code:** 1 The `--force` workaround: ```bash agents init --yes --force # Works — wipes and reinitializes ``` --- ## How to Reproduce ```bash # Step 1 — initialize for the first time (or ensure config already exists) agents init --yes --force # Step 2 — attempt to reset with just --yes agents init --yes # Expected: clean reset; output shows Schema: v3, Tables: N created, backup path # Actual: Error [422] VALIDATION_FAILED: Project already initialized at /app # Exit code: 1 ``` --- ## Expected Behavior `agents init --yes` should perform the full reset without requiring any additional flags, producing output matching the spec: ``` Environment Reset Config: /home/devuser/.cleveragents/config.toml Database: /home/devuser/.cleveragents/cleveragents.db Backup: /home/devuser/.cleveragents.backup-YYYY-MM-DD Status: ready Schema Version: v3 Tables: N created Migrations: up to date [OK] Environment initialized ``` Exit code: 0. --- ## Acceptance Criteria - [ ] `agents init --yes` exits 0 on an already-initialized environment and performs the full wipe + reinit - [ ] Existing data directory, config, and database are wiped and recreated - [ ] A backup of the previous state is created and its path is reported in the output - [ ] Output includes Schema version, table count, and backup path as specified - [ ] `agents init` (no flags) continues to prompt interactively for confirmation - [ ] No regression: a fresh (never-initialized) environment still works with `agents init --yes` --- ## Supporting Information - Discovered during test plan `rune-actor.md`, Call 4 (2026-04-15) - The CLI error hint itself acknowledges the workaround: `use_force: Add --force to reinitialize`, confirming `--force` exists but is undocumented - Related issues (different symptoms, same command): #783 (closed — established `--yes` for fresh init), #4098 (migration noise on stdout), #5752 (`--force/-f` flag conflict with `--format/-f`) --- ## Subtasks - [ ] Locate the `init` command handler and identify where the 422 "already initialized" guard is raised - [ ] Update the guard: when `--yes` is passed, bypass the "already initialized" check and proceed with the wipe - [ ] Implement backup-before-wipe: snapshot the existing data dir to a timestamped backup path before deleting - [ ] Update output to match spec format: Environment Reset, Schema, backup path sections - [ ] Tests (Behave): scenario — `agents init --yes` on an existing environment wipes and reinitializes successfully - [ ] Tests (Behave): scenario — `agents init --yes` on a fresh environment initializes successfully (regression) - [ ] Tests (Robot): integration test covering the full init → wipe → reinit lifecycle - [ ] Verify coverage ≥ 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors --- ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional implementation details. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done.
Owner

Thank you for this detailed bug report, @hurui200320.

This is a clear spec compliance issue: agents init --yes should perform the full reset without requiring --force. The undocumented flag requirement is a usability problem and a spec violation.

Triage Assessment:

  • Priority: High (confirmed — spec violation affecting core workflow)
  • Type: Bug (confirmed)
  • Milestone: Needs assignment (likely v3.2.0 or v3.3.0 based on CLI scope)

This issue has been received and will be picked up by the implementation team. The well-structured report with reproduction steps, acceptance criteria, and subtasks will help expedite resolution.

Next Steps: This issue will be moved to State/Verified and assigned to a milestone by the grooming team. Implementation will follow standard workflow.


Automated by CleverAgents Bot
Supervisor: Human Liaison | Agent: human-liaison-pool-supervisor

Thank you for this detailed bug report, @hurui200320. This is a clear spec compliance issue: `agents init --yes` should perform the full reset without requiring `--force`. The undocumented flag requirement is a usability problem and a spec violation. **Triage Assessment**: - Priority: High (confirmed — spec violation affecting core workflow) - Type: Bug (confirmed) - Milestone: Needs assignment (likely v3.2.0 or v3.3.0 based on CLI scope) This issue has been received and will be picked up by the implementation team. The well-structured report with reproduction steps, acceptance criteria, and subtasks will help expedite resolution. **Next Steps**: This issue will be moved to `State/Verified` and assigned to a milestone by the grooming team. Implementation will follow standard workflow. --- **Automated by CleverAgents Bot** Supervisor: Human Liaison | Agent: human-liaison-pool-supervisor
Owner

🏷️ Triage Decision — [AUTO-OWNR-1]\n\nStatus: Verified\n\nIssue Type: Bug \nMoSCoW: Should Have — Important UX fix for init workflow \nPriority: High (already set)\n\nRationale: agents init --yes should reset an existing environment without requiring --force. This is a spec-required behavior that's currently broken. It's a Should Have because it affects the developer onboarding experience and could cause confusion, but it doesn't block core plan execution.\n\nLabels to apply: State/Verified, MoSCoW/Should have, Priority/High, Type/Bug\n\n---\nAutomated by CleverAgents Bot\nSupervisor: Project Owner | Agent: project-owner-pool-supervisor

## 🏷️ Triage Decision — [AUTO-OWNR-1]\n\n**Status:** ✅ Verified\n\n**Issue Type:** Bug \n**MoSCoW:** Should Have — Important UX fix for init workflow \n**Priority:** High (already set)\n\n**Rationale:** `agents init --yes` should reset an existing environment without requiring `--force`. This is a spec-required behavior that's currently broken. It's a Should Have because it affects the developer onboarding experience and could cause confusion, but it doesn't block core plan execution.\n\n**Labels to apply:** State/Verified, MoSCoW/Should have, Priority/High, Type/Bug\n\n---\n**Automated by CleverAgents Bot**\nSupervisor: Project Owner | Agent: project-owner-pool-supervisor
Owner

[AUTO-OWNR-1] Triage complete.

Verified — Valid spec compliance bug. agents init --yes should reset an existing environment per the spec, but instead errors out requiring an undocumented --force flag.

  • Type: Bug
  • Priority: High — breaks the documented --yes flag behavior
  • MoSCoW: Must Have — spec compliance for core CLI commands
  • Milestone: v3.2.0 — CLI spec compliance

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor


Automated by CleverAgents Bot
Agent: automation-tracking-manager

[AUTO-OWNR-1] Triage complete. **Verified** ✅ — Valid spec compliance bug. `agents init --yes` should reset an existing environment per the spec, but instead errors out requiring an undocumented `--force` flag. - **Type**: Bug - **Priority**: High — breaks the documented `--yes` flag behavior - **MoSCoW**: Must Have — spec compliance for core CLI commands - **Milestone**: v3.2.0 — CLI spec compliance --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor --- **Automated by CleverAgents Bot** Agent: automation-tracking-manager
Owner

Triage Decision [AUTO-OWNR]

Status: Verified

Type: Bug
Priority: High
MoSCoW: Should Have
Milestone: v3.2.0

Rationale: The agents init --yes command silently fails to reset an already-initialized environment, requiring an undocumented --force flag. This is a usability bug that affects developer experience. Should Have because while it's a real bug, it doesn't block core functionality — users can work around it with --force.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

## Triage Decision [AUTO-OWNR] **Status**: ✅ Verified **Type**: Bug **Priority**: High **MoSCoW**: Should Have **Milestone**: v3.2.0 **Rationale**: The `agents init --yes` command silently fails to reset an already-initialized environment, requiring an undocumented `--force` flag. This is a usability bug that affects developer experience. Should Have because while it's a real bug, it doesn't block core functionality — users can work around it with `--force`. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
HAL9000 added this to the v3.2.0 milestone 2026-04-16 09:04:48 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#9744
No description provided.