diff --git a/README.md b/README.md index bd431f6..e9e3e67 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ stellarforge test stellarforge deploy ``` -These commands are planned and will become available incrementally through the roadmap. Do not assume a command documented here is implemented until the corresponding release notes state that it is available. +These MVP commands are now implemented in the repository. The package remains under active pre-v1 development and is not yet presented as a stable published npm release. See the [Command Reference](docs/reference/commands.md) for exact behavior. --- @@ -38,7 +38,7 @@ These commands are planned and will become available incrementally through the r ### Project Scaffolding -Planned command: +Implemented command: ```bash stellarforge new my-app @@ -59,7 +59,7 @@ Additional domain templates may be considered after the MVP based on validated d ### Environment Diagnostics -Planned command: +Implemented command: ```bash stellarforge doctor @@ -69,7 +69,7 @@ Diagnostics will check the developer tooling required by supported workflows and ### Local Development -Planned command: +Implemented command: ```bash stellarforge dev @@ -79,7 +79,7 @@ This command will orchestrate supported local-development processes; it will not ### Unified Testing -Planned command: +Implemented command: ```bash stellarforge test @@ -89,7 +89,7 @@ The CLI will provide a consistent entry point for supported project tests while ### Stellar Testnet Deployment -Planned command: +Implemented command: ```bash stellarforge deploy @@ -147,7 +147,7 @@ See [SECURITY.md](SECURITY.md), the [threat model](docs/architecture/threat-mode | `stellarforge --help` | Display CLI usage/help | Planned | | `stellarforge --version` | Display CLI version | Planned | -`stellarforge add`, plugin architecture, and remote template registries are **post-v1 candidates**, not MVP commitments. +`stellarforge add`, plugin architecture, remote template registries, and Mainnet deployment are **not implemented** and remain post-v1 or separately reviewed candidates.\n\nSee [Quick Start](docs/guides/quick-start.md), [Command Reference](docs/reference/commands.md), [Configuration](docs/reference/configuration.md), and [Troubleshooting](docs/reference/troubleshooting.md). --- diff --git a/docs/guides/installation.md b/docs/guides/installation.md index dd3db7a..49051cb 100644 --- a/docs/guides/installation.md +++ b/docs/guides/installation.md @@ -43,9 +43,7 @@ node dist/cli.js The package metadata maps the installed command name `stellarforge` to `dist/cli.js`. When the package is eventually installed or linked through an approved workflow, package managers can expose that executable as `stellarforge`. -At the CLI-002 stage, successful startup intentionally produces no command output. The root command, global help, and invalid-command behavior are implemented separately in CLI-003. - -Do not install undocumented global dependencies. Stellar-specific tools required by individual commands will be documented with those commands and validated by `stellarforge doctor` where applicable. +After building, verify the executable with:\n\n```bash\nnode dist/cli.js --help\nnode dist/cli.js --version\n```\n\nThe implemented command behavior is documented in the [Command Reference](../reference/commands.md).\n\nDo not install undocumented global dependencies. Stellar-specific tools required by individual commands will be documented with those commands and validated by `stellarforge doctor` where applicable. ## Package Publication diff --git a/docs/guides/quick-start.md b/docs/guides/quick-start.md index d87a798..e97eabc 100644 --- a/docs/guides/quick-start.md +++ b/docs/guides/quick-start.md @@ -1,47 +1,87 @@ # Quick Start -This guide describes the intended MVP workflow. Commands may remain unavailable until their implementation issues are merged. +This guide uses the currently implemented StellarForge CLI MVP commands. -## Create a Project +For contributor installation, see [Installation](installation.md). For full options and failure behavior, see the [Command Reference](../reference/commands.md). + +## 1. Create a project + +The default template is `basic-app`: ```bash stellarforge new my-app +cd my-app ``` -Select one supported MVP template: Basic App, Full Stack App, Stellar smart contract, or API Service. +Or choose one of the other bundled templates: + +```bash +stellarforge new my-api --template api-service +stellarforge new my-contract --template smart-contract +stellarforge new my-stack --template full-stack +``` -## Validate Your Environment +Supported template IDs are `basic-app`, `full-stack`, `smart-contract`, and `api-service`. + +## 2. Validate your environment ```bash stellarforge doctor ``` -Diagnostics should identify missing or incompatible developer tools and provide remediation guidance without exposing sensitive environment values. +The command checks the supported local toolchain and prints remediation guidance. A failed required diagnostic exits with code `5`. + +## 3. Run local development -## Develop +From a supported generated Node.js project: ```bash stellarforge dev ``` -The CLI will orchestrate supported local-development processes for generated projects. +StellarForge looks for a supported npm development script: `dev`, then `start`, then `start:backend`. -## Test +## 4. Run tests ```bash stellarforge test ``` -The command should preserve meaningful test failures and exit codes. +Node.js projects use `npm run test`; Cargo projects use `cargo test`. -## Deploy to Testnet +## 5. Configure Testnet deployment + +For a smart-contract project, create `stellarforge.config.json` at the project root: + +```json +{ + "version": 1, + "network": "testnet", + "identity": "deployer" +} +``` + +The identity must already exist in Stellar CLI identity management. Do not place raw secret keys or seed phrases in project configuration. + +See the [Configuration Reference](../reference/configuration.md). + +## 6. Deploy to Testnet ```bash stellarforge deploy ``` -The v1 MVP targets Stellar Testnet. Mainnet deployment automation is explicitly outside the MVP. +Or override configuration explicitly: + +```bash +stellarforge deploy --network testnet --source deployer +``` + +The MVP deployment path is Testnet-only. Mainnet deployment is not implemented. -## Current Status +## Next references -Use the repository README and ROADMAP as the source of truth for which commands are available versus planned. +- [Command Reference](../reference/commands.md) +- [Troubleshooting](../reference/troubleshooting.md) +- [Exit Code Policy](../reference/exit-codes.md) +- [Security Policy](../../SECURITY.md) diff --git a/docs/reference/commands.md b/docs/reference/commands.md index 63bb522..3e2a57e 100644 --- a/docs/reference/commands.md +++ b/docs/reference/commands.md @@ -1,46 +1,241 @@ # Command Reference -This reference tracks the v1.0 MVP command surface. +This reference documents the implemented StellarForge CLI MVP command surface. -| Command | Purpose | MVP Status | -|---|---|---| -| `stellarforge --help` | Show global usage/help | Implemented | -| `stellarforge --version` | Show installed CLI version | Implemented | -| `stellarforge new ` | Scaffold a supported Stellar project | Implemented | -| `stellarforge doctor` | Validate the development environment | Implemented | -| `stellarforge dev` | Orchestrate local development | Implemented | -| `stellarforge test` | Run supported tests | Implemented | -| `stellarforge deploy --network testnet --source ` | Deploy a supported smart contract to Stellar Testnet | Implemented | +## Command status -## Root Command +| Command | Purpose | Status | +| --- | --- | --- | +| `stellarforge --help` | Show root usage and available commands | Implemented | +| `stellarforge --version` | Show the installed CLI package version | Implemented | +| `stellarforge new ` | Generate a supported StellarForge project | Implemented | +| `stellarforge doctor` | Validate the local development toolchain | Implemented | +| `stellarforge dev` | Start a supported generated Node.js project | Implemented | +| `stellarforge test` | Run a supported project test workflow | Implemented | +| `stellarforge deploy` | Deploy a supported smart-contract project to Stellar Testnet | Implemented | +| `stellarforge add` | Add modules/plugins | Not implemented / post-v1 candidate | -The root command is `stellarforge`. It provides global help, installed-package version output, deterministic parser errors, and the implemented MVP product commands. +See also [Installation](../guides/installation.md), [Quick Start](../guides/quick-start.md), [Configuration](configuration.md), [Exit Codes](exit-codes.md), [Troubleshooting](troubleshooting.md), and the repository [security guidance](../../SECURITY.md). + +## Global command behavior + +### Help ```bash stellarforge --help +stellarforge new --help +``` + +Help exits successfully with code `0`. + +### Version + +```bash stellarforge --version ``` -`stellarforge --version` reads the version from the installed package metadata. It does not contact a package registry, run a subprocess, or maintain a second hard-coded version constant. +The version comes from installed package metadata. No registry request or subprocess is used. + +Unknown commands, unknown options, and missing required positional arguments are usage failures and exit with code `2`. + +## `stellarforge new ` + +Creates a new project from a bundled, project-controlled template. + +### Usage + +```bash +stellarforge new [options] +``` + +### Options + +| Option | Meaning | +| --- | --- | +| `-t, --template ` | Select a bundled template. | -Unknown options or positional commands fail with a non-zero exit code and include root usage information. `stellarforge add` is not part of the v1.0 MVP. +Supported template IDs are: -## Deploy +- `basic-app` — default when `--template` is omitted; +- `full-stack`; +- `smart-contract`; +- `api-service`. -MVP deployment is intentionally restricted to generated Stellar smart-contract Cargo workspaces and Stellar Testnet. +### Examples + +```bash +stellarforge new my-app +stellarforge new payments-api --template api-service +stellarforge new escrow-contract -t smart-contract +``` + +Generation validates project names and destinations before writing. Existing non-empty destinations are not overwritten. Templates come only from the bundled template registry; arbitrary URLs, filesystem template paths, or executable template code are not accepted. + +See [Template Generation Safety](template-generation.md). + +### Common failures + +- invalid or missing project name; +- unsupported template ID; +- destination traversal or invalid destination; +- existing non-empty destination; +- invalid bundled template content. + +These are validation failures and exit with code `2`. + +## `stellarforge doctor` + +Runs the registered development-environment diagnostics. + +### Usage + +```bash +stellarforge doctor +``` + +The current diagnostic set checks the supported Node.js/npm runtime and relevant local development tools, including Git, Rust, Cargo, Stellar CLI, and Docker. + +The report renders each result, remediation guidance when available, a summary, and an overall health result. + +### Exit behavior + +- `0` — no required diagnostic failed; +- `5` — one or more required diagnostics failed. + +Warnings do not by themselves make the command fail. + +The command does not print complete sensitive environment values. + +## `stellarforge dev` + +Starts the supported local-development workflow for a generated Node.js StellarForge project. + +### Usage + +```bash +cd my-project +stellarforge dev +``` + +The command requires a valid project `package.json` with a `scripts` object. Script selection uses the first supported entry in this order: + +1. `dev`; +2. `start`; +3. `start:backend`. + +StellarForge invokes npm as an executable with an argument array; it does not execute the package script text through a constructed shell command. + +Child stdout/stderr are streamed with process labels. + +### Common failures + +- no `package.json`; +- invalid JSON; +- missing `scripts` object; +- no supported development script; +- child process startup or runtime failure. + +Validation failures use code `2`; failed child processes use code `3`. + +## `stellarforge test` + +Runs the supported project test workflow. + +### Usage + +```bash +cd my-project +stellarforge test +``` + +Supported project forms are: + +- Node.js project with a `package.json` `test` script → `npm run test`; +- Cargo workspace/project with `Cargo.toml` → `cargo test`. + +When both are present, the Node.js project test workflow is selected first. + +StellarForge does not execute package script text directly. It delegates through npm or Cargo and preserves external-process failures. + +### Exit behavior + +- `0` — test workflow completed successfully; +- `2` — project/test configuration is unsupported or invalid; +- `3` — the test subprocess fails. + +## `stellarforge deploy` + +Deploys a supported smart-contract Cargo project to **Stellar Testnet**. + +### Usage + +Using explicit CLI options: ```bash stellarforge deploy --network testnet --source deployer ``` -The network value must be written explicitly as `testnet`; Mainnet, Futurenet, local networks, and implicit defaults are not accepted. The source must be the name of a Stellar CLI identity already configured by the developer. StellarForge does not accept raw secret keys, seed phrases, public keys, or path-like source values for deployment. +Using project configuration: + +```json +{ + "version": 1, + "network": "testnet", + "identity": "deployer" +} +``` + +```bash +stellarforge deploy +``` + +CLI values override corresponding values from `stellarforge.config.json`: + +```bash +stellarforge deploy --source release-deployer +``` + +### Options -The command invokes Stellar CLI using an executable and argument array equivalent to: +| Option | Meaning | +| --- | --- | +| `--network ` | Explicit deployment network. CLI value overrides project configuration. | +| `--source ` | Named Stellar CLI identity alias. CLI value overrides project configuration. | + +The effective network and identity must both be present after configuration resolution. + +The MVP deployment command accepts only the exact network value `testnet`. A project config value of `mainnet` or `futurenet` is valid schema data for future command use, but it is rejected by the deploy command. + +The source must be a named Stellar CLI identity. Raw secret keys, seed phrases, account/public StrKeys, and path-like values are rejected. + +The invoked external command is equivalent to: ```text stellar contract deploy --source-account deployer --network testnet ``` -No shell interpolation is used. Deployment output is streamed to the terminal. A failed Stellar CLI process produces a non-zero StellarForge subprocess result. Signing material remains under Stellar CLI identity management and must never be committed to the project or passed as a raw StellarForge argument. +No shell interpolation is used. Signing material remains under Stellar CLI identity management. + +### Exit behavior + +- `0` — deployment subprocess completes successfully; +- `2` — configuration, project layout, network, or identity input is invalid; +- `3` — Stellar CLI fails to start or returns a failure. + +See [Configuration](configuration.md) and [Troubleshooting](troubleshooting.md). + +## Unsupported or planned behavior + +The following are not part of the implemented MVP command surface: + +- Mainnet deployment; +- Futurenet or local-network deployment through `stellarforge deploy`; +- `stellarforge add`; +- plugin execution; +- remote template registries; +- arbitrary/executable project configuration; +- raw-key deployment arguments; +- automatic fallback to Mainnet; +- arbitrary custom deployment commands. -Each implemented command should document arguments/options, examples, exit behavior, security-sensitive behavior, and configuration requirements here or in a dedicated reference page. +Do not rely on roadmap items as available behavior until their implementation is merged and documented. diff --git a/docs/reference/troubleshooting.md b/docs/reference/troubleshooting.md new file mode 100644 index 0000000..3905316 --- /dev/null +++ b/docs/reference/troubleshooting.md @@ -0,0 +1,166 @@ +# Troubleshooting + +This page covers common failures in the implemented StellarForge CLI MVP. + +For numeric failure categories, see [Exit Codes](exit-codes.md). + +## Command or option is not recognized + +Run: + +```bash +stellarforge --help +stellarforge --help +``` + +Unknown commands/options and missing required positional arguments are usage failures and exit with code `2`. + +`stellarforge add`, plugin commands, and remote-template commands are not implemented in the MVP. + +## `stellarforge new` cannot create the project + +Check: + +- the project name is present and valid; +- the requested template is one of `basic-app`, `full-stack`, `smart-contract`, or `api-service`; +- the destination is within the allowed working path; +- the target directory is not an existing non-empty directory. + +StellarForge intentionally refuses unsafe paths, unsupported templates, symlinked template entries, and implicit overwrite behavior. + +## `stellarforge doctor` reports failures + +Read the remediation line printed under each failed diagnostic. + +The current diagnostics cover the Node.js/npm runtime and local tools used by supported workflows, including Git, Rust, Cargo, Stellar CLI, and Docker. + +A diagnostic failure exits with code `5`. A warning may indicate a usable but incomplete environment and does not by itself fail the command. + +## `stellarforge dev` says no supported script exists + +The project must contain a valid `package.json` with a `scripts` object and at least one of: + +```text +dev +start +start:backend +``` + +Selection follows that order. + +If the selected npm process starts and then fails, StellarForge returns subprocess exit category `3`. + +## `stellarforge test` cannot find a workflow + +A supported test project must have either: + +- `package.json` with a string `scripts.test` entry; or +- `Cargo.toml`. + +Node.js projects are run through `npm run test`; Cargo projects are run through `cargo test`. + +A failing project test is preserved as a subprocess failure instead of being converted to success. + +## Configuration file is rejected + +The file must be named exactly: + +```text +stellarforge.config.json +``` + +and live at the project root. + +It must be a regular non-symlink file, no larger than 64 KiB, and contain valid JSON with schema version `1`. + +Supported fields are only: + +- `version`; +- `network`; +- `identity`. + +Secret-bearing fields such as private keys, seed phrases, tokens, passwords, or mnemonic data are intentionally rejected. Validation messages do not echo secret values. + +See [Configuration](configuration.md). + +## Deployment network is required + +Provide either project configuration: + +```json +{ + "version": 1, + "network": "testnet", + "identity": "deployer" +} +``` + +or CLI options: + +```bash +stellarforge deploy --network testnet --source deployer +``` + +There is no implicit network default. + +## Deployment rejects Mainnet or Futurenet + +This is expected. The MVP deploy command is deliberately Testnet-only. + +Even though the configuration schema recognizes `mainnet` and `futurenet` as explicit network values, deployment rejects them. Mainnet deployment requires separate architecture and security work. + +## Deployment identity is rejected + +Use the **name** of a Stellar CLI identity, for example: + +```bash +stellarforge deploy --network testnet --source deployer +``` + +Do not pass: + +- a raw `S...` secret StrKey; +- a `G...` public/account StrKey; +- a seed phrase; +- a filesystem path; +- an option-like value beginning with `-`. + +StellarForge delegates signing to Stellar CLI identity management. + +## Stellar CLI deployment fails + +First run: + +```bash +stellarforge doctor +``` + +Then verify that: + +- Stellar CLI is installed and usable; +- the named identity exists in Stellar CLI; +- the project contains `Cargo.toml`; +- the selected network is `testnet`; +- the local environment can reach the required Stellar Testnet services. + +A failed external process returns exit category `3`. + +## Sensitive information appeared in a failure + +StellarForge errors are designed not to render raw secrets. Do not paste private keys, seed phrases, access tokens, or complete credential-bearing environment values into public issues. + +If you believe a secret disclosure is caused by a vulnerability, follow [SECURITY.md](../../SECURITY.md) instead of opening a public issue. + +## Still blocked? + +Collect only non-sensitive information: + +- StellarForge CLI version; +- command name and sanitized arguments; +- exit code; +- operating system; +- relevant tool versions; +- the safe error message; +- minimal project layout information. + +Do not include secrets, full environment dumps, wallet seed material, or private signing keys.