@codexa/cli 9.0.36 → 9.0.38

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.
@@ -79,7 +79,7 @@ export async function discoverStart(json: boolean = false): Promise<void> {
79
79
  await initSchema();
80
80
 
81
81
  // Verificar se ja foi descoberto
82
- const existing = await dbGet("SELECT * FROM project WHERE id = 'default'", ["default"]);
82
+ const existing = await dbGet("SELECT * FROM project WHERE id = ?", ["default"]);
83
83
  if (existing) {
84
84
  console.log("\nProjeto ja foi descoberto.");
85
85
  console.log("Use: discover show para ver detalhes");
@@ -170,7 +170,7 @@ export async function discoverStart(json: boolean = false): Promise<void> {
170
170
  export async function discoverConfirm(): Promise<void> {
171
171
  await initSchema();
172
172
 
173
- const pending = await dbGet<any>("SELECT * FROM project WHERE id = 'pending'", ["pending"]);
173
+ const pending = await dbGet<any>("SELECT * FROM project WHERE id = ?", ["pending"]);
174
174
  if (!pending) {
175
175
  throw new CodexaError("Nenhuma descoberta pendente.\nExecute: discover start primeiro");
176
176
  }
@@ -179,9 +179,9 @@ export async function discoverConfirm(): Promise<void> {
179
179
  const now = new Date().toISOString();
180
180
 
181
181
  // Mover de pending para default
182
- await dbRun("DELETE FROM project WHERE id = 'pending'", ["pending"]);
182
+ await dbRun("DELETE FROM project WHERE id = ?", ["pending"]);
183
183
  await dbRun(
184
- `INSERT INTO project (id, name, stack, discovered_at, updated_at, cli_version, last_discover_at)
184
+ `INSERT OR REPLACE INTO project (id, name, stack, discovered_at, updated_at, cli_version, last_discover_at)
185
185
  VALUES ('default', ?, ?, ?, ?, ?, ?)`,
186
186
  ["Projeto", JSON.stringify(data.stack), now, now, pkg.version, now]
187
187
  );
@@ -295,7 +295,7 @@ export async function discoverConfirm(): Promise<void> {
295
295
  export async function discoverShow(json: boolean = false): Promise<void> {
296
296
  await initSchema();
297
297
 
298
- const project = await dbGet<any>("SELECT * FROM project WHERE id = 'default'", ["default"]);
298
+ const project = await dbGet<any>("SELECT * FROM project WHERE id = ?", ["default"]);
299
299
 
300
300
  if (!project) {
301
301
  throw new CodexaError("Projeto nao descoberto.\nExecute: discover start");
@@ -345,7 +345,7 @@ export async function discoverSetStack(options: {
345
345
  }): Promise<void> {
346
346
  await initSchema();
347
347
 
348
- const pending = await dbGet<any>("SELECT * FROM project WHERE id = 'pending'", ["pending"]);
348
+ const pending = await dbGet<any>("SELECT * FROM project WHERE id = ?", ["pending"]);
349
349
  let data: any;
350
350
 
351
351
  if (pending) {
@@ -389,7 +389,7 @@ export async function discoverReset(): Promise<void> {
389
389
  export async function discoverRefresh(options: { force?: boolean } = {}): Promise<void> {
390
390
  await initSchema();
391
391
 
392
- const currentProject = await dbGet<any>("SELECT * FROM project WHERE id = 'default'", ["default"]);
392
+ const currentProject = await dbGet<any>("SELECT * FROM project WHERE id = ?", ["default"]);
393
393
  if (!currentProject) {
394
394
  throw new CodexaError("Projeto nao descoberto.\nExecute: discover start primeiro");
395
395
  }
@@ -430,8 +430,8 @@ export async function discoverRefresh(options: { force?: boolean } = {}): Promis
430
430
  const now = new Date().toISOString();
431
431
 
432
432
  await dbRun(
433
- `UPDATE project SET stack = ?, updated_at = ? WHERE id = 'default'`,
434
- [JSON.stringify(newStack), now]
433
+ `UPDATE project SET stack = ?, updated_at = ? WHERE id = ?`,
434
+ [JSON.stringify(newStack), now, "default"]
435
435
  );
436
436
 
437
437
  // Atualizar standards de stack
@@ -472,7 +472,7 @@ export async function discoverRefresh(options: { force?: boolean } = {}): Promis
472
472
  export async function discoverIncremental(): Promise<void> {
473
473
  await initSchema();
474
474
 
475
- const project = await dbGet<any>("SELECT * FROM project WHERE id = 'default'", ["default"]);
475
+ const project = await dbGet<any>("SELECT * FROM project WHERE id = ?", ["default"]);
476
476
  if (!project) {
477
477
  throw new CodexaError("Projeto nao descoberto.\nExecute: discover start primeiro");
478
478
  }
@@ -516,7 +516,7 @@ export async function discoverIncremental(): Promise<void> {
516
516
 
517
517
  // Atualizar timestamp mesmo sem mudancas
518
518
  const now = new Date().toISOString();
519
- await dbRun("UPDATE project SET last_discover_at = ? WHERE id = 'default'", [now]);
519
+ await dbRun("UPDATE project SET last_discover_at = ? WHERE id = ?", [now, "default"]);
520
520
  return;
521
521
  }
522
522
 
@@ -578,7 +578,7 @@ export async function discoverIncremental(): Promise<void> {
578
578
  // Atualizar timestamp
579
579
  console.log("\n[3/3] Atualizando timestamp...");
580
580
  const now = new Date().toISOString();
581
- await dbRun("UPDATE project SET last_discover_at = ?, updated_at = ? WHERE id = 'default'", [now, now]);
581
+ await dbRun("UPDATE project SET last_discover_at = ?, updated_at = ? WHERE id = ?", [now, now, "default"]);
582
582
 
583
583
  // Resumo
584
584
  console.log("\n" + "═".repeat(50));
@@ -592,7 +592,7 @@ export async function discoverIncremental(): Promise<void> {
592
592
  }
593
593
 
594
594
  async function generateStandardsMarkdown(): Promise<void> {
595
- const project = await dbGet<any>("SELECT * FROM project WHERE id = 'default'", ["default"]);
595
+ const project = await dbGet<any>("SELECT * FROM project WHERE id = ?", ["default"]);
596
596
  const standards = await dbAll<any>("SELECT * FROM standards ORDER BY category, scope", []);
597
597
 
598
598
  if (!project) return;
@@ -1007,7 +1007,7 @@ export async function discoverRefreshPatterns(): Promise<void> {
1007
1007
  await initSchema();
1008
1008
 
1009
1009
  // Verificar se projeto foi descoberto
1010
- const project = await dbGet<any>("SELECT * FROM project WHERE id = 'default'", ["default"]);
1010
+ const project = await dbGet<any>("SELECT * FROM project WHERE id = ?", ["default"]);
1011
1011
  if (!project) {
1012
1012
  throw new CodexaError("Projeto nao descoberto.\nExecute: discover start primeiro");
1013
1013
  }
@@ -35,7 +35,7 @@ export async function productImport(options: { file?: string; content?: string }
35
35
  await initSchema();
36
36
 
37
37
  // Verificar se ja existe
38
- const existing = await dbGet("SELECT * FROM product_context WHERE id = 'default'", ["default"]);
38
+ const existing = await dbGet("SELECT * FROM product_context WHERE id = ?", ["default"]);
39
39
  if (existing) {
40
40
  console.log("\nContexto de produto ja definido.");
41
41
  console.log("Use: product reset para refazer\n");
@@ -100,7 +100,7 @@ export async function productSet(options: {
100
100
  await initSchema();
101
101
 
102
102
  // Buscar pendente ou criar novo
103
- let pending = await dbGet<any>("SELECT * FROM product_context WHERE id = 'pending'", ["pending"]);
103
+ let pending = await dbGet<any>("SELECT * FROM product_context WHERE id = ?", ["pending"]);
104
104
  const now = new Date().toISOString();
105
105
 
106
106
  if (!pending) {
@@ -174,7 +174,7 @@ export async function productSet(options: {
174
174
  [category, goal, priority, now]
175
175
  );
176
176
 
177
- const countRow = await dbGet<any>("SELECT COUNT(*) as c FROM product_goals WHERE product_id = 'pending'", ["pending"]);
177
+ const countRow = await dbGet<any>("SELECT COUNT(*) as c FROM product_goals WHERE product_id = ?", ["pending"]);
178
178
  const count = countRow?.c ?? 0;
179
179
  console.log(`\nObjetivo adicionado (${count} total)`);
180
180
  console.log(` [${category}] ${goal} (${priority})`);
@@ -193,14 +193,14 @@ export async function productSet(options: {
193
193
  [name, description, priority, now]
194
194
  );
195
195
 
196
- const countRow = await dbGet<any>("SELECT COUNT(*) as c FROM product_features WHERE product_id = 'pending'", ["pending"]);
196
+ const countRow = await dbGet<any>("SELECT COUNT(*) as c FROM product_features WHERE product_id = ?", ["pending"]);
197
197
  const count = countRow?.c ?? 0;
198
198
  console.log(`\nFeature adicionada (${count} total)`);
199
199
  console.log(` ${name} (${priority})`);
200
200
  }
201
201
 
202
202
  // Mostrar estado atual
203
- const current = await dbGet<any>("SELECT * FROM product_context WHERE id = 'pending'", ["pending"]);
203
+ const current = await dbGet<any>("SELECT * FROM product_context WHERE id = ?", ["pending"]);
204
204
 
205
205
  console.log("\nContexto de produto atualizado:");
206
206
  console.log("─".repeat(40));
@@ -219,7 +219,7 @@ export async function productSet(options: {
219
219
  export async function productConfirm(): Promise<void> {
220
220
  await initSchema();
221
221
 
222
- const pending = await dbGet<any>("SELECT * FROM product_context WHERE id = 'pending'", ["pending"]);
222
+ const pending = await dbGet<any>("SELECT * FROM product_context WHERE id = ?", ["pending"]);
223
223
  if (!pending) {
224
224
  throw new CodexaError("Nenhum contexto de produto pendente.\nExecute: product import primeiro");
225
225
  }
@@ -238,16 +238,16 @@ export async function productConfirm(): Promise<void> {
238
238
  await dbRun("PRAGMA foreign_keys = OFF");
239
239
 
240
240
  // Deletar goals e features do 'default' ANTES de deletar product_context
241
- await dbRun("DELETE FROM product_goals WHERE product_id = 'default'", ["default"]);
242
- await dbRun("DELETE FROM product_features WHERE product_id = 'default'", ["default"]);
243
- await dbRun("DELETE FROM product_context WHERE id = 'default'", ["default"]);
241
+ await dbRun("DELETE FROM product_goals WHERE product_id = ?", ["default"]);
242
+ await dbRun("DELETE FROM product_features WHERE product_id = ?", ["default"]);
243
+ await dbRun("DELETE FROM product_context WHERE id = ?", ["default"]);
244
244
 
245
245
  // Mover pending para default (primeiro os filhos, depois o pai)
246
- await dbRun(`UPDATE product_goals SET product_id = 'default' WHERE product_id = 'pending'`, ["pending"]);
247
- await dbRun(`UPDATE product_features SET product_id = 'default' WHERE product_id = 'pending'`, ["pending"]);
246
+ await dbRun(`UPDATE product_goals SET product_id = ? WHERE product_id = ?`, ["default", "pending"]);
247
+ await dbRun(`UPDATE product_features SET product_id = ? WHERE product_id = ?`, ["default", "pending"]);
248
248
  await dbRun(
249
- `UPDATE product_context SET id = 'default', updated_at = ? WHERE id = 'pending'`,
250
- [now]
249
+ `UPDATE product_context SET id = ?, updated_at = ? WHERE id = ?`,
250
+ ["default", now, "pending"]
251
251
  );
252
252
 
253
253
  // Reabilitar foreign keys
@@ -256,8 +256,8 @@ export async function productConfirm(): Promise<void> {
256
256
  // Gerar arquivo product-context.md
257
257
  await generateProductMarkdown();
258
258
 
259
- const goalsCountRow = await dbGet<any>("SELECT COUNT(*) as c FROM product_goals WHERE product_id = 'default'", ["default"]);
260
- const featuresCountRow = await dbGet<any>("SELECT COUNT(*) as c FROM product_features WHERE product_id = 'default'", ["default"]);
259
+ const goalsCountRow = await dbGet<any>("SELECT COUNT(*) as c FROM product_goals WHERE product_id = ?", ["default"]);
260
+ const featuresCountRow = await dbGet<any>("SELECT COUNT(*) as c FROM product_features WHERE product_id = ?", ["default"]);
261
261
  const goalsCount = goalsCountRow?.c ?? 0;
262
262
  const featuresCount = featuresCountRow?.c ?? 0;
263
263
 
@@ -425,9 +425,9 @@ export async function productReset(): Promise<void> {
425
425
  // ═══════════════════════════════════════════════════════════════
426
426
 
427
427
  async function generateProductMarkdown(): Promise<void> {
428
- const product = await dbGet<any>("SELECT * FROM product_context WHERE id = 'default'", ["default"]);
429
- const goals = await dbAll<any>("SELECT * FROM product_goals WHERE product_id = 'default' ORDER BY priority, category", ["default"]);
430
- const features = await dbAll<any>("SELECT * FROM product_features WHERE product_id = 'default' ORDER BY priority", ["default"]);
428
+ const product = await dbGet<any>("SELECT * FROM product_context WHERE id = ?", ["default"]);
429
+ const goals = await dbAll<any>("SELECT * FROM product_goals WHERE product_id = ? ORDER BY priority, category", ["default"]);
430
+ const features = await dbAll<any>("SELECT * FROM product_features WHERE product_id = ? ORDER BY priority", ["default"]);
431
431
 
432
432
  if (!product) return;
433
433
 
package/commands/utils.ts CHANGED
@@ -183,7 +183,7 @@ export async function contextExport(options: { task?: string; json?: boolean; sp
183
183
  [spec.id]
184
184
  );
185
185
  const artifacts = await dbAll<any>("SELECT * FROM artifacts WHERE spec_id = ?", [spec.id]);
186
- const project = await dbGet<any>("SELECT * FROM project WHERE id = 'default'", ["default"]);
186
+ const project = await dbGet<any>("SELECT * FROM project WHERE id = ?", ["default"]);
187
187
 
188
188
  let taskContext = null;
189
189
  let standards: any[] = [];
@@ -238,9 +238,9 @@ export async function contextExport(options: { task?: string; json?: boolean; sp
238
238
  }
239
239
 
240
240
  // Obter contexto de produto
241
- const productContext = await dbGet<any>("SELECT * FROM product_context WHERE id = 'default'", ["default"]);
242
- const productGoals = await dbAll<any>("SELECT * FROM product_goals WHERE product_id = 'default'", ["default"]);
243
- const productFeatures = await dbAll<any>("SELECT * FROM product_features WHERE product_id = 'default'", ["default"]);
241
+ const productContext = await dbGet<any>("SELECT * FROM product_context WHERE id = ?", ["default"]);
242
+ const productGoals = await dbAll<any>("SELECT * FROM product_goals WHERE product_id = ?", ["default"]);
243
+ const productFeatures = await dbAll<any>("SELECT * FROM product_features WHERE product_id = ?", ["default"]);
244
244
 
245
245
  const exportData = {
246
246
  spec: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codexa/cli",
3
- "version": "9.0.36",
3
+ "version": "9.0.38",
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": {