@codexa/cli 9.0.4 → 9.0.6

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.
Files changed (3) hide show
  1. package/errors.ts +59 -0
  2. package/package.json +2 -1
  3. package/workflow.ts +11 -10
package/errors.ts ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Codexa error hierarchy.
3
+ * Thrown instead of process.exit() on critical paths.
4
+ * Caught by wrapAction() in workflow.ts which prints the message and exits.
5
+ */
6
+
7
+ export class CodexaError extends Error {
8
+ readonly exitCode: number;
9
+
10
+ constructor(message: string, exitCode: number = 1) {
11
+ super(message);
12
+ this.name = "CodexaError";
13
+ this.exitCode = exitCode;
14
+ }
15
+ }
16
+
17
+ export interface RecoverySuggestion {
18
+ diagnostic: string;
19
+ steps: string[];
20
+ command?: string;
21
+ }
22
+
23
+ export class GateError extends CodexaError {
24
+ readonly gateName: string;
25
+ readonly resolution: string;
26
+ readonly recovery?: RecoverySuggestion;
27
+
28
+ constructor(reason: string, resolution: string, gateName?: string, recovery?: RecoverySuggestion) {
29
+ super(`BLOQUEADO: ${reason}\nResolva: ${resolution}`);
30
+ this.name = "GateError";
31
+ this.gateName = gateName || "";
32
+ this.resolution = resolution;
33
+ this.recovery = recovery;
34
+ }
35
+ }
36
+
37
+ export class ValidationError extends CodexaError {
38
+ constructor(message: string) {
39
+ super(message, 2);
40
+ this.name = "ValidationError";
41
+ }
42
+ }
43
+
44
+ export class TaskStateError extends CodexaError {
45
+ constructor(message: string) {
46
+ super(message, 2);
47
+ this.name = "TaskStateError";
48
+ }
49
+ }
50
+
51
+ export class KnowledgeBlockError extends CodexaError {
52
+ readonly unackedItems: any[];
53
+
54
+ constructor(message: string, unackedItems: any[]) {
55
+ super(message);
56
+ this.name = "KnowledgeBlockError";
57
+ this.unackedItems = unackedItems;
58
+ }
59
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codexa/cli",
3
- "version": "9.0.4",
3
+ "version": "9.0.6",
4
4
  "description": "Orchestrated workflow system for Claude Code - manages feature development through parallel subagents with structured phases, gates, and quality enforcement.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,6 +8,7 @@
8
8
  },
9
9
  "files": [
10
10
  "workflow.ts",
11
+ "errors.ts",
11
12
  "commands/",
12
13
  "db/",
13
14
  "gates/",
package/workflow.ts CHANGED
@@ -48,7 +48,7 @@ import pkg from "./package.json";
48
48
  import { CodexaError, ValidationError, GateError } from "./errors";
49
49
 
50
50
  function checkVersionSync(): void {
51
- // 1. Check CLI vs Plugin (dev repo only)
51
+ // 1. Check CLI vs Plugin (dev repo only — igualdade estrita)
52
52
  try {
53
53
  const gitRoot = execSync("git rev-parse --show-toplevel", { encoding: "utf-8" }).trim();
54
54
  const pluginJson = join(gitRoot, "plugins", "codexa-workflow", ".claude-plugin", "plugin.json");
@@ -62,11 +62,12 @@ function checkVersionSync(): void {
62
62
  );
63
63
  }
64
64
  }
65
- } catch {
65
+ } catch (e) {
66
+ if (e instanceof CodexaError) throw e;
66
67
  // Not in dev repo — skip
67
68
  }
68
69
 
69
- // 2. Check CLI vs project's stored version (client projects)
70
+ // 2. Track CLI version in project DB (informativo, migracoes garantem compatibilidade)
70
71
  try {
71
72
  const dbPath = join(process.cwd(), ".codexa", "db", "workflow.db");
72
73
  if (!existsSync(dbPath)) return;
@@ -77,7 +78,6 @@ function checkVersionSync(): void {
77
78
  if (!project) return;
78
79
 
79
80
  if (!project.cli_version) {
80
- // Projeto existente sem versao gravada (pre-v8.7) — registrar versao atual
81
81
  db.run(
82
82
  `UPDATE project SET cli_version = ? WHERE id = 'default'`,
83
83
  [pkg.version]
@@ -87,12 +87,13 @@ function checkVersionSync(): void {
87
87
  }
88
88
 
89
89
  if (project.cli_version !== pkg.version) {
90
- throw new CodexaError(
91
- `✘ Versao incompativel: CLI=${pkg.version} Projeto=${project.cli_version}\n` +
92
- ` O projeto foi configurado com CLI v${project.cli_version} mas voce esta usando v${pkg.version}.\n` +
93
- ` Opcoes:\n` +
94
- ` 1. Atualize o CLI: bun add -g @codexa/cli@${project.cli_version}\n` +
95
- ` 2. Reconfigure o projeto: codexa discover reset && codexa discover start`
90
+ console.log(
91
+ `ℹ Projeto configurado com CLI v${project.cli_version}, rodando v${pkg.version}. ` +
92
+ `Migracoes aplicadas automaticamente.`
93
+ );
94
+ db.run(
95
+ `UPDATE project SET cli_version = ? WHERE id = 'default'`,
96
+ [pkg.version]
96
97
  );
97
98
  }
98
99
  } catch {