openprompt-lang 1.2.6 → 1.3.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/README.md +62 -8
- package/docs/EMBEDDINGS.md +214 -0
- package/docs/FRAMEWORK.md +52 -0
- package/docs/ONBOARDING_WORKFLOW.md +151 -0
- package/docs/OPL-ERRORES.md +504 -0
- package/docs/OPL_ACADEMIC_ISSUES.md +158 -0
- package/docs/WEB_SCRAPER_PLAN.md +454 -0
- package/package.json +7 -1
- package/scripts/postinstall.js +37 -0
- package/src/cli/commands-knowledge.js +1 -0
- package/src/cli/commands-opl.js +79 -1
- package/src/cli/commands-work.js +3 -1
- package/src/cli/commands-workflow.js +125 -6
- package/src/commands/init-core.js +188 -12
- package/src/commands/init-existing.js +13 -6
- package/src/commands/init-helpers.js +20 -14
- package/src/commands/knowledge-ops.js +52 -0
- package/src/commands/opl-embeddings.js +556 -0
- package/src/commands/opl-help.js +26 -2
- package/src/commands/opl-search.js +106 -2
- package/src/commands/opl-webscrape.js +390 -0
- package/src/commands/work-context.js +17 -0
- package/src/commands/workflow/close/index.js +2 -1
- package/src/commands/workflow/delivery/index.js +4 -0
- package/src/commands/workflow/discovery/index.js +4 -0
- package/src/commands/workflow/epic-cli.js +192 -0
- package/src/commands/workflow/select.js +146 -0
- package/src/commands/workflow/specification/index.js +4 -0
- package/src/commands/workflow/sprint-cli.js +174 -0
- package/src/core/engine/sandbox.js +7 -3
- package/src/core/webscrape/analyzer.js +481 -0
- package/src/core/webscrape/deep-scraper.js +1027 -0
- package/src/core/workflow/epic-manager.js +845 -0
- package/src/core/workflow/gates.js +180 -1
- package/src/core/workflow/selector.js +707 -0
- package/src/embeddings/chunker.js +450 -0
- package/src/embeddings/embedder.js +431 -0
- package/src/embeddings/index-pipeline.js +320 -0
- package/src/embeddings/vector-store.js +505 -0
- package/src/mcp-plan-server.js +12 -5
- package/src/mcp-shared-state.js +25 -0
- package/src/mcp-refactor/mcp-server.js +0 -171
- package/src/mcp-server-backup.js +0 -1913
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { readFileSync, existsSync, rmSync, writeFileSync, mkdirSync } from "fs"
|
|
4
|
-
import { join, dirname } from "path"
|
|
5
|
-
import { fileURLToPath } from "url"
|
|
6
|
-
import { TOOLS } from "./tools.js"
|
|
7
|
-
import { handleToolCall } from "./router.js"
|
|
8
|
-
import { generateRichInstructions } from "../mcp-workflow.js"
|
|
9
|
-
|
|
10
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
11
|
-
const __dirname = dirname(__filename)
|
|
12
|
-
|
|
13
|
-
function getServerVersion() {
|
|
14
|
-
try {
|
|
15
|
-
const pkg = JSON.parse(readFileSync(join(__dirname, "../..", "package.json"), "utf-8"))
|
|
16
|
-
return pkg.version || "0.9.0"
|
|
17
|
-
} catch {
|
|
18
|
-
return "0.9.0"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const SUPPORTED_PROTOCOL_VERSIONS = ["2024-11-05", "1.0", "1.0.0", "0.1.0"]
|
|
23
|
-
const LATEST_PROTOCOL_VERSION = SUPPORTED_PROTOCOL_VERSIONS[0]
|
|
24
|
-
|
|
25
|
-
const SERVER_INFO = {
|
|
26
|
-
name: "OPL",
|
|
27
|
-
version: getServerVersion(),
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function sendMessage(msg) {
|
|
31
|
-
const data = JSON.stringify(msg)
|
|
32
|
-
process.stdout.write(`${data}\n`)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function sendError(id, code, message) {
|
|
36
|
-
sendMessage({ jsonrpc: "2.0", id, error: { code, message } })
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function sendResult(id, result) {
|
|
40
|
-
sendMessage({ jsonrpc: "2.0", id, result })
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function startServer() {
|
|
44
|
-
// PID lock: evitar servidores duplicados
|
|
45
|
-
const PID_PATH = join(process.cwd(), ".opencode", "mcp.pid")
|
|
46
|
-
try {
|
|
47
|
-
if (existsSync(PID_PATH)) {
|
|
48
|
-
const oldPid = readFileSync(PID_PATH, "utf-8").trim()
|
|
49
|
-
try {
|
|
50
|
-
process.kill(parseInt(oldPid), 0)
|
|
51
|
-
console.error("[mcp] ⚠ Ya hay un servidor MCP activo (PID " + oldPid + "). Saliendo.")
|
|
52
|
-
process.exit(1)
|
|
53
|
-
} catch {
|
|
54
|
-
/* PID huérfano, continuar */
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
mkdirSync(dirname(PID_PATH), { recursive: true })
|
|
58
|
-
writeFileSync(PID_PATH, String(process.pid))
|
|
59
|
-
} catch {
|
|
60
|
-
/* fallback: continuar sin PID lock */
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Graceful shutdown: limpiar PID file y conexiones
|
|
64
|
-
function cleanupAndExit() {
|
|
65
|
-
try {
|
|
66
|
-
if (existsSync(PID_PATH)) rmSync(PID_PATH)
|
|
67
|
-
} catch {
|
|
68
|
-
/* ignore */
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
import("../persistence/sqlite/connection.js").then((m) => m.close())
|
|
72
|
-
} catch {
|
|
73
|
-
/* ignore */
|
|
74
|
-
}
|
|
75
|
-
process.exit(0)
|
|
76
|
-
}
|
|
77
|
-
process.on("SIGTERM", cleanupAndExit)
|
|
78
|
-
process.on("SIGINT", cleanupAndExit)
|
|
79
|
-
|
|
80
|
-
let buffer = ""
|
|
81
|
-
|
|
82
|
-
process.stdin.setEncoding("utf-8")
|
|
83
|
-
process.stdin.on("data", async (chunk) => {
|
|
84
|
-
buffer += chunk
|
|
85
|
-
const lines = buffer.split("\n")
|
|
86
|
-
buffer = lines.pop() || ""
|
|
87
|
-
|
|
88
|
-
for (const line of lines) {
|
|
89
|
-
const trimmed = line.trim()
|
|
90
|
-
if (!trimmed) continue
|
|
91
|
-
|
|
92
|
-
let msg
|
|
93
|
-
try {
|
|
94
|
-
msg = JSON.parse(trimmed)
|
|
95
|
-
} catch {
|
|
96
|
-
continue
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (msg.jsonrpc !== "2.0") continue
|
|
100
|
-
|
|
101
|
-
const { id, method, params } = msg
|
|
102
|
-
|
|
103
|
-
const isNotification = id === undefined || id === null
|
|
104
|
-
|
|
105
|
-
switch (method) {
|
|
106
|
-
case "initialize": {
|
|
107
|
-
const clientVersion = params?.protocolVersion
|
|
108
|
-
const clientSupportsLatest =
|
|
109
|
-
clientVersion && SUPPORTED_PROTOCOL_VERSIONS.includes(clientVersion)
|
|
110
|
-
const negotiatedVersion = clientSupportsLatest ? clientVersion : LATEST_PROTOCOL_VERSION
|
|
111
|
-
|
|
112
|
-
// Generate rich dynamic instructions based on project context
|
|
113
|
-
const instructions = generateRichInstructions()
|
|
114
|
-
|
|
115
|
-
sendResult(id, {
|
|
116
|
-
protocolVersion: negotiatedVersion,
|
|
117
|
-
capabilities: {
|
|
118
|
-
tools: { listChanged: false },
|
|
119
|
-
logging: {},
|
|
120
|
-
},
|
|
121
|
-
serverInfo: SERVER_INFO,
|
|
122
|
-
instructions,
|
|
123
|
-
})
|
|
124
|
-
break
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
case "notifications/initialized": {
|
|
128
|
-
break
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
case "tools/list": {
|
|
132
|
-
sendResult(id, { tools: TOOLS })
|
|
133
|
-
break
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
case "tools/call": {
|
|
137
|
-
try {
|
|
138
|
-
const toolName = params?.name
|
|
139
|
-
const toolArgs = params?.arguments || {}
|
|
140
|
-
const result = await handleToolCall(toolName, toolArgs)
|
|
141
|
-
sendResult(id, result)
|
|
142
|
-
} catch (err) {
|
|
143
|
-
sendError(id, -32603, err.message)
|
|
144
|
-
}
|
|
145
|
-
break
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
case "ping": {
|
|
149
|
-
sendResult(id, {})
|
|
150
|
-
break
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
default: {
|
|
154
|
-
if (!isNotification) {
|
|
155
|
-
sendError(id, -32601, `Method not found: ${method}`)
|
|
156
|
-
}
|
|
157
|
-
break
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
process.stdin.on("end", () => {
|
|
164
|
-
cleanupAndExit()
|
|
165
|
-
})
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// Start if main module
|
|
169
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
170
|
-
startServer()
|
|
171
|
-
}
|