openprompt-lang 1.2.0 → 1.2.2
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/package.json +3 -3
- package/src/commands/init-core.js +4 -1
- package/src/commands/init-existing.js +6 -1
- package/src/commands/init-helpers.js +36 -0
- package/src/core/engine/ast-mutate.js +4 -1
- package/src/core/engine/blast-radius.js +4 -1
- package/src/core/engine/sandbox.js +5 -4
- package/src/mcp-plan-server.js +1 -1
- package/src/mcp-refactor/mcp-server.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openprompt-lang",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "PromptLang CLI — Context Engine de anotaciones para desarrollo asistido por IA",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./bin/cli.js",
|
|
@@ -79,14 +79,14 @@
|
|
|
79
79
|
"handlebars": "^4.7.9",
|
|
80
80
|
"inquirer": "^9.3.0",
|
|
81
81
|
"pdf-parse": "^2.4.5",
|
|
82
|
-
"tesseract.js": "^7.0.0"
|
|
82
|
+
"tesseract.js": "^7.0.0",
|
|
83
|
+
"typescript": "^6.0.3"
|
|
83
84
|
},
|
|
84
85
|
"devDependencies": {
|
|
85
86
|
"@types/node": "^25.9.1",
|
|
86
87
|
"eslint": "^10.3.0",
|
|
87
88
|
"husky": "^9.1.7",
|
|
88
89
|
"prettier": "^3.8.3",
|
|
89
|
-
"typescript": "^6.0.3",
|
|
90
90
|
"vitest": "^4.1.6"
|
|
91
91
|
},
|
|
92
92
|
"repository": {
|
|
@@ -7,7 +7,7 @@ import { writeFileSync, existsSync, mkdirSync } from "fs"
|
|
|
7
7
|
import { join } from "path"
|
|
8
8
|
import chalk from "chalk"
|
|
9
9
|
import inquirer from "inquirer"
|
|
10
|
-
import { validatePreInit } from "./init-helpers.js"
|
|
10
|
+
import { validatePreInit, checkAndInstallOpencode } from "./init-helpers.js"
|
|
11
11
|
import { initExisting } from "./init-existing.js"
|
|
12
12
|
|
|
13
13
|
export async function init(options) {
|
|
@@ -106,6 +106,9 @@ export async function init(options) {
|
|
|
106
106
|
)
|
|
107
107
|
console.log(chalk.green(" ✅ package.json"))
|
|
108
108
|
|
|
109
|
+
// ── Verificar OpenCode ──
|
|
110
|
+
await checkAndInstallOpencode(interactive)
|
|
111
|
+
|
|
109
112
|
// ── Handoff a la IA ──
|
|
110
113
|
console.log(chalk.cyan("\n✨ OPL Init: Estructura base lista."))
|
|
111
114
|
console.log(chalk.yellow("OPL delega ahora la inicialización estratégica a tu Agente IA."))
|
|
@@ -8,7 +8,7 @@ import { join } from "path"
|
|
|
8
8
|
import chalk from "chalk"
|
|
9
9
|
import inquirer from "inquirer"
|
|
10
10
|
import { detectStack, loadConfig } from "../utils/config.js"
|
|
11
|
-
import { DESCRIPTIVE_SCRIPTS } from "./init-helpers.js"
|
|
11
|
+
import { DESCRIPTIVE_SCRIPTS, checkAndInstallOpencode } from "./init-helpers.js"
|
|
12
12
|
import { generateFrameworkMd } from "../utils/generate-framework-md.js"
|
|
13
13
|
|
|
14
14
|
function enhancedDetectStack(cwd) {
|
|
@@ -137,6 +137,11 @@ export async function initExisting(options = {}) {
|
|
|
137
137
|
|
|
138
138
|
if (!rebuild) {
|
|
139
139
|
console.log(chalk.cyan(`\n🔧 Inicializando OPL en proyecto existente: ${projectName}\n`))
|
|
140
|
+
|
|
141
|
+
// ── Verificar OpenCode ──
|
|
142
|
+
const interactive = options.interactive !== false && !!process.stdin.isTTY
|
|
143
|
+
await checkAndInstallOpencode(interactive)
|
|
144
|
+
|
|
140
145
|
console.log(chalk.cyan("✨ OPL Init: Entorno detectado."))
|
|
141
146
|
console.log(chalk.yellow("OPL delega ahora la inicialización estratégica a tu Agente IA."))
|
|
142
147
|
console.log(chalk.white("Copia y pega el siguiente prompt en tu chat con la IA (ej. Cline, Cursor, OpenCode, etc.):\n"))
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { writeFileSync, existsSync, mkdirSync, readdirSync } from "fs"
|
|
7
7
|
import { join } from "path"
|
|
8
|
+
import { execSync } from "child_process"
|
|
8
9
|
import chalk from "chalk"
|
|
9
10
|
import inquirer from "inquirer"
|
|
10
11
|
import { getLanguages, getUiStyles, getExtensions } from "../utils/language-loader.js"
|
|
@@ -533,4 +534,39 @@ export async function selectFullStack(options) {
|
|
|
533
534
|
}
|
|
534
535
|
}
|
|
535
536
|
|
|
537
|
+
export async function checkAndInstallOpencode(interactive) {
|
|
538
|
+
if (!interactive) return;
|
|
539
|
+
|
|
540
|
+
let isInstalled = false;
|
|
541
|
+
try {
|
|
542
|
+
execSync("opencode --version", { stdio: "ignore" });
|
|
543
|
+
isInstalled = true;
|
|
544
|
+
} catch (e) {
|
|
545
|
+
isInstalled = false;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
if (!isInstalled) {
|
|
549
|
+
console.log(chalk.yellow("\n⚠️ No se detectó 'opencode' instalado globalmente."));
|
|
550
|
+
console.log(chalk.gray("OpenCode es el agente CLI recomendado para aprovechar la integración MCP de OPL."));
|
|
551
|
+
const { install } = await inquirer.prompt([
|
|
552
|
+
{
|
|
553
|
+
type: "confirm",
|
|
554
|
+
name: "install",
|
|
555
|
+
message: "¿Deseas instalar opencode globalmente ahora? (npm install -g opencode)",
|
|
556
|
+
default: true
|
|
557
|
+
}
|
|
558
|
+
]);
|
|
559
|
+
|
|
560
|
+
if (install) {
|
|
561
|
+
console.log(chalk.cyan("⏳ Instalando opencode..."));
|
|
562
|
+
try {
|
|
563
|
+
execSync("npm install -g opencode", { stdio: "inherit" });
|
|
564
|
+
console.log(chalk.green("✅ opencode instalado exitosamente.\n"));
|
|
565
|
+
} catch (e) {
|
|
566
|
+
console.log(chalk.red("❌ Error instalando opencode. Puedes instalarlo manualmente con: npm install -g opencode\n"));
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
536
572
|
export { generateFrameworkMd }
|
|
@@ -2,6 +2,7 @@ import ts from "typescript"
|
|
|
2
2
|
import fs from "fs"
|
|
3
3
|
import path from "path"
|
|
4
4
|
import Ajv from "ajv"
|
|
5
|
+
import { fileURLToPath } from "url"
|
|
5
6
|
import { analyzeBlastRadius } from "./blast-radius.js"
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -17,7 +18,9 @@ const ajv = new Ajv({ allErrors: true, useDefaults: true })
|
|
|
17
18
|
|
|
18
19
|
let mutateSchema
|
|
19
20
|
try {
|
|
20
|
-
const
|
|
21
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
22
|
+
const __dirname = path.dirname(__filename)
|
|
23
|
+
const schemaPath = path.resolve(__dirname, "../../../schemas/ast_patch_mutate.json")
|
|
21
24
|
const schemaRaw = fs.readFileSync(schemaPath, "utf8")
|
|
22
25
|
mutateSchema = JSON.parse(schemaRaw)
|
|
23
26
|
} catch (e) {
|
|
@@ -2,6 +2,7 @@ import ts from "typescript"
|
|
|
2
2
|
import fs from "fs"
|
|
3
3
|
import path from "path"
|
|
4
4
|
import Ajv from "ajv"
|
|
5
|
+
import { fileURLToPath } from "url"
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @use(
|
|
@@ -16,7 +17,9 @@ const ajv = new Ajv({ allErrors: true, useDefaults: true })
|
|
|
16
17
|
|
|
17
18
|
let blastSchema
|
|
18
19
|
try {
|
|
19
|
-
const
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
21
|
+
const __dirname = path.dirname(__filename)
|
|
22
|
+
const schemaPath = path.resolve(__dirname, "../../../schemas/analyze_blast_radius.json")
|
|
20
23
|
const schemaRaw = fs.readFileSync(schemaPath, "utf8")
|
|
21
24
|
blastSchema = JSON.parse(schemaRaw)
|
|
22
25
|
} catch (e) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Ajv from "ajv"
|
|
2
2
|
import { readFileSync } from "fs"
|
|
3
|
-
import {
|
|
3
|
+
import { fileURLToPath } from "url"
|
|
4
|
+
import { dirname, join } from "path"
|
|
4
5
|
import { spawn } from "child_process"
|
|
5
6
|
import { performance } from "perf_hooks"
|
|
6
7
|
|
|
@@ -17,9 +18,9 @@ const ajv = new Ajv({ allErrors: true, useDefaults: true })
|
|
|
17
18
|
|
|
18
19
|
let sandboxSchema
|
|
19
20
|
try {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const schemaPath = join(
|
|
21
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
22
|
+
const __dirname = dirname(__filename)
|
|
23
|
+
const schemaPath = join(__dirname, "..", "..", "..", "schemas", "execute_sandbox.json")
|
|
23
24
|
const schemaRaw = readFileSync(schemaPath, "utf8")
|
|
24
25
|
sandboxSchema = JSON.parse(schemaRaw)
|
|
25
26
|
} catch (e) {
|
package/src/mcp-plan-server.js
CHANGED
|
@@ -28,7 +28,7 @@ function getServerVersion() {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const SUPPORTED_PROTOCOL_VERSIONS = ["2024-11-05"]
|
|
31
|
+
const SUPPORTED_PROTOCOL_VERSIONS = ["2024-11-05", "1.0", "1.0.0", "0.1.0"]
|
|
32
32
|
const LATEST_PROTOCOL_VERSION = SUPPORTED_PROTOCOL_VERSIONS[0]
|
|
33
33
|
|
|
34
34
|
const SERVER_INFO = {
|
|
@@ -19,7 +19,7 @@ function getServerVersion() {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const SUPPORTED_PROTOCOL_VERSIONS = ["2024-11-05"]
|
|
22
|
+
const SUPPORTED_PROTOCOL_VERSIONS = ["2024-11-05", "1.0", "1.0.0", "0.1.0"]
|
|
23
23
|
const LATEST_PROTOCOL_VERSION = SUPPORTED_PROTOCOL_VERSIONS[0]
|
|
24
24
|
|
|
25
25
|
const SERVER_INFO = {
|