@gluecharm-lab/easyspecs-cli 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  Headless **EasySpecs** command-line tool for **context analysis**, **diagnoses**, **macro pipelines**, **upload to EasySpecs**, **auth**, and **ACE** — the same orchestration logic as the [EasySpecs VS Code extension](https://easyspecs.ai), without an editor.
4
4
 
5
- Published as **`@gluecharm-lab/easyspecs-cli`** (npm org **gluecharm-lab**; **EasySpecs** is the product). The executable on your `PATH` is **`easyspecs-cli`**.
5
+ Published as `**@gluecharm-lab/easyspecs-cli`** (npm org **gluecharm-lab**; **EasySpecs** is the product). The executable on your `PATH` is `**easyspecs-cli`**.
6
6
 
7
7
  ## Requirements
8
8
 
9
9
  - **Node.js** ≥ 18
10
10
  - **[OpenCode](https://opencode.ai)** on `PATH` for flows that run agents
11
- - A **git repository** with **`.gluecharm/`** (documentation + context layout) when running analysis, diagnose, or upload against a project
11
+ - A **git repository** with `**.gluecharm/`** (documentation + context layout) when running analysis, diagnose, or upload against a project
12
12
 
13
13
  ## Install
14
14
 
@@ -40,7 +40,7 @@ easyspecs-cli doctor --inspect-config
40
40
  easyspecs-cli help
41
41
  ```
42
42
 
43
- Use **`config init`** to create **`.easyspecs/config.json`** with defaults (add **`--overwrite`** to replace an existing file). Set **`easyspecs.easyspecsProjectId`** and **`easyspecs.defaultGitRemoteUrl`** from the shell with **`config set-project-id <id>`** and **`config set-git-remote <url>`** (each overwrites that field). Use **`--ci`** for non-interactive CI: no prompts, stricter defaults (e.g. macro outer-iteration cap). Tunables come from **`<repo>/.easyspecs/config.json`**, not ad-hoc environment-variable overrides for product settings.
43
+ Use `**config init**` to create `**.easyspecs/config.json**` with defaults (add `**--overwrite**` to replace an existing file). Set `**easyspecs.easyspecsProjectId**` and `**easyspecs.defaultGitRemoteUrl**` from the shell with `**config set-project-id <id>**` and `**config set-git-remote <url>**` (each overwrites that field). Use `**--ci**` for non-interactive CI: no prompts, stricter defaults (e.g. macro outer-iteration cap). Tunables come from `**<repo>/.easyspecs/config.json**`, not ad-hoc environment-variable overrides for product settings.
44
44
 
45
45
  ```bash
46
46
  easyspecs-cli diagnose coordination-duplicates --cwd /your/repo --ci --json
@@ -48,36 +48,36 @@ easyspecs-cli diagnose coordination-duplicates --cwd /your/repo --ci --json
48
48
 
49
49
  ## Commands (overview)
50
50
 
51
- | Area | Examples |
52
- |------|-----------|
53
- | **Health** | `doctor` (`--readiness`, `--inspect-config`), `version` |
54
- | **Config** | `doctor --inspect-config` (inspect merged settings), `config init`, `config set-project-id`, `config set-git-remote` |
55
- | **Auth** | `auth login --email … --password …`, `auth logout`, `auth status` |
56
- | **Run synthesis** | `run synthesis`; **`run synthesis resume-missing`** / **`resume-synthesis`** |
57
- | **Analysis** (full macro pipeline) | `analysis` (optional **`--upload`** after login; **`--synthesis-only`** stops after synthesis) |
58
- | **Diagnose** | `diagnose reference-coverage`, `coordination-duplicates`, `coverage-report`, … |
59
- | **Upload** | `upload context`, `upload republish` |
60
- | **ACE** | `ace clear`, `ace learn`, `ace auto-learn` |
61
51
 
62
- Run **`easyspecs-cli help`** and **`easyspecs-cli <command> --help`** for the full tree and flags.
52
+ | Area | Examples |
53
+ | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
54
+ | **Health** | `doctor` (`--readiness`, `--inspect-config`), `version` |
55
+ | **Config** | `doctor --inspect-config` (inspect merged settings), `config init`, `config set-project-id`, `config set-git-remote` |
56
+ | **Auth** | `auth login --email … --password …`, `auth logout`, `auth status` |
57
+ | **Run synthesis** | `run synthesis`; `**run synthesis resume-missing`** / `**resume-synthesis**` |
58
+ | **Analysis** (full macro pipeline) | `analysis` (optional `**--upload`** after login; `**--synthesis-only**` stops after synthesis) |
59
+ | **Diagnose** | `diagnose reference-coverage`, `coordination-duplicates`, `coverage-report`, … |
60
+ | **Upload** | `upload context`, `upload republish` |
61
+ | **ACE** | `ace clear`, `ace learn`, `ace auto-learn` |
62
+
63
+
64
+ Run `**easyspecs-cli help`** and `**easyspecs-cli <command> --help**` for the full tree and flags.
63
65
 
64
66
  ## Configuration
65
67
 
66
- Primary configuration file: **`<repo>/.easyspecs/config.json`** (auto-created when needed). See **[`commands.md`](./commands.md)** for flags and merge rules. **`auth login --email … --password …`** stores tokens for upload commands (optional **`--session-path`** tail updates **`easyspecs.cliSessionPath`** in **`config.json`**).
68
+ Primary configuration file: `**<repo>/.easyspecs/config.json**` (auto-created when needed). See `**[commands.md](./commands.md)**` for flags and merge rules. `**auth login --email … --password …**` stores tokens for upload commands (optional `**--session-path**` tail updates `**easyspecs.cliSessionPath**` in `**config.json**`).
67
69
 
68
- After **`auth login`**, session data is stored at **`easyspecs.cliSessionPath`** in **`config.json`** when set (otherwise **`~/.easyspecs/cli-session.json`**). When the VS Code extension delegates with a temp session file, it passes global **`--session-path <file>`** on the spawned **`easyspecs-cli`** process.
70
+ After `**auth login**`, session data is stored at `**easyspecs.cliSessionPath**` in `**config.json**` when set (otherwise `**~/.easyspecs/cli-session.json**`). When the VS Code extension delegates with a temp session file, it passes global `**--session-path <file>**` on the spawned `**easyspecs-cli**` process.
69
71
 
70
72
  ## Global flags
71
73
 
72
- `--cwd`, `--ci`, `--json`, `--verbose`, `--api-base-url`, **`--session-path`**, `--environment`, `--promote` / `--no-promote` (see **`--help`**).
74
+ `--cwd`, `--ci`, `--json`, `--verbose`, `--api-base-url`, `**--session-path**`, `--environment`, `--promote` / `--no-promote` (see `**--help**`).
73
75
 
74
76
  ## Website & documentation
75
77
 
76
78
  - **Product website:** **[easyspecs.ai](https://easyspecs.ai/)** — sign in, projects, documentation in the browser, and product information. This is the public EasySpecs site (not a source-code host).
77
-
78
- - **Command reference** (flags, env, merge rules): [`commands.md`](./commands.md) in this npm package.
79
-
80
- - **CLI:** run **`easyspecs-cli help`** for the full command tree.
79
+ - **Command reference** (flags, env, merge rules): `[commands.md](./commands.md)` in this npm package.
80
+ - **CLI:** run `**easyspecs-cli help`** for the full command tree.
81
81
 
82
82
  Engineering source for this CLI is maintained privately; use **easyspecs.ai** and the docs bundled here for support and usage.
83
83
 
@@ -85,4 +85,133 @@ Engineering source for this CLI is maintained privately; use **easyspecs.ai** an
85
85
 
86
86
  Copyright © **Spaii Edutainment SL** (Barcelona, Spain).
87
87
 
88
- This package is licensed under the **Elastic License 2.0** (**ELv2**, SPDX **`Elastic-2.0`**). See **[`LICENSE`](./LICENSE)** in this package for the full text and [Elastic’s licensing overview](https://www.elastic.co/licensing/elastic-license). Other artifacts in the monorepo may use different licenses.
88
+ This package is licensed under the **Elastic License 2.0** (**ELv2**, SPDX `**Elastic-2.0`**). See `**[LICENSE](./LICENSE)**` in this package for the full text and [Elastic’s licensing overview](https://www.elastic.co/licensing/elastic-license). Other artifacts in the monorepo may use different licenses.
89
+
90
+
91
+
92
+ ```markdown
93
+ # EasySpecs CLI — commands, flags, and configuration
94
+
95
+ Published package: **`@gluecharm-lab/easyspecs-cli`** (`easyspecs-cli`). Source of truth for routing: [`src/cli/main.ts`](../../src/cli/main.ts), argument parsing: [`src/cli/argv.ts`](../../src/cli/argv.ts), merged settings: [`mergeEasyspecsCliSettings`](../../src/cli/cliSettings.ts), per-repo config: [`src/config/easyspecsConfigFile.ts`](../../src/config/easyspecsConfigFile.ts), CLI API URL resolution: [`src/easyspecsApiBaseUrlCli.ts`](../../src/easyspecsApiBaseUrlCli.ts). The VS Code extension resolves API URLs via [`src/apiBaseUrlResolve.ts`](../../src/apiBaseUrlResolve.ts); **`easyspecs-cli` does not use that chain** for System Manager origin (**SRS-43 R30 / R34**).
96
+
97
+ Quick usage:
98
+
99
+ ```bash
100
+ easyspecs-cli help
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Global options
106
+
107
+ These flags may appear **before** the subcommand. Anything after the first non-flag token is treated as the command and its arguments ([`parseArgv`](../../src/cli/argv.ts)).
108
+
109
+ | Flag | Effect |
110
+ |------|--------|
111
+ | `--cwd <dir>` | Repository root for git resolution and file paths (default: current working directory). |
112
+ | `--ci` | Non-interactive mode; feeds into merged settings (e.g. macro outer-iteration default when unlimited). **`EASYSPECS_CI` is not read** — use this flag in CI. |
113
+ | `--json` | On supported exits, prints one JSON summary line on stdout; suppresses some human-oriented stderr unless `--verbose`. |
114
+ | `--verbose` | Extra stderr logging where implemented. |
115
+ | `--api-base-url <url>` | System Manager API origin for this process (overrides `easyspecs.apiBaseUrl` in config). |
116
+ | `--environment production` \| `--environment staging` | Alias: **`--env`**. Overrides `easyspecs.deploymentEnvironment` for built-in URL selection when no explicit URL is set. |
117
+ | `--promote` | After a successful `run synthesis`, copy generated `.gluecharm/context` from the analysis worktree into the workspace repo (when promotion is applicable). |
118
+ | `--no-promote` | Disable that promotion step for this run. |
119
+ | `--help`, `-h` | Show built-in help (also `help` as first positional). Does **not** create `.easyspecs/config.json`. |
120
+ | `--version`, `-V` | Print CLI package version (also `version` as first positional). Does **not** create config. |
121
+ | `--config <path>` | Parsed but **unused** by `main.ts` today; configuration is read from `<repoRoot>/.easyspecs/config.json`. |
122
+
123
+ ---
124
+
125
+ ## Shared configuration (SRS-43)
126
+
127
+ ### File: `<repoRoot>/.easyspecs/config.json`
128
+
129
+ Canonical JSON created on first need (except **`help`**, **`version`**, and **`doctor`** — no auto-create). Invalid JSON fails with a clear path (**R6**). If **`config.json`** is missing and **`.easyspecs/cli.json`** exists, settings are imported once (**§6 M2**) into the new file.
130
+
131
+ Merge uses **this file + global CLI flags only** — no `EASYSPECS_`* / `VITE_*` product overrides on *`*easyspecs-cli`** (**R34**).
132
+
133
+ | Path | Purpose |
134
+ |------|---------|
135
+ | `schemaVersion` | Integer (e.g. `1`) for future migrations. |
136
+ | `easyspecs.deploymentEnvironment` | `production` or `staging` (default `production`). Used with built-in System Manager URLs when `apiBaseUrl` is empty. |
137
+ | `easyspecs.apiBaseUrl` | Explicit System Manager origin; wins after `--api-base-url`. Generated defaults use **`https://api.easyspecs.ai`** (production). Use **`""`** only if you want the built-in URL from **`deploymentEnvironment`** / **`--environment`** instead. |
138
+ | `easyspecs.easyspecsProjectId` | Optional EasySpecs **project** id (Content application UUID). **Only** store for uploads / Sync — set via **`Send context`**, **`Changes → Sync`**, **`config set-project-id`**, or **`easyspecs-cli`**. **`upload`** / **`analysis --upload`** read **only** this field (merged **`easyspecs.applicationId`** legacy key maps here). |
139
+ | `easyspecs.defaultGitRemoteUrl` | Optional primary **`git remote`** URL (HTTPS or SSH) for documentation / tooling; analysis still uses the live repo. Related: **`index-application-context.json`** `repository`, **`.easyspecs/analysis-worktree.json`** `repositoryRoot`. |
140
+ | `easyspecs.cliSessionPath` | Repo-relative or absolute path to **`cli-session.json`** written by **`auth login`**. Empty **`""`** → **`~/.easyspecs/cli-session.json`**. Effective path: global **`--session-path`** (if passed) → **`cliSessionPath`** → default home path ([`cliSession.ts`](../../src/cli/cliSession.ts)). |
141
+ | `easyspecs.openCode` | `executable`, `skipCredentialsCheck` (legacy shortcut; see also `openCodeRuntime`). |
142
+ | `easyspecs.analysis.`* | Pipeline: argv template, timeouts, repair attempts, concurrency, `promoteContextToWorkspace`. |
143
+ | `easyspecs.orchestration.*` | Macro delays, outer iterations, ping-pong cap, etc. |
144
+ | `easyspecs.openCodeRuntime` | Annex-aligned block: `providers` (per-provider `apiKey`, `defaultModel`), `run`, `coordinationRepairs`, `pool`, `projectConfigOverlay` — see [`srs-43-opencode.schema.json`](../../.gluecharm/docs/srs/srs-43-opencode.schema.json). |
145
+
146
+ ### Resolved System Manager URL (`easyspecs-cli`)
147
+
148
+ **Order:** `--api-base-url` → non-empty `easyspecs.apiBaseUrl` → built-in URL from effective environment (*`*--environment`** \|\| **`easyspecs.deploymentEnvironment`** \|\| **`production`**). No `.env` / `process.env` product keys (**R30**).
149
+
150
+ Built-in defaults ship in [`src/easyspecsBuiltInApiUrls.ts`](../../src/easyspecsBuiltInApiUrls.ts).
151
+
152
+ ### Environment variables still used by the CLI
153
+
154
+ | Variable | Purpose |
155
+ |----------|---------|
156
+ | `EASYSPECS_EMAIL` / `EASYSPECS_PASSWORD` | Optional legacy **`auth login`** when **`--ci`** is set and **`--email` / `--password`** are omitted (**SRS-43 §5.3**). Prefer explicit **`--email`** / **`--password`** on the command line for scripts (credentials appear in process listings — avoid shared machines). |
157
+ | `EASYSPECS_EXTENSION_ROOT` | Extension/monorepo root for bundled resources. |
158
+ | `EASYSPECS_CLI_RESOURCES` | Override directory containing **`opencode-agents/`**. |
159
+ | `EASYSPECS_UPLOAD_CONTEXT_DIR` | Upload republish context dir bridging. |
160
+ | `EASYSPECS_CLI_MACRO_DEBUG` | Macro extra logging ([`macroHeadlessHost`](../../src/analysis/macroHeadlessHost.ts)). |
161
+ | OS-level (e.g. `PATH`) | Finding `node`, `opencode`, `git`. |
162
+
163
+ Provider API keys for OpenCode runs should live under **`easyspecs.openCodeRuntime.providers`** in **`config.json`**; they are injected into the **child** OpenCode process (**R13**) and redacted in **`doctor --inspect-config`** (**R17**).
164
+
165
+ ---
166
+
167
+ ## Diagnose-only flags
168
+
169
+ Used after `diagnose <subcommand>`:
170
+
171
+ | Flag | Values | Meaning |
172
+ |------|--------|---------|
173
+ | `--root` | `workspace` or `worktree` | Whether paths resolve against the workspace repo root or an analysis checkout ([`parseTailFlags`](../../src/cli/parseTailFlags.ts)). |
174
+ | `--worktree` | path | Analysis git checkout (required for `--root worktree` when no path embedded in `--root` flow; combined with explicit `--worktree` — see `main.ts`). |
175
+
176
+ ---
177
+
178
+ ## Command reference
179
+
180
+ Each row lists **command-specific CLI tokens**, then **what configuration applies**.
181
+
182
+ | Command | Command-specific flags / tokens | Configuration & notes |
183
+ |---------|--------------------------------|----------------------|
184
+ | `help`, `--help` | — | Global options only; prints usage. |
185
+ | `version` | — | Prints [`PKG_VERSION`](../../src/cli/main.ts) from the bundle. |
186
+ | `doctor` | Optional **`--readiness`**, **`--inspect-config`** | **Does not** create `config.json`. Default (no flags) = **`--readiness`**: repo root, resolved API URL, OpenCode installed/credentials, agents dir. **`--inspect-config`** alone: redacted **`merged`** + **`easyspecsConfig`**. **`--readiness --inspect-config`**: both. Global flags apply (**`--cwd`**, **`--ci`**, **`--api-base-url`**, **`--session-path`**, **`--environment`**, **`--promote`** / **`--no-promote`**). |
187
+ | `config init` | Optional **`--overwrite`** | Creates **`<repo>/.easyspecs/config.json`** with full defaults if missing; imports legacy **`cli.json`** / **`settings.json`** (ACE) when present, same as first-time bootstrap. If the file already exists, does nothing unless **`--overwrite`** (replaces with that bootstrap content). Does not run other commands. |
188
+ | `config set-project-id <id>` | — | Writes **`easyspecs.easyspecsProjectId`** to **`config.json`**, replacing any previous value. Creates **`config.json`** (defaults + legacy import) if missing. |
189
+ | `config set-git-remote <url>` | — | Writes **`easyspecs.defaultGitRemoteUrl`** to **`config.json`**, replacing any previous value. Same bootstrap-if-missing behaviour as **`set-project-id`**. |
190
+ | `auth login` | **`--email <email> --password <password>`**, optional **`--session-path <path>`** (tail; updates **`config.json`**) | Calls **`POST /api/authentication/login`**. On success prints **`OK`** (stdout), exit **0**, and writes tokens + **`apiBaseUrl`** to the session file. Tail **`--session-path`** updates **`easyspecs.cliSessionPath`** in **`config.json`** (normalized repo-relative when under the repo) and writes the session there for this run; omit it to use the existing **`easyspecs.cliSessionPath`** / default **`~/.easyspecs/cli-session.json`**. Global **`--session-path`** (before the command) overrides the effective session file for any command without changing **`config.json`**. On failure prints **`KO: …`** (stderr), exit **`auth`**. Legacy: **`easyspecs-cli --ci auth login`** with **`EASYSPECS_`*** when CLI credentials omitted. **`--password`** on argv is visible to **`ps`**. |
191
+ | `auth logout` | — | Deletes the effective session file (same path rules as **`auth login`**). |
192
+ | `auth status` | — | Reads session file. |
193
+ | `run synthesis` | — | Single SRS-9 context pass (same as extension **Run Analysis**). **`requireOpenCode`** → executable + credentials unless skip flag. Uses **`merged.pipelineOpenCode`** from **`config.json`**. **`--promote` / `--no-promote`** controls promotion after success. |
194
+ | `run synthesis resume-missing`, `run synthesis resume-synthesis` | Optional **`--worktree <path>`** | Same implementation: resolves checkout via `--worktree` or stored snapshot ([`resolveAdHocCheckoutRoot`](../../src/cli/main.ts)). OpenCode + **`merged.pipelineOpenCode`**. |
195
+ | `analysis` | Optional tokens anywhere in argv: **`--synthesis-only`**, **`--upload`** | **SRS-32** full loop: synthesis convergence (until no missing artefacts), then coverage, zero-ref, report, index, optional backend sync. **`merged.macroOrchestration`** from config + **`--ci`** defaults. **`--upload`** requires prior **`auth login`** session. **`EASYSPECS_CLI_MACRO_DEBUG`**. OpenCode options from **`merged.pipelineOpenCode`**. |
196
+ | `diagnose reference-coverage` | **`--root workspace`** \| **`--root worktree`**, optional **`--worktree <path>`** | **`EASYSPECS_MAX_PERCENT_NON_REFERENCED`**: if set to a finite number, failure when metric exceeds it. |
197
+ | `diagnose coordination-duplicates` | Same **`--root`** / **`--worktree`** | **`EASYSPECS_DUPLICATES_STRICT`**: unless `0`, duplicate/orphan issues fail the exit code. |
198
+ | `diagnose coverage-report` | Same **`--root`** / **`--worktree`** | Uses repo/worktree paths only; no extra env in `main.ts`. |
199
+ | `diagnose missing-artefacts` | Same **`--root`** / **`--worktree`** | Reads artefact snapshot from workspace state; no OpenCode. |
200
+ | `diagnose zero-reference` | Optional **`--worktree <path>`** (no `--root` branch in this handler) | **`requireOpenCode`**; **`merged.pipelineOpenCode`** for pool concurrency/argv/timeout. Checkout from **`--worktree`** or snapshot ([`resolveAdHocCheckoutRoot`](../../src/cli/main.ts)). |
201
+ | `upload context` | — | Requires **`auth`** session. Context dir: **`<repoRoot>/.gluecharm/context`**. Project id: **`easyspecs.easyspecsProjectId`** in **`config.json`** only. |
202
+ | `upload republish` | — | Same auth + upload pipeline; context dir from **`EASYSPECS_UPLOAD_CONTEXT_DIR`** if set and valid, else analysis worktree **`…/.gluecharm/context`** from snapshot, else error. Same project id rule as **`upload context`**. |
203
+ | `ace clear` | — | Deletes **`<repoRoot>/.gluecharm/context/learnings`**. |
204
+ | `ace learn` | Optional **`--worktree <path>`** | **`requireOpenCode`**; worktree chosen if `--worktree` points at checkout with **`.opencode/schemas/ace`**, else **`repoRoot`** ([`main.ts`](../../src/cli/main.ts)). **`merged.pipelineOpenCode`** for spawn argv/timeout. |
205
+ | `ace auto-learn` | Optional **`--worktree <path>`** | **`requireOpenCode`**; checkout = `--worktree` if valid git dir, else **`repoRoot`**. **`merged.pipelineOpenCode.maxConcurrentOpenCodeAgents`** caps parallelism. |
206
+
207
+ ---
208
+
209
+ ## Notes
210
+
211
+ - Commands that **spawn OpenCode** call **`requireOpenCode`**: binary must respond (`easyspecs.openCode.executable` / `opencode` on **`PATH`**), and credentials must look ready unless **`easyspecs.openCode.skipCredentialsCheck`**, or provider keys exist in **`config.json`**, or the parent shell already has provider env (probe behaviour in [`opencodeCli`](../../src/opencodeCli.ts)).
212
+ - **`upload`** / **`analysis --upload`** require a prior **`auth login`** session (**`--email`** / **`--password`**, or legacy **`--ci`** + env).
213
+ - Unknown commands print help and exit with a usage error.
214
+ - Git subprocesses may set **`GIT_TERMINAL_PROMPT=0`** on the child environment ([`coverageReferenceValidation`](../../src/analysis/coverageReferenceValidation.ts)).
215
+
216
+ ```
217
+
package/dist/main.cjs CHANGED
@@ -19457,7 +19457,7 @@ function parseAuthLoginTail(tail) {
19457
19457
  }
19458
19458
 
19459
19459
  // src/cli/main.ts
19460
- var PKG_VERSION = "0.0.8";
19460
+ var PKG_VERSION = "0.0.9";
19461
19461
  function logErr(flags, ...a) {
19462
19462
  if (!flags.json) {
19463
19463
  console.error(...a);