@umbral/cli 0.0.5 → 0.0.7
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/dist/index.js +45 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -971,27 +971,24 @@ function normalizeEde(raw, index) {
|
|
|
971
971
|
};
|
|
972
972
|
}
|
|
973
973
|
function parseEdes(stdout2) {
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
edes.push(ede);
|
|
984
|
-
}
|
|
985
|
-
} catch {
|
|
974
|
+
const jsonStr = extractJson(stdout2);
|
|
975
|
+
const parsed = JSON.parse(jsonStr);
|
|
976
|
+
if (!Array.isArray(parsed) || parsed.length === 0) return null;
|
|
977
|
+
const edes = [];
|
|
978
|
+
for (let i = 0; i < parsed.length; i++) {
|
|
979
|
+
try {
|
|
980
|
+
const ede = normalizeEde(parsed[i], i);
|
|
981
|
+
if (ede.whatAndHow.decision && ede.why.rationale) {
|
|
982
|
+
edes.push(ede);
|
|
986
983
|
}
|
|
984
|
+
} catch {
|
|
987
985
|
}
|
|
988
|
-
return edes.length > 0 ? edes : null;
|
|
989
|
-
} catch {
|
|
990
|
-
return null;
|
|
991
986
|
}
|
|
987
|
+
return edes.length > 0 ? edes : null;
|
|
992
988
|
}
|
|
993
989
|
function generateWithClaude(detections) {
|
|
994
|
-
if (detections.length === 0)
|
|
990
|
+
if (detections.length === 0)
|
|
991
|
+
return Promise.resolve({ edes: null, error: "Sin detecciones" });
|
|
995
992
|
const prompt = buildPrompt(detections);
|
|
996
993
|
return new Promise((resolve) => {
|
|
997
994
|
const child = spawn("claude", ["--print"], {
|
|
@@ -1013,15 +1010,32 @@ function generateWithClaude(detections) {
|
|
|
1013
1010
|
});
|
|
1014
1011
|
child.on("close", (code) => {
|
|
1015
1012
|
clearTimeout(timeout);
|
|
1016
|
-
if (timedOut
|
|
1017
|
-
resolve(null);
|
|
1013
|
+
if (timedOut) {
|
|
1014
|
+
resolve({ edes: null, error: "Timeout (>2min)" });
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
if (code !== 0 || !stdout2.trim()) {
|
|
1018
|
+
const reason = stderr.trim().split("\n")[0] || `exit code ${code}`;
|
|
1019
|
+
resolve({ edes: null, error: reason });
|
|
1018
1020
|
return;
|
|
1019
1021
|
}
|
|
1020
|
-
|
|
1022
|
+
try {
|
|
1023
|
+
const edes = parseEdes(stdout2);
|
|
1024
|
+
if (!edes) {
|
|
1025
|
+
resolve({
|
|
1026
|
+
edes: null,
|
|
1027
|
+
error: "Claude respondio pero el JSON no es valido"
|
|
1028
|
+
});
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1031
|
+
resolve({ edes });
|
|
1032
|
+
} catch (e) {
|
|
1033
|
+
resolve({ edes: null, error: `Error parseando JSON: ${e.message}` });
|
|
1034
|
+
}
|
|
1021
1035
|
});
|
|
1022
|
-
child.on("error", () => {
|
|
1036
|
+
child.on("error", (err) => {
|
|
1023
1037
|
clearTimeout(timeout);
|
|
1024
|
-
resolve(null);
|
|
1038
|
+
resolve({ edes: null, error: err.message });
|
|
1025
1039
|
});
|
|
1026
1040
|
child.stdin.write(prompt);
|
|
1027
1041
|
child.stdin.end();
|
|
@@ -1117,20 +1131,21 @@ function generateFromTemplates(detections) {
|
|
|
1117
1131
|
return proposals;
|
|
1118
1132
|
}
|
|
1119
1133
|
async function generateProposals(detections) {
|
|
1134
|
+
const w = (s) => process.stdout.write(s);
|
|
1120
1135
|
if (isClaudeAvailable()) {
|
|
1121
1136
|
const spinner = createSpinner("Generando EDEs con Claude Code...");
|
|
1122
|
-
const
|
|
1123
|
-
if (
|
|
1137
|
+
const result = await generateWithClaude(detections);
|
|
1138
|
+
if (result.edes && result.edes.length > 0) {
|
|
1124
1139
|
spinner.succeed(
|
|
1125
|
-
`${
|
|
1140
|
+
`${result.edes.length} EDEs generadas con Claude Code (IA)`
|
|
1126
1141
|
);
|
|
1127
|
-
return { proposals:
|
|
1142
|
+
return { proposals: result.edes, source: "claude" };
|
|
1128
1143
|
}
|
|
1129
|
-
spinner.fail(
|
|
1130
|
-
|
|
1131
|
-
process.stdout.write(
|
|
1132
|
-
" \u21B3 Claude Code no disponible \u2014 usando templates locales\n"
|
|
1144
|
+
spinner.fail(
|
|
1145
|
+
`Claude fallo: ${result.error ?? "respuesta vacia"} \u2014 usando templates`
|
|
1133
1146
|
);
|
|
1147
|
+
} else {
|
|
1148
|
+
w(" \u21B3 Claude Code no disponible \u2014 usando templates locales\n");
|
|
1134
1149
|
}
|
|
1135
1150
|
return { proposals: generateFromTemplates(detections), source: "templates" };
|
|
1136
1151
|
}
|
|
@@ -1865,7 +1880,7 @@ function stopCommand() {
|
|
|
1865
1880
|
|
|
1866
1881
|
// src/index.ts
|
|
1867
1882
|
var program = new Command();
|
|
1868
|
-
program.name("umbral").description("Umbral \u2014 Framework de gobernanza para proyectos con Claude Code").version("0.0.
|
|
1883
|
+
program.name("umbral").description("Umbral \u2014 Framework de gobernanza para proyectos con Claude Code").version("0.0.7");
|
|
1869
1884
|
program.command("init").description("Inicializar Umbral en el proyecto actual").option("--yes", "Aceptar todas las propuestas sin preguntar").option("--path <path>", "Ruta al proyecto (default: directorio actual)").action(initCommand);
|
|
1870
1885
|
program.command("start").description("Levantar la plataforma Umbral (Neo4j + Dashboard web)").option("--port <port>", "Puerto para el dashboard (default: auto)").option("--no-detach", "Correr en primer plano (sin -d)").action(startCommand);
|
|
1871
1886
|
program.command("stop").description("Detener la plataforma Umbral").action(stopCommand);
|