@codexa/cli 8.6.0 → 8.6.10
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 -760
- package/commands/check.ts +131 -131
- package/commands/clear.ts +170 -170
- package/commands/decide.ts +249 -249
- package/commands/discover.ts +1071 -1071
- package/commands/knowledge.ts +361 -361
- package/commands/patterns.ts +621 -621
- package/commands/plan.ts +376 -376
- package/commands/product.ts +626 -626
- package/commands/research.ts +754 -754
- package/commands/review.ts +463 -463
- package/commands/standards.ts +200 -200
- package/commands/task.ts +623 -623
- package/commands/utils.ts +1024 -1021
- package/db/connection.ts +32 -32
- package/db/schema.ts +719 -719
- package/detectors/README.md +109 -109
- package/detectors/dotnet.ts +357 -357
- package/detectors/flutter.ts +350 -350
- package/detectors/go.ts +324 -324
- package/detectors/index.ts +387 -387
- package/detectors/jvm.ts +433 -433
- package/detectors/loader.ts +128 -128
- package/detectors/node.ts +493 -493
- package/detectors/python.ts +423 -423
- package/detectors/rust.ts +348 -348
- package/gates/standards-validator.ts +204 -204
- package/gates/validator.ts +441 -441
- package/package.json +44 -43
- package/protocol/process-return.ts +450 -450
- package/protocol/subagent-protocol.ts +401 -401
- package/workflow.ts +802 -782
package/commands/standards.ts
CHANGED
|
@@ -1,201 +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");
|
|
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
201
|
}
|