@codexa/cli 8.5.0 → 8.6.0
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/commands/architect.ts +760 -896
- package/commands/check.ts +131 -131
- package/commands/clear.ts +170 -174
- package/commands/decide.ts +249 -249
- package/commands/discover.ts +82 -10
- package/commands/knowledge.ts +361 -361
- package/commands/patterns.ts +621 -621
- package/commands/plan.ts +376 -376
- package/commands/product.ts +626 -628
- package/commands/research.ts +754 -754
- package/commands/review.ts +463 -463
- package/commands/standards.ts +200 -223
- package/commands/task.ts +2 -2
- package/commands/utils.ts +1021 -1021
- package/db/connection.ts +32 -32
- package/db/schema.ts +719 -788
- package/detectors/loader.ts +0 -12
- package/gates/standards-validator.ts +204 -204
- package/gates/validator.ts +441 -441
- package/package.json +43 -43
- package/protocol/process-return.ts +450 -450
- package/protocol/subagent-protocol.ts +401 -411
- package/workflow.ts +0 -18
package/commands/standards.ts
CHANGED
|
@@ -1,224 +1,201 @@
|
|
|
1
|
-
import { getDb } from "../db/connection";
|
|
2
|
-
import { initSchema } from "../db/schema";
|
|
3
|
-
import { generateStandardsMarkdown } from "./discover";
|
|
4
|
-
|
|
5
|
-
export function standardsList(options: { category?: string; scope?: string; json?: boolean }): void {
|
|
6
|
-
initSchema();
|
|
7
|
-
const db = getDb();
|
|
8
|
-
|
|
9
|
-
let query = "SELECT * FROM standards WHERE 1=1";
|
|
10
|
-
const params: any[] = [];
|
|
11
|
-
|
|
12
|
-
if (options.category) {
|
|
13
|
-
query += " AND category = ?";
|
|
14
|
-
params.push(options.category);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (options.scope) {
|
|
18
|
-
query += " AND scope = ?";
|
|
19
|
-
params.push(options.scope);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
query += " ORDER BY category, scope";
|
|
23
|
-
|
|
24
|
-
const standards = db.query(query).all(...params) as any[];
|
|
25
|
-
|
|
26
|
-
if (options.json) {
|
|
27
|
-
console.log(JSON.stringify({ standards }, null, 2));
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (standards.length === 0) {
|
|
32
|
-
console.log("\nNenhum standard definido.");
|
|
33
|
-
console.log("Execute: discover start para detectar automaticamente");
|
|
34
|
-
console.log("Ou: standards add para adicionar manualmente\n");
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
console.log(`\nStandards (${standards.length}):`);
|
|
39
|
-
console.log("═".repeat(60));
|
|
40
|
-
|
|
41
|
-
let currentCategory = "";
|
|
42
|
-
for (const std of standards) {
|
|
43
|
-
if (std.category !== currentCategory) {
|
|
44
|
-
currentCategory = std.category;
|
|
45
|
-
console.log(`\n[${currentCategory.toUpperCase()}]`);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const enforcement = std.enforcement === "required" ? "[REQ]" : "[REC]";
|
|
49
|
-
console.log(` #${std.id} ${enforcement} (${std.scope}) ${std.rule}`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
console.log("\n" + "─".repeat(60));
|
|
53
|
-
console.log("Legenda: [REQ] = Obrigatorio [REC] = Recomendado\n");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function standardsAdd(options: {
|
|
57
|
-
category: string;
|
|
58
|
-
scope: string;
|
|
59
|
-
rule: string;
|
|
60
|
-
examples?: string;
|
|
61
|
-
antiExamples?: string;
|
|
62
|
-
enforcement?: string;
|
|
63
|
-
}): void {
|
|
64
|
-
initSchema();
|
|
65
|
-
const db = getDb();
|
|
66
|
-
|
|
67
|
-
const validCategories = ["stack", "structure", "naming", "code", "library", "practice"];
|
|
68
|
-
const validScopes = ["all", "database", "backend", "frontend", "testing"];
|
|
69
|
-
const validEnforcement = ["required", "recommended"];
|
|
70
|
-
|
|
71
|
-
if (!validCategories.includes(options.category)) {
|
|
72
|
-
console.error(`\nCategoria invalida: ${options.category}`);
|
|
73
|
-
console.error(`Validas: ${validCategories.join(", ")}\n`);
|
|
74
|
-
process.exit(2);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (!validScopes.includes(options.scope)) {
|
|
78
|
-
console.error(`\nEscopo invalido: ${options.scope}`);
|
|
79
|
-
console.error(`Validos: ${validScopes.join(", ")}\n`);
|
|
80
|
-
process.exit(2);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const enforcement = options.enforcement || "required";
|
|
84
|
-
if (!validEnforcement.includes(enforcement)) {
|
|
85
|
-
console.error(`\nEnforcement invalido: ${enforcement}`);
|
|
86
|
-
console.error(`Validos: ${validEnforcement.join(", ")}\n`);
|
|
87
|
-
process.exit(2);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
let examples = null;
|
|
91
|
-
let antiExamples = null;
|
|
92
|
-
|
|
93
|
-
if (options.examples) {
|
|
94
|
-
examples = JSON.stringify(options.examples.split(",").map((s) => s.trim()));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (options.antiExamples) {
|
|
98
|
-
antiExamples = JSON.stringify(options.antiExamples.split(",").map((s) => s.trim()));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const result = db.run(
|
|
102
|
-
`INSERT INTO standards (category, scope, rule, examples, anti_examples, enforcement, source, created_at)
|
|
103
|
-
VALUES (?, ?, ?, ?, ?, ?, 'user', datetime('now'))`,
|
|
104
|
-
[options.category, options.scope, options.rule, examples, antiExamples, enforcement]
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
// Regenerar markdown
|
|
108
|
-
generateStandardsMarkdown();
|
|
109
|
-
|
|
110
|
-
console.log(`\nStandard #${result.lastInsertRowid} adicionado:`);
|
|
111
|
-
console.log(` Categoria: ${options.category}`);
|
|
112
|
-
console.log(` Escopo: ${options.scope}`);
|
|
113
|
-
console.log(` Regra: ${options.rule}`);
|
|
114
|
-
console.log(` Enforcement: ${enforcement}`);
|
|
115
|
-
console.log("\nArquivo atualizado: .codexa/standards.md\n");
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export function standardsEdit(
|
|
119
|
-
id: string,
|
|
120
|
-
options: {
|
|
121
|
-
rule?: string;
|
|
122
|
-
examples?: string;
|
|
123
|
-
antiExamples?: string;
|
|
124
|
-
enforcement?: string;
|
|
125
|
-
}
|
|
126
|
-
): void {
|
|
127
|
-
initSchema();
|
|
128
|
-
const db = getDb();
|
|
129
|
-
|
|
130
|
-
const standardId = parseInt(id);
|
|
131
|
-
const existing = db.query("SELECT * FROM standards WHERE id = ?").get(standardId) as any;
|
|
132
|
-
|
|
133
|
-
if (!existing) {
|
|
134
|
-
console.error(`\nStandard #${id} nao encontrado.\n`);
|
|
135
|
-
process.exit(1);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const updates: string[] = [];
|
|
139
|
-
const params: any[] = [];
|
|
140
|
-
|
|
141
|
-
if (options.rule) {
|
|
142
|
-
updates.push("rule = ?");
|
|
143
|
-
params.push(options.rule);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (options.examples) {
|
|
147
|
-
updates.push("examples = ?");
|
|
148
|
-
params.push(JSON.stringify(options.examples.split(",").map((s) => s.trim())));
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (options.antiExamples) {
|
|
152
|
-
updates.push("anti_examples = ?");
|
|
153
|
-
params.push(JSON.stringify(options.antiExamples.split(",").map((s) => s.trim())));
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (options.enforcement) {
|
|
157
|
-
updates.push("enforcement = ?");
|
|
158
|
-
params.push(options.enforcement);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (updates.length === 0) {
|
|
162
|
-
console.error("\nNenhuma alteracao fornecida.\n");
|
|
163
|
-
process.exit(2);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
params.push(standardId);
|
|
167
|
-
db.run(`UPDATE standards SET ${updates.join(", ")} WHERE id = ?`, params);
|
|
168
|
-
|
|
169
|
-
// Regenerar markdown
|
|
170
|
-
generateStandardsMarkdown();
|
|
171
|
-
|
|
172
|
-
console.log(`\nStandard #${id} atualizado.`);
|
|
173
|
-
console.log("Arquivo atualizado: .codexa/standards.md\n");
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export function standardsRemove(id: string): void {
|
|
177
|
-
initSchema();
|
|
178
|
-
const db = getDb();
|
|
179
|
-
|
|
180
|
-
const standardId = parseInt(id);
|
|
181
|
-
const existing = db.query("SELECT * FROM standards WHERE id = ?").get(standardId) as any;
|
|
182
|
-
|
|
183
|
-
if (!existing) {
|
|
184
|
-
console.error(`\nStandard #${id} nao encontrado.\n`);
|
|
185
|
-
process.exit(1);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
db.run("DELETE FROM standards WHERE id = ?", [standardId]);
|
|
189
|
-
|
|
190
|
-
// Regenerar markdown
|
|
191
|
-
generateStandardsMarkdown();
|
|
192
|
-
|
|
193
|
-
console.log(`\nStandard #${id} removido: ${existing.rule}`);
|
|
194
|
-
console.log("Arquivo atualizado: .codexa/standards.md\n");
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export function standardsExport(): void {
|
|
198
|
-
initSchema();
|
|
199
|
-
generateStandardsMarkdown();
|
|
200
|
-
console.log("\nArquivo gerado: .codexa/standards.md\n");
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export function getStandardsForAgent(agent: string): any[] {
|
|
204
|
-
const db = getDb();
|
|
205
|
-
|
|
206
|
-
// Extrair dominio do agent (ex: "backend-bun" -> "backend")
|
|
207
|
-
const domain = agent.split("-")[0];
|
|
208
|
-
|
|
209
|
-
const standards = db
|
|
210
|
-
.query(
|
|
211
|
-
`SELECT * FROM standards
|
|
212
|
-
WHERE scope = 'all' OR scope = ?
|
|
213
|
-
ORDER BY enforcement DESC, category`
|
|
214
|
-
)
|
|
215
|
-
.all(domain) as any[];
|
|
216
|
-
|
|
217
|
-
return standards.map((std) => ({
|
|
218
|
-
category: std.category,
|
|
219
|
-
rule: std.rule,
|
|
220
|
-
examples: std.examples ? JSON.parse(std.examples) : [],
|
|
221
|
-
anti_examples: std.anti_examples ? JSON.parse(std.anti_examples) : [],
|
|
222
|
-
enforcement: std.enforcement,
|
|
223
|
-
}));
|
|
1
|
+
import { getDb } from "../db/connection";
|
|
2
|
+
import { initSchema } from "../db/schema";
|
|
3
|
+
import { generateStandardsMarkdown } from "./discover";
|
|
4
|
+
|
|
5
|
+
export function standardsList(options: { category?: string; scope?: string; json?: boolean }): void {
|
|
6
|
+
initSchema();
|
|
7
|
+
const db = getDb();
|
|
8
|
+
|
|
9
|
+
let query = "SELECT * FROM standards WHERE 1=1";
|
|
10
|
+
const params: any[] = [];
|
|
11
|
+
|
|
12
|
+
if (options.category) {
|
|
13
|
+
query += " AND category = ?";
|
|
14
|
+
params.push(options.category);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (options.scope) {
|
|
18
|
+
query += " AND scope = ?";
|
|
19
|
+
params.push(options.scope);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
query += " ORDER BY category, scope";
|
|
23
|
+
|
|
24
|
+
const standards = db.query(query).all(...params) as any[];
|
|
25
|
+
|
|
26
|
+
if (options.json) {
|
|
27
|
+
console.log(JSON.stringify({ standards }, null, 2));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (standards.length === 0) {
|
|
32
|
+
console.log("\nNenhum standard definido.");
|
|
33
|
+
console.log("Execute: discover start para detectar automaticamente");
|
|
34
|
+
console.log("Ou: standards add para adicionar manualmente\n");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
console.log(`\nStandards (${standards.length}):`);
|
|
39
|
+
console.log("═".repeat(60));
|
|
40
|
+
|
|
41
|
+
let currentCategory = "";
|
|
42
|
+
for (const std of standards) {
|
|
43
|
+
if (std.category !== currentCategory) {
|
|
44
|
+
currentCategory = std.category;
|
|
45
|
+
console.log(`\n[${currentCategory.toUpperCase()}]`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const enforcement = std.enforcement === "required" ? "[REQ]" : "[REC]";
|
|
49
|
+
console.log(` #${std.id} ${enforcement} (${std.scope}) ${std.rule}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
console.log("\n" + "─".repeat(60));
|
|
53
|
+
console.log("Legenda: [REQ] = Obrigatorio [REC] = Recomendado\n");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function standardsAdd(options: {
|
|
57
|
+
category: string;
|
|
58
|
+
scope: string;
|
|
59
|
+
rule: string;
|
|
60
|
+
examples?: string;
|
|
61
|
+
antiExamples?: string;
|
|
62
|
+
enforcement?: string;
|
|
63
|
+
}): void {
|
|
64
|
+
initSchema();
|
|
65
|
+
const db = getDb();
|
|
66
|
+
|
|
67
|
+
const validCategories = ["stack", "structure", "naming", "code", "library", "practice"];
|
|
68
|
+
const validScopes = ["all", "database", "backend", "frontend", "testing"];
|
|
69
|
+
const validEnforcement = ["required", "recommended"];
|
|
70
|
+
|
|
71
|
+
if (!validCategories.includes(options.category)) {
|
|
72
|
+
console.error(`\nCategoria invalida: ${options.category}`);
|
|
73
|
+
console.error(`Validas: ${validCategories.join(", ")}\n`);
|
|
74
|
+
process.exit(2);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!validScopes.includes(options.scope)) {
|
|
78
|
+
console.error(`\nEscopo invalido: ${options.scope}`);
|
|
79
|
+
console.error(`Validos: ${validScopes.join(", ")}\n`);
|
|
80
|
+
process.exit(2);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const enforcement = options.enforcement || "required";
|
|
84
|
+
if (!validEnforcement.includes(enforcement)) {
|
|
85
|
+
console.error(`\nEnforcement invalido: ${enforcement}`);
|
|
86
|
+
console.error(`Validos: ${validEnforcement.join(", ")}\n`);
|
|
87
|
+
process.exit(2);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
let examples = null;
|
|
91
|
+
let antiExamples = null;
|
|
92
|
+
|
|
93
|
+
if (options.examples) {
|
|
94
|
+
examples = JSON.stringify(options.examples.split(",").map((s) => s.trim()));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (options.antiExamples) {
|
|
98
|
+
antiExamples = JSON.stringify(options.antiExamples.split(",").map((s) => s.trim()));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const result = db.run(
|
|
102
|
+
`INSERT INTO standards (category, scope, rule, examples, anti_examples, enforcement, source, created_at)
|
|
103
|
+
VALUES (?, ?, ?, ?, ?, ?, 'user', datetime('now'))`,
|
|
104
|
+
[options.category, options.scope, options.rule, examples, antiExamples, enforcement]
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
// Regenerar markdown
|
|
108
|
+
generateStandardsMarkdown();
|
|
109
|
+
|
|
110
|
+
console.log(`\nStandard #${result.lastInsertRowid} adicionado:`);
|
|
111
|
+
console.log(` Categoria: ${options.category}`);
|
|
112
|
+
console.log(` Escopo: ${options.scope}`);
|
|
113
|
+
console.log(` Regra: ${options.rule}`);
|
|
114
|
+
console.log(` Enforcement: ${enforcement}`);
|
|
115
|
+
console.log("\nArquivo atualizado: .codexa/standards.md\n");
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function standardsEdit(
|
|
119
|
+
id: string,
|
|
120
|
+
options: {
|
|
121
|
+
rule?: string;
|
|
122
|
+
examples?: string;
|
|
123
|
+
antiExamples?: string;
|
|
124
|
+
enforcement?: string;
|
|
125
|
+
}
|
|
126
|
+
): void {
|
|
127
|
+
initSchema();
|
|
128
|
+
const db = getDb();
|
|
129
|
+
|
|
130
|
+
const standardId = parseInt(id);
|
|
131
|
+
const existing = db.query("SELECT * FROM standards WHERE id = ?").get(standardId) as any;
|
|
132
|
+
|
|
133
|
+
if (!existing) {
|
|
134
|
+
console.error(`\nStandard #${id} nao encontrado.\n`);
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const updates: string[] = [];
|
|
139
|
+
const params: any[] = [];
|
|
140
|
+
|
|
141
|
+
if (options.rule) {
|
|
142
|
+
updates.push("rule = ?");
|
|
143
|
+
params.push(options.rule);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (options.examples) {
|
|
147
|
+
updates.push("examples = ?");
|
|
148
|
+
params.push(JSON.stringify(options.examples.split(",").map((s) => s.trim())));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (options.antiExamples) {
|
|
152
|
+
updates.push("anti_examples = ?");
|
|
153
|
+
params.push(JSON.stringify(options.antiExamples.split(",").map((s) => s.trim())));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (options.enforcement) {
|
|
157
|
+
updates.push("enforcement = ?");
|
|
158
|
+
params.push(options.enforcement);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (updates.length === 0) {
|
|
162
|
+
console.error("\nNenhuma alteracao fornecida.\n");
|
|
163
|
+
process.exit(2);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
params.push(standardId);
|
|
167
|
+
db.run(`UPDATE standards SET ${updates.join(", ")} WHERE id = ?`, params);
|
|
168
|
+
|
|
169
|
+
// Regenerar markdown
|
|
170
|
+
generateStandardsMarkdown();
|
|
171
|
+
|
|
172
|
+
console.log(`\nStandard #${id} atualizado.`);
|
|
173
|
+
console.log("Arquivo atualizado: .codexa/standards.md\n");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function standardsRemove(id: string): void {
|
|
177
|
+
initSchema();
|
|
178
|
+
const db = getDb();
|
|
179
|
+
|
|
180
|
+
const standardId = parseInt(id);
|
|
181
|
+
const existing = db.query("SELECT * FROM standards WHERE id = ?").get(standardId) as any;
|
|
182
|
+
|
|
183
|
+
if (!existing) {
|
|
184
|
+
console.error(`\nStandard #${id} nao encontrado.\n`);
|
|
185
|
+
process.exit(1);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
db.run("DELETE FROM standards WHERE id = ?", [standardId]);
|
|
189
|
+
|
|
190
|
+
// Regenerar markdown
|
|
191
|
+
generateStandardsMarkdown();
|
|
192
|
+
|
|
193
|
+
console.log(`\nStandard #${id} removido: ${existing.rule}`);
|
|
194
|
+
console.log("Arquivo atualizado: .codexa/standards.md\n");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export function standardsExport(): void {
|
|
198
|
+
initSchema();
|
|
199
|
+
generateStandardsMarkdown();
|
|
200
|
+
console.log("\nArquivo gerado: .codexa/standards.md\n");
|
|
224
201
|
}
|
package/commands/task.ts
CHANGED
|
@@ -224,7 +224,7 @@ ${taskFiles.map(f => ` - ${f}`).join('\n') || ' (nenhum arquivo especificado -
|
|
|
224
224
|
╚══════════════════════════════════════════════════════════════════════════════╝
|
|
225
225
|
|
|
226
226
|
ANTES de criar o 4o, 7o, 10o arquivo (a cada 3), execute:
|
|
227
|
-
|
|
227
|
+
codexa knowledge list --severity critical --unread
|
|
228
228
|
|
|
229
229
|
Se retornar QUALQUER blocker:
|
|
230
230
|
1. PARE imediatamente
|
|
@@ -520,7 +520,7 @@ export function taskDone(id: string, options: { checkpoint: string; files?: stri
|
|
|
520
520
|
* Mostra resumo detalhado da implementacao apos todas as tasks concluidas
|
|
521
521
|
* Permite ao usuario decidir se quer fazer review ou nao
|
|
522
522
|
*/
|
|
523
|
-
|
|
523
|
+
function showImplementationSummary(
|
|
524
524
|
specId: number,
|
|
525
525
|
tasks: any[],
|
|
526
526
|
artifacts: any[],
|