@gluecharm-lab/easyspecs-cli 0.0.16 → 0.0.18

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/error-code.md ADDED
@@ -0,0 +1,113 @@
1
+ # EasySpecs CLI — error codes
2
+
3
+ Single reference for **process exit codes**, structured **`failureExitId`** subcodes, and how they appear in **`--json`** and stderr. **Normative requirements:** umbrella CLI exit taxonomy **[SRS-39](../../.gluecharm/docs/srs/srs-39.md)** (**R1.3**) is implemented in [`src/cli/exitCodes.ts`](../../src/cli/exitCodes.ts); factory-phase validation ids **[SRS-57](../../.gluecharm/docs/srs/srs-57.md)**; cross-factory structured errors **[SRS-58](../../.gluecharm/docs/srs/srs-58.md)** and **[PLAN-SRS-58](../../.gluecharm/docs/srs/PLAN-SRS-58.md)**.
4
+
5
+ **Maintenance:** When you add a **`failureExitId`** or change **`describeExitCode`**, update this file **in the same change** as [`src/cli/exitCodes.ts`](../../src/cli/exitCodes.ts) and the central registry (**[`failureExitRegistry.ts`](../../src/cli/failureExitRegistry.ts)** when SRS-58 lands). **Do not** change numeric OS exit codes without an SRS amendment (**SRS-39 R1.3**).
6
+
7
+ ---
8
+
9
+ ## 1. Process exit codes (OS / `process.exit`)
10
+
11
+ These are the **only** integers the CLI returns. Everything else (**`5.3`**, **`3.1`**, …) is **metadata** in JSON or stderr, **not** a second process exit status.
12
+
13
+ | Code | Name (internal) | Meaning |
14
+ |:----:|-----------------|--------|
15
+ | **0** | `ok` | Success. |
16
+ | **2** | `usage` | Invalid arguments, unknown subcommand, or help could not be shown as requested. |
17
+ | **3** | `misconfiguration` | Configuration, repo layout, missing prerequisites, or paths that prevent starting work. |
18
+ | **4** | `opencode` | OpenCode (agent runner) failed — install, credentials, or tool run. |
19
+ | **5** | `validation` | Validation or factory pipeline did not succeed (synthesis, coverage, index, drift write, etc.). |
20
+ | **6** | `auth` | Authentication failed or session missing. |
21
+ | **7** | `upload` | Upload or cloud sync failed. |
22
+ | **8** | `cancelled` | Operation cancelled (abort/stop). |
23
+ | **99** | `internal` | Unexpected internal CLI error. |
24
+ | **other** | — | Treated as unknown failure; see stderr and JSON **`error`**. |
25
+
26
+ **Default human line** when **`factoryFailures`** is absent (from **`describeExitCode`** in **`exitCodes.ts`**):
27
+
28
+ | Code | One-line summary |
29
+ |------|------------------|
30
+ | 2 | Invalid arguments, unknown command, or help was not applicable — see message above or run `easyspecs-cli help`. |
31
+ | 3 | Configuration or repo layout problem — fix `.easyspecs/config.json`, paths, or prerequisites, then retry. |
32
+ | 4 | OpenCode (agent runner) failed — check `opencode` install, credentials, and stderr from the tool run. |
33
+ | 5 | Validation or factory pipeline did not succeed — see `error` above and logs for the failing phase. |
34
+ | 6 | Authentication failed or session missing — run `easyspecs-cli auth login` or fix CI credentials in config. |
35
+ | 7 | Upload or cloud sync failed — check network, project id, and session; see `error` above. |
36
+ | 8 | Operation was cancelled (abort/stop). |
37
+ | 99 | Unexpected internal CLI error — retry; if it persists, report with full stderr and `--verbose` output. |
38
+
39
+ When **`factoryFailures`** is present, **`exitMeaning`** in **`--json`** and the primary stderr summary should be driven by **`factoryFailures[0].title`** (per SRS-57 / SRS-58), not only the generic row above.
40
+
41
+ ---
42
+
43
+ ## 2. Structured IDs: `failureExitId`
44
+
45
+ Format: **`{major}.{minor}`** where:
46
+
47
+ - **`major`** = decimal string of the **same** OS exit code used for **`process.exit`** (e.g. **`5`**, **`3`**).
48
+ - **`minor`** = stable integer assigned **per major** in the registry (no reuse for unrelated meanings).
49
+
50
+ **Aliases:**
51
+
52
+ - For **`exitCode === 5`**, **`validationExitId`** (SRS-57) **must** equal **`failureExitId`** on that row.
53
+
54
+ **JSON shape (each element of `factoryFailures`):**
55
+
56
+ | Field | Required | Notes |
57
+ |-------|----------|--------|
58
+ | `factory` | yes | e.g. `generate_context`, `context_drift` |
59
+ | `phase` | yes | Pipeline key within that factory |
60
+ | `exitCode` | yes | Same as top-level exit when single-cause |
61
+ | `failureExitId` | yes | `major.minor` |
62
+ | `title` | yes | Normative one-line explanation |
63
+ | `validationExitId` | when exit 5 | Same as `failureExitId` |
64
+ | `detail` | no | Technical tail |
65
+ | `validationSubcode` | no | Non-localized token (e.g. threshold class) |
66
+
67
+ ---
68
+
69
+ ## 3. `failureExitId` tables by scope
70
+
71
+ ### 3.1 Generate Context factory (`analysis`)
72
+
73
+ **`5.0`–`5.9`** — pipeline phases (synthesis worktree through cloud sync). Full **`phase` ↔ id ↔ title** table: **[SRS-57 §6.1–6.2](../../.gluecharm/docs/srs/srs-57.md)** and [commands.md](./commands.md) (Factory validation reporting).
74
+
75
+ ### 3.2 Context drift factory (`context drift`)
76
+
77
+ Implementation: [`failureExitRegistry.ts`](../../src/cli/failureExitRegistry.ts). **`INVALID_REFERENCE_PATH`** resolves to **`3.1`** or **`3.2`** (bad **`--index`**) using the error text.
78
+
79
+ | Drift `code` | Phase | OS exit | `failureExitId` |
80
+ |--------------|-------|---------|-----------------|
81
+ | `INVALID_REFERENCE_PATH` | `resolve_reference_bundle` or `resolve_reference_root` | 3 | **3.1** / **3.2** |
82
+ | `WORKTREE_PREP_FAILED` | `prepare_analysis_worktree` | 3 | **3.3** |
83
+ | `AGENT_FAILED` | `run_drift_analysis` | 4 | **4.1** |
84
+ | `INVALID_AGENT_PAYLOAD` | `validate_and_render_report` | 4 | **4.2** |
85
+ | `EMPTY_BUNDLE` | `resolve_reference_bundle` | 5 | **5.10** |
86
+ | `UNRESOLVED_REFERENCE_ROOT` | `resolve_reference_root` | 5 | **5.11** |
87
+ | `MANIFEST_FAILED` | `build_comparison_manifest` | 5 | **5.12** |
88
+ | `REPORT_WRITE_FAILED` | `validate_and_render_report` | 5 | **5.13** |
89
+ | `INDEX_PATCH_FAILED` | `update_reference_index` | 5 | **5.14** |
90
+ | `PROMOTE_FAILED` | `promote_drift_artefacts` | 7 | **7.1** |
91
+
92
+ ### 3.3 Other commands
93
+
94
+ Diagnostics, **`context link-graph`**, **`upload`**, etc. may exit **2–7** or **99** without **`factoryFailures`**. Use **§1** and the stderr **`error`** field. Reserved **`5.10`–`5.99`** for non–Generate-Context validation is described in **SRS-57 §6.3** and **SRS-58**.
95
+
96
+ ---
97
+
98
+ ## 4. Related files
99
+
100
+ | File | Role |
101
+ |------|------|
102
+ | [`src/cli/exitCodes.ts`](../../src/cli/exitCodes.ts) | `ExitCode`, `describeExitCode` |
103
+ | [`src/factory/factoryValidationFailures.ts`](../../src/factory/factoryValidationFailures.ts) | Generate Context **`factoryFailures`** build + titles **5.0–5.9** |
104
+ | [`src/cli/jsonReporter.ts`](../../src/cli/jsonReporter.ts) | JSON envelope typing |
105
+ | [commands.md](./commands.md) | Per-command behaviour and flags |
106
+
107
+ ---
108
+
109
+ ## 5. Revision history
110
+
111
+ | Date | Notes |
112
+ |------|--------|
113
+ | 2026-05-06 | Initial **`error-code.md`**: OS codes + **`failureExitId`** rules + pointers; sub-tables to be filled from registry as SRS-58 ships. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gluecharm-lab/easyspecs-cli",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "EasySpecs headless CLI (synthesis, analysis, diagnose, download/upload context, auth, ACE)",
5
5
  "license": "Elastic-2.0",
6
6
  "homepage": "https://easyspecs.ai/",
@@ -17,6 +17,7 @@
17
17
  "LICENSE",
18
18
  "README.md",
19
19
  "commands.md",
20
+ "error-code.md",
20
21
  "dist",
21
22
  "resources"
22
23
  ],