/** * init command — scaffold the project layout. * * Registry-driven (ADR-0038): `init` scaffolds one directory tree per REGISTERED * tool, never a hardcoded fit/sim pair. Each tool owns its own example bytes + * config block; the host owns only the directory layout (`pluginLayout`), the * document header, and `targets:`. With the bundled fitness + simulation tools * registered, a TypeScript project gets: * /opensip-cli.config.yml (TRACKED) * /opensip-cli/fit/{checks,recipes}/example-*.mjs (TRACKED) * /opensip-cli/sim/{scenarios,recipes}/example-*.mjs (TRACKED) * A tool with no `pluginLayout` (e.g. `graph`) contributes no directory. * * Consequence — the scaffolded set equals the REGISTERED set: * - A tool installed AFTER `init` scaffolds on the next `init --keep`. * - Back-compat behavior shift: if a bundled tool fails to load, init * now scaffolds FEWER dirs (vs the old always-fit/sim). A bundled tool * that's expected but absent is surfaced loudly via the * `cli.tool.expected_bundled_absent` diagnostic (bootstrap) so a silent * under-scaffold is observable; a genuinely uninstalled third-party * tool stays silent (correct). * * Appends `opensip-cli/.runtime/` to /.gitignore so the * tool-generated state (sessions, logs, dashboards, baselines, plugin * installs) stays untracked. * * Promotion path: when a customer's pack outgrows a handful of .mjs * files (shared helpers, tests, more than a dozen checks/scenarios), * `opensip-cli//` can graduate to a real workspace npm * package — fit packs declare the `fit-pack` marker plus target-domain epoch; * sim packs use the `scenarios-*` package-name pattern. Add `tsconfig.json` and * an `index.ts` re-exporting checks/recipes or scenarios/recipes. Marker-based * discovery picks up a fit workspace package automatically regardless of npm * scope. The init scaffold stays loose-`.mjs` to * preserve the fast first-touch experience; graduation is a manual * step the customer takes when their coverage becomes substantial. * See docs/public/50-extend/01-plugin-authoring.md. * * Language selection drives: * - which `targets:` entry shape goes into the YAML config * - the `scope.languages` field on the example check * * `--language ` (comma-separated or repeatable) overrides detection. * Detection inspects filesystem markers (Cargo.toml, pyproject.toml, * go.mod, pom.xml/build.gradle, CMakeLists.txt, package.json+tsconfig) * and accepts every detected language in host-canonical order (polyglot * is not an error). When no markers are found and --language is missing, * or when --language is empty/unknown, init exits 2 with a helpful prompt * — no partial scaffolding. * * Partial-state handling: * * After language resolution, init classifies the working directory * into one of four states based on the presence of the config file * and the `opensip-cli/` directory: * * - 'pristine' — neither present; scaffold everything. * - 'fully-initialized' — both present; refresh guidance without a flag. * - 'partial-config-only' — config only; refresh guidance without a flag. * - 'partial-dir-only' — config XOR dir; refuse without a flag. * * Two flags express explicit user intent for the non-pristine states: * * - `--keep` — re-scaffold examples; preserve existing config and custom files. * - `--remove` — delete `opensip-cli/` entirely; scaffold fresh. * * The two flags are mutually exclusive. The legacy `--force` flag is * gone; users who scripted it should migrate to `--remove`, the * closest semantic match. * * Implementation is split across `./init/` siblings: * - language-detection.ts — marker scanning + `--language` parsing * - config-templates.ts — host-owned YAML document skeleton (header + * targets); per-tool config blocks come from * each tool's `scaffoldConfigBlock()` * - file-classifier.ts — scaffolded / stale / custom tagging * - state-machine.ts — working-dir state + refusal messages * - scaffold-writer.ts — disk writes, gitignore patching, refresh mode * * This file is the orchestrator: argument validation → language * resolution → state classification → file classification → scaffold * (or refuse). */ import { type ProjectContext } from '@opensip-cli/core'; import type { RuntimePromotionRecoveryDependencies } from './init/runtime-promotion-recovery.js'; import type { RuntimePromotionDependencies } from './init/runtime-promotion.js'; import type { ToolScaffold } from './shared.js'; import type { InitOptions, InitResult } from '@opensip-cli/contracts'; import type { DataStoreLockContext } from '@opensip-cli/datastore'; interface ExecuteInitBaseArgs extends InitOptions { projectContext?: ProjectContext; cwdExplicit?: boolean; datastoreLockContext: DataStoreLockContext; } type ExecuteInitArgs = ExecuteInitBaseArgs & { toolScaffolds: readonly ToolScaffold[]; }; /** * Run init for the given args. Returns an InitResult — the caller * (CLI render layer) prints it. */ export declare function executeInit(args: ExecuteInitArgs, dependencyOverrides?: Partial): Promise; /** * Recovery-only Init entry used before Tool discovery. It can never fall back * to a fresh operation if the fixed journal disappears between probe and * action. */ export declare function executeInitRecovery(args: ExecuteInitBaseArgs, dependencyOverrides?: Partial): Promise; export {}; //# sourceMappingURL=init.d.ts.map