oxe-cc 0.9.1 → 0.9.3
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/.cursor/commands/oxe-retro.md +2 -2
- package/.cursor/commands/oxe-spec.md +2 -2
- package/.github/prompts/oxe-retro.prompt.md +2 -2
- package/.github/prompts/oxe-spec.prompt.md +2 -2
- package/README.md +1 -1
- package/bin/banner.txt +1 -1
- package/bin/lib/oxe-context-engine.cjs +1 -0
- package/bin/oxe-cc.js +61 -0
- package/commands/oxe/retro.md +2 -2
- package/commands/oxe/spec.md +2 -2
- package/oxe/templates/LESSONS-METRICS.template.json +13 -0
- package/oxe/workflows/references/robustness-elevation.md +295 -0
- package/oxe/workflows/references/workflow-runtime-contracts.json +32 -4
- package/oxe/workflows/retro.md +21 -0
- package/oxe/workflows/spec.md +50 -26
- package/oxe/workflows/verify.md +36 -0
- package/package.json +4 -2
- package/vscode-extension/.vscodeignore +7 -0
- package/vscode-extension/oxe-agents-0.9.1.vsix +0 -0
- package/vscode-extension/oxe-agents-0.9.2.vsix +0 -0
- package/vscode-extension/package.json +185 -0
- package/vscode-extension/src/extension.js +310 -0
- package/vscode-extension/src/shared/contextLoader.js +137 -0
- package/vscode-extension/src/shared/contractBuilder.js +159 -0
- package/vscode-extension/src/shared/stateReader.js +101 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Retorna o caminho raiz do primeiro workspace folder, ou null.
|
|
8
|
+
* @param {readonly import('vscode').WorkspaceFolder[] | undefined} folders
|
|
9
|
+
* @returns {string | null}
|
|
10
|
+
*/
|
|
11
|
+
function getProjectRoot(folders) {
|
|
12
|
+
if (!folders || folders.length === 0) return null;
|
|
13
|
+
return folders[0].uri.fsPath;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Verifica se o projeto tem estrutura OXE inicializada.
|
|
18
|
+
* @param {string} projectRoot
|
|
19
|
+
* @returns {boolean}
|
|
20
|
+
*/
|
|
21
|
+
function hasOxe(projectRoot) {
|
|
22
|
+
try {
|
|
23
|
+
return fs.existsSync(path.join(projectRoot, '.oxe', 'STATE.md'));
|
|
24
|
+
} catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Lê o conteúdo de STATE.md, retorna string vazia se ausente.
|
|
31
|
+
* @param {string} projectRoot
|
|
32
|
+
* @returns {string}
|
|
33
|
+
*/
|
|
34
|
+
function readState(projectRoot) {
|
|
35
|
+
try {
|
|
36
|
+
const statePath = path.join(projectRoot, '.oxe', 'STATE.md');
|
|
37
|
+
return fs.existsSync(statePath) ? fs.readFileSync(statePath, 'utf8') : '';
|
|
38
|
+
} catch {
|
|
39
|
+
return '';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Extrai a fase atual do STATE.md (padrão: backtick ou campo `fase_atual:`).
|
|
45
|
+
* @param {string} stateText
|
|
46
|
+
* @returns {string | null}
|
|
47
|
+
*/
|
|
48
|
+
function parsePhase(stateText) {
|
|
49
|
+
// Padrão OXE: ## Fase atual \n\n `scan_complete`
|
|
50
|
+
const backtickMatch = stateText.match(/##\s*Fase\s*atual[\s\S]*?`([^`]+)`/im);
|
|
51
|
+
if (backtickMatch) return backtickMatch[1].trim();
|
|
52
|
+
// Fallback: fase_atual: valor
|
|
53
|
+
const fieldMatch = stateText.match(/fase_atual:\s*([^\n]+)/i);
|
|
54
|
+
return fieldMatch ? fieldMatch[1].trim() : null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Extrai a sessão ativa do STATE.md.
|
|
59
|
+
* @param {string} stateText
|
|
60
|
+
* @returns {string | null}
|
|
61
|
+
*/
|
|
62
|
+
function parseActiveSession(stateText) {
|
|
63
|
+
const m = stateText.match(/active_session:\s*([^\n]+)/i);
|
|
64
|
+
if (!m) return null;
|
|
65
|
+
const val = m[1].trim().replace(/["'`]/g, '');
|
|
66
|
+
return val === 'null' || val === '' ? null : val;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Extrai próximo passo recomendado do STATE.md.
|
|
71
|
+
* @param {string} stateText
|
|
72
|
+
* @returns {string | null}
|
|
73
|
+
*/
|
|
74
|
+
function parseNextStep(stateText) {
|
|
75
|
+
const m = stateText.match(/próximo[_\s]passo:\s*([^\n]+)/i)
|
|
76
|
+
|| stateText.match(/next[_\s]step:\s*([^\n]+)/i);
|
|
77
|
+
return m ? m[1].trim().replace(/["'`]/g, '') : null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Retorna um resumo compacto do estado do projeto para o system prompt.
|
|
82
|
+
* @param {string} projectRoot
|
|
83
|
+
* @returns {{ text: string, phase: string | null, session: string | null, nextStep: string | null }}
|
|
84
|
+
*/
|
|
85
|
+
function getProjectContext(projectRoot) {
|
|
86
|
+
const text = readState(projectRoot);
|
|
87
|
+
const phase = parsePhase(text);
|
|
88
|
+
const session = parseActiveSession(text);
|
|
89
|
+
const nextStep = parseNextStep(text);
|
|
90
|
+
return { text: text.slice(0, 800), phase, session, nextStep };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
module.exports = {
|
|
94
|
+
getProjectRoot,
|
|
95
|
+
hasOxe,
|
|
96
|
+
readState,
|
|
97
|
+
parsePhase,
|
|
98
|
+
parseActiveSession,
|
|
99
|
+
parseNextStep,
|
|
100
|
+
getProjectContext,
|
|
101
|
+
};
|