oxe-cc 1.22.0 → 1.22.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.
Files changed (145) hide show
  1. package/.cursor/commands/oxe-discuss.md +45 -45
  2. package/.cursor/commands/oxe-execute.md +52 -52
  3. package/.cursor/commands/oxe-help.md +44 -44
  4. package/.cursor/commands/oxe-next.md +44 -44
  5. package/.cursor/commands/oxe-plan.md +49 -49
  6. package/.cursor/commands/oxe-quick.md +49 -49
  7. package/.cursor/commands/oxe-review-pr.md +47 -47
  8. package/.cursor/commands/oxe-scan.md +47 -47
  9. package/.cursor/commands/oxe-ship.md +47 -47
  10. package/.cursor/commands/oxe-spec.md +49 -49
  11. package/.cursor/commands/oxe-verify.md +50 -50
  12. package/.cursor/commands/oxe.md +51 -51
  13. package/.github/prompts/oxe-alm.prompt.md +47 -47
  14. package/.github/prompts/oxe-ask.prompt.md +47 -47
  15. package/.github/prompts/oxe-capabilities.prompt.md +47 -47
  16. package/.github/prompts/oxe-checkpoint.prompt.md +47 -47
  17. package/.github/prompts/oxe-compact.prompt.md +46 -46
  18. package/.github/prompts/oxe-dashboard.prompt.md +47 -47
  19. package/.github/prompts/oxe-debug.prompt.md +47 -47
  20. package/.github/prompts/oxe-discuss.prompt.md +47 -47
  21. package/.github/prompts/oxe-execute.prompt.md +52 -52
  22. package/.github/prompts/oxe-forensics.prompt.md +47 -47
  23. package/.github/prompts/oxe-help.prompt.md +46 -46
  24. package/.github/prompts/oxe-loop.prompt.md +47 -47
  25. package/.github/prompts/oxe-milestone.prompt.md +47 -47
  26. package/.github/prompts/oxe-next.prompt.md +46 -46
  27. package/.github/prompts/oxe-obs.prompt.md +47 -47
  28. package/.github/prompts/oxe-plan-agent.prompt.md +46 -46
  29. package/.github/prompts/oxe-plan.prompt.md +49 -49
  30. package/.github/prompts/oxe-project.prompt.md +47 -47
  31. package/.github/prompts/oxe-quick.prompt.md +49 -49
  32. package/.github/prompts/oxe-research.prompt.md +47 -47
  33. package/.github/prompts/oxe-retro.prompt.md +47 -47
  34. package/.github/prompts/oxe-review-pr.prompt.md +47 -47
  35. package/.github/prompts/oxe-route.prompt.md +47 -47
  36. package/.github/prompts/oxe-scan.prompt.md +47 -47
  37. package/.github/prompts/oxe-security.prompt.md +47 -47
  38. package/.github/prompts/oxe-session.prompt.md +47 -47
  39. package/.github/prompts/oxe-ship.prompt.md +47 -47
  40. package/.github/prompts/oxe-skill.prompt.md +47 -47
  41. package/.github/prompts/oxe-spec.prompt.md +49 -49
  42. package/.github/prompts/oxe-ui-review.prompt.md +47 -47
  43. package/.github/prompts/oxe-ui-spec.prompt.md +47 -47
  44. package/.github/prompts/oxe-update.prompt.md +46 -46
  45. package/.github/prompts/oxe-validate-gaps.prompt.md +47 -47
  46. package/.github/prompts/oxe-verify.prompt.md +50 -50
  47. package/.github/prompts/oxe-workstream.prompt.md +47 -47
  48. package/.github/prompts/oxe.prompt.md +51 -51
  49. package/.github/workflows/release.yml +31 -0
  50. package/CHANGELOG.md +88 -0
  51. package/README.md +1 -1
  52. package/bin/lib/commands/ops-commands.cjs +751 -0
  53. package/bin/lib/commands/spec-program-commands.cjs +337 -0
  54. package/bin/lib/operational/alm-refine-runtime.cjs +791 -0
  55. package/bin/lib/operational/child-env.cjs +52 -0
  56. package/bin/lib/operational/promote-runtime.cjs +1187 -0
  57. package/bin/lib/oxe-agent-coord.cjs +246 -0
  58. package/bin/lib/oxe-alm-refine.cjs +97 -1
  59. package/bin/lib/oxe-ci-adapter.cjs +304 -0
  60. package/bin/lib/oxe-complexity.cjs +1 -1
  61. package/bin/lib/oxe-decisions.cjs +9 -3
  62. package/bin/lib/oxe-dir-info.cjs +20 -1
  63. package/bin/lib/oxe-env-sanitize.cjs +6 -1
  64. package/bin/lib/oxe-git-root.cjs +97 -0
  65. package/bin/lib/oxe-grill.cjs +90 -1
  66. package/bin/lib/oxe-onboard.cjs +640 -0
  67. package/bin/lib/oxe-operational.cjs +14481 -15949
  68. package/bin/lib/oxe-origin.cjs +4 -1
  69. package/bin/lib/oxe-phase-gates.cjs +139 -2
  70. package/bin/lib/oxe-plan-build.cjs +62 -2
  71. package/bin/lib/oxe-plan-mutate.cjs +108 -2
  72. package/bin/lib/oxe-preflight.cjs +9 -3
  73. package/bin/lib/oxe-presets.cjs +216 -0
  74. package/bin/lib/oxe-project-env.cjs +79 -0
  75. package/bin/lib/oxe-project-health.cjs +2 -0
  76. package/bin/lib/oxe-reevaluate.cjs +198 -0
  77. package/bin/lib/oxe-release-ops.cjs +51 -15
  78. package/bin/lib/oxe-scorecard.cjs +394 -1
  79. package/bin/lib/oxe-ship-pr.cjs +72 -4
  80. package/bin/lib/oxe-spec-check.cjs +32 -0
  81. package/bin/lib/oxe-suite-impact.cjs +1160 -1145
  82. package/bin/lib/oxe-sync.cjs +99 -2
  83. package/bin/lib/oxe-verify-cache.cjs +132 -0
  84. package/bin/lib/oxe-vitest-batch.cjs +10 -3
  85. package/bin/lib/oxe-worktree-gc.cjs +655 -170
  86. package/bin/oxe-cc.js +10042 -10669
  87. package/commands/oxe/alm.md +54 -54
  88. package/commands/oxe/ask.md +55 -55
  89. package/commands/oxe/capabilities.md +50 -50
  90. package/commands/oxe/checkpoint.md +53 -53
  91. package/commands/oxe/compact.md +47 -47
  92. package/commands/oxe/dashboard.md +51 -51
  93. package/commands/oxe/debug.md +58 -58
  94. package/commands/oxe/discuss.md +58 -58
  95. package/commands/oxe/execute.md +63 -63
  96. package/commands/oxe/forensics.md +53 -53
  97. package/commands/oxe/help.md +48 -48
  98. package/commands/oxe/loop.md +54 -54
  99. package/commands/oxe/milestone.md +53 -53
  100. package/commands/oxe/next.md +49 -49
  101. package/commands/oxe/obs.md +53 -53
  102. package/commands/oxe/oxe.md +55 -55
  103. package/commands/oxe/plan-agent.md +57 -57
  104. package/commands/oxe/plan.md +59 -59
  105. package/commands/oxe/project.md +53 -53
  106. package/commands/oxe/quick.md +53 -53
  107. package/commands/oxe/research.md +53 -53
  108. package/commands/oxe/retro.md +53 -53
  109. package/commands/oxe/review-pr.md +53 -53
  110. package/commands/oxe/route.md +48 -48
  111. package/commands/oxe/scan.md +58 -58
  112. package/commands/oxe/security.md +53 -53
  113. package/commands/oxe/session.md +53 -53
  114. package/commands/oxe/ship.md +53 -53
  115. package/commands/oxe/skill.md +53 -53
  116. package/commands/oxe/spec.md +59 -59
  117. package/commands/oxe/ui-review.md +53 -53
  118. package/commands/oxe/ui-spec.md +53 -53
  119. package/commands/oxe/update.md +53 -53
  120. package/commands/oxe/validate-gaps.md +53 -53
  121. package/commands/oxe/verify-audit.md +50 -50
  122. package/commands/oxe/verify.md +60 -60
  123. package/commands/oxe/workflow-authoring.md +50 -50
  124. package/commands/oxe/workstream.md +53 -53
  125. package/docs/RELEASE-READINESS.md +7 -1
  126. package/docs/adr/D-1-isolamento-read-only-e-sanitizacao-centralizada-de-env-vars.md +29 -29
  127. package/docs/adr/D-2-junction-segura-de-node-modules-condicionada-a-sha-256-de-pa.md +29 -29
  128. package/docs/adr/D-3-preflight-local-5s-impacto-estatico-e2e-e-leitura-explicita.md +29 -29
  129. package/docs/adr/D-4-governanca-de-release-unificada-retomada-idempotente-pos-rei.md +29 -29
  130. package/docs/adr/D-5-core-agnostico-vs-presets-declarativos-de-dominio.md +29 -0
  131. package/docs/adr/D-6-decomposicao-strangler-fig-de-oxe-cc-e-oxe-operational.md +29 -0
  132. package/docs/adr/D-7-paridade-pre-push-com-phase-gates-path-aware-json-compacto-e.md +28 -0
  133. package/docs/adr/D-F1F4-1-paridade-pre-push-compactacao-json-sync-version-pins-e-quali.md +44 -0
  134. package/docs/adr/README.md +18 -14
  135. package/lib/runtime/verification/verification-compiler.d.ts +12 -1
  136. package/lib/runtime/verification/verification-compiler.js +235 -65
  137. package/oxe/templates/CONFIG.md +14 -1
  138. package/oxe/workflows/help.md +3 -0
  139. package/oxe/workflows/lean/execute.md +2 -1
  140. package/oxe/workflows/ship.md +4 -2
  141. package/package.json +4 -4
  142. package/packages/runtime/package.json +1 -1
  143. package/packages/runtime/src/verification/verification-compiler.ts +193 -25
  144. package/packages/runtime/tsconfig.json +1 -0
  145. package/vscode-extension/package.json +1 -1
@@ -0,0 +1,216 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * 1.22.1 (OXB-221-04): Declarative project presets (`cli`, `web`, `desktop-mobile`, `brand-strict`).
5
+ * Separates the agnostic OXE core from optional domain defaults.
6
+ * Precedence: explicit keys in `.oxe/config.json` > explicit keys in `oxe.config.json` > preset(s) in order > agnostic default.
7
+ */
8
+
9
+ const fs = require('node:fs');
10
+ const path = require('node:path');
11
+
12
+ const AGNOSTIC_DEFAULTS = Object.freeze({
13
+ ui: {
14
+ brandGate: false,
15
+ },
16
+ ship: {
17
+ requiredCommitStatuses: [],
18
+ },
19
+ preflight: {
20
+ cssTargetsDir: null,
21
+ },
22
+ verify: {
23
+ noBatchPatterns: [],
24
+ },
25
+ envSanitize: {
26
+ stripEnvPrefixes: [],
27
+ },
28
+ release: {
29
+ expectedAssets: [],
30
+ },
31
+ });
32
+
33
+ const PRESETS = Object.freeze({
34
+ cli: Object.freeze({
35
+ ui: { brandGate: false },
36
+ ship: { requiredCommitStatuses: [] },
37
+ preflight: { cssTargetsDir: null },
38
+ verify: { noBatchPatterns: [] },
39
+ envSanitize: { stripEnvPrefixes: [] },
40
+ release: {
41
+ expectedAssets: [],
42
+ },
43
+ }),
44
+ web: Object.freeze({
45
+ ui: { brandGate: false },
46
+ ship: { requiredCommitStatuses: [] },
47
+ preflight: { cssTargetsDir: null },
48
+ verify: { noBatchPatterns: [] },
49
+ envSanitize: { stripEnvPrefixes: [] },
50
+ release: {
51
+ expectedAssets: [],
52
+ },
53
+ }),
54
+ 'desktop-mobile': Object.freeze({
55
+ ui: { brandGate: false },
56
+ ship: { requiredCommitStatuses: [] },
57
+ preflight: { cssTargetsDir: null },
58
+ verify: { noBatchPatterns: ['gradle152'] },
59
+ envSanitize: { stripEnvPrefixes: ['OXESPACE_', 'AI_MEMORY_'] },
60
+ release: {
61
+ expectedAssets: [
62
+ { label: 'Desktop installer (.exe/.dmg/.AppImage/.deb)', patterns: ['*.exe', '*.dmg', '*.AppImage', '*.deb', '*.msi'] },
63
+ { label: 'Android APK (.apk)', patterns: ['*.apk'] },
64
+ { label: 'Checksums (SHA256SUMS / checksums)', patterns: ['*checksum*', '*sha256*'] },
65
+ ],
66
+ },
67
+ }),
68
+ 'brand-strict': Object.freeze({
69
+ ui: { brandGate: true },
70
+ ship: { requiredCommitStatuses: ['marca/conformidade'] },
71
+ preflight: { cssTargetsDir: 'src/design/targets' },
72
+ verify: { noBatchPatterns: [] },
73
+ envSanitize: { stripEnvPrefixes: [] },
74
+ release: {
75
+ expectedAssets: [],
76
+ },
77
+ }),
78
+ });
79
+
80
+ const PRESET_NAMES = Object.freeze(Object.keys(PRESETS));
81
+
82
+ function readJsonQuiet(file) {
83
+ try {
84
+ return fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : null;
85
+ } catch {
86
+ return null;
87
+ }
88
+ }
89
+
90
+ function readRawConfig(rootOrCfg) {
91
+ if (!rootOrCfg) return {};
92
+ if (typeof rootOrCfg === 'string') {
93
+ const base = readJsonQuiet(path.join(rootOrCfg, 'oxe.config.json'));
94
+ const local = readJsonQuiet(path.join(rootOrCfg, '.oxe', 'config.json'));
95
+ if (base && typeof base === 'object' && local && typeof local === 'object') return { ...base, ...local };
96
+ return (local && typeof local === 'object' ? local : (base && typeof base === 'object' ? base : {}));
97
+ }
98
+ return typeof rootOrCfg === 'object' ? rootOrCfg : {};
99
+ }
100
+
101
+ function cloneValue(val) {
102
+ if (Array.isArray(val)) return val.map(cloneValue);
103
+ if (val && typeof val === 'object') {
104
+ const out = {};
105
+ for (const [k, v] of Object.entries(val)) out[k] = cloneValue(v);
106
+ return out;
107
+ }
108
+ return val;
109
+ }
110
+
111
+ function mergePresetLayer(acc, layer) {
112
+ if (!layer || typeof layer !== 'object') return acc;
113
+ if (layer.ui && typeof layer.ui === 'object') {
114
+ if (layer.ui.brandGate === true) acc.ui.brandGate = true;
115
+ }
116
+ if (layer.ship && Array.isArray(layer.ship.requiredCommitStatuses)) {
117
+ acc.ship.requiredCommitStatuses = [...new Set([...acc.ship.requiredCommitStatuses, ...layer.ship.requiredCommitStatuses])];
118
+ }
119
+ if (layer.preflight && layer.preflight.cssTargetsDir) {
120
+ acc.preflight.cssTargetsDir = layer.preflight.cssTargetsDir;
121
+ }
122
+ if (layer.verify && Array.isArray(layer.verify.noBatchPatterns)) {
123
+ acc.verify.noBatchPatterns = [...new Set([...acc.verify.noBatchPatterns, ...layer.verify.noBatchPatterns])];
124
+ }
125
+ if (layer.envSanitize && Array.isArray(layer.envSanitize.stripEnvPrefixes)) {
126
+ acc.envSanitize.stripEnvPrefixes = [...new Set([...acc.envSanitize.stripEnvPrefixes, ...layer.envSanitize.stripEnvPrefixes])];
127
+ }
128
+ if (layer.release && Array.isArray(layer.release.expectedAssets) && layer.release.expectedAssets.length) {
129
+ acc.release.expectedAssets = cloneValue(layer.release.expectedAssets);
130
+ }
131
+ return acc;
132
+ }
133
+
134
+ function applyExplicitOverrides(acc, cfg) {
135
+ if (!cfg || typeof cfg !== 'object') return acc;
136
+ if (cfg.ui && typeof cfg.ui === 'object' && typeof cfg.ui.brandGate === 'boolean') {
137
+ acc.ui.brandGate = cfg.ui.brandGate;
138
+ }
139
+ if (cfg.ship && typeof cfg.ship === 'object' && Array.isArray(cfg.ship.requiredCommitStatuses)) {
140
+ acc.ship.requiredCommitStatuses = cloneValue(cfg.ship.requiredCommitStatuses);
141
+ }
142
+ if (cfg.preflight && typeof cfg.preflight === 'object' && Object.prototype.hasOwnProperty.call(cfg.preflight, 'cssTargetsDir')) {
143
+ acc.preflight.cssTargetsDir = cfg.preflight.cssTargetsDir;
144
+ }
145
+ if (cfg.verify && typeof cfg.verify === 'object' && Array.isArray(cfg.verify.noBatchPatterns)) {
146
+ acc.verify.noBatchPatterns = cloneValue(cfg.verify.noBatchPatterns);
147
+ }
148
+ if (cfg.envSanitize && typeof cfg.envSanitize === 'object' && Array.isArray(cfg.envSanitize.stripEnvPrefixes)) {
149
+ acc.envSanitize.stripEnvPrefixes = cloneValue(cfg.envSanitize.stripEnvPrefixes);
150
+ }
151
+ if (Array.isArray(cfg.stripEnvPrefixes)) {
152
+ acc.envSanitize.stripEnvPrefixes = cloneValue(cfg.stripEnvPrefixes);
153
+ }
154
+ if (cfg.release && typeof cfg.release === 'object' && Array.isArray(cfg.release.expectedAssets)) {
155
+ acc.release.expectedAssets = cloneValue(cfg.release.expectedAssets);
156
+ }
157
+ return acc;
158
+ }
159
+
160
+ /**
161
+ * Resolves effective preset policies for a project root or raw config object.
162
+ * @param {string|object|null} rootOrCfg
163
+ */
164
+ function resolvePresetConfig(rootOrCfg) {
165
+ const cfg = readRawConfig(rootOrCfg);
166
+ const requested = [];
167
+ if (typeof cfg.preset === 'string' && cfg.preset.trim()) requested.push(cfg.preset.trim());
168
+ if (Array.isArray(cfg.presets)) {
169
+ for (const p of cfg.presets) {
170
+ if (typeof p === 'string' && p.trim()) requested.push(p.trim());
171
+ }
172
+ }
173
+ const uniqueRequested = [...new Set(requested)];
174
+ const appliedPresets = [];
175
+ const warnings = [];
176
+ const acc = cloneValue(AGNOSTIC_DEFAULTS);
177
+
178
+ for (const name of uniqueRequested) {
179
+ if (Object.prototype.hasOwnProperty.call(PRESETS, name)) {
180
+ mergePresetLayer(acc, PRESETS[name]);
181
+ appliedPresets.push(name);
182
+ } else {
183
+ warnings.push(`preset desconhecido "${name}" (use: ${PRESET_NAMES.join(', ')})`);
184
+ }
185
+ }
186
+
187
+ applyExplicitOverrides(acc, cfg);
188
+ return {
189
+ ...acc,
190
+ appliedPresets,
191
+ hasExplicitPreset: uniqueRequested.length > 0,
192
+ warnings,
193
+ };
194
+ }
195
+
196
+ /** Merges resolved preset defaults under explicit config keys without mutating the input object. */
197
+ function mergePresetIntoConfig(cfg) {
198
+ const base = cfg && typeof cfg === 'object' ? cfg : {};
199
+ const resolved = resolvePresetConfig(base);
200
+ return {
201
+ ...base,
202
+ ui: { ...resolved.ui, ...(base.ui && typeof base.ui === 'object' ? base.ui : {}) },
203
+ ship: { ...resolved.ship, ...(base.ship && typeof base.ship === 'object' ? base.ship : {}) },
204
+ preflight: { ...resolved.preflight, ...(base.preflight && typeof base.preflight === 'object' ? base.preflight : {}) },
205
+ verify: { ...resolved.verify, ...(base.verify && typeof base.verify === 'object' ? base.verify : {}) },
206
+ release: { ...resolved.release, ...(base.release && typeof base.release === 'object' ? base.release : {}) },
207
+ };
208
+ }
209
+
210
+ module.exports = {
211
+ AGNOSTIC_DEFAULTS,
212
+ PRESETS,
213
+ PRESET_NAMES,
214
+ resolvePresetConfig,
215
+ mergePresetIntoConfig,
216
+ };
@@ -260,11 +260,90 @@ function checkProjectEnvironment(projectRoot, machine = {}) {
260
260
  } catch {
261
261
  scrubbedEnv = [];
262
262
  }
263
+
264
+ // OXB-222-09: warn (non-blocking) when host shell variables match configured stripEnvPrefixes.
265
+ const leakedEnv = [];
266
+ try {
267
+ const envSanitize = require('./oxe-env-sanitize.cjs');
268
+ const pol = envSanitize.resolveEnvSanitizeConfig(projectRoot);
269
+ if (pol && pol.enabled && Array.isArray(pol.prefixes) && pol.prefixes.length) {
270
+ const allowSet = new Set(pol.allow || []);
271
+ const allowLower = new Set((pol.allow || []).map((a) => String(a).toLowerCase()));
272
+ const envObj = machine.env || process.env;
273
+ for (const [key, value] of Object.entries(envObj || {})) {
274
+ if (value === undefined) continue;
275
+ if (allowSet.has(key) || (process.platform === 'win32' && allowLower.has(key.toLowerCase()))) continue;
276
+ const upper = key.toUpperCase();
277
+ if (pol.prefixes.some((p) => upper.startsWith(String(p).toUpperCase()))) {
278
+ leakedEnv.push(key);
279
+ }
280
+ }
281
+ leakedEnv.sort();
282
+ if (leakedEnv.length) {
283
+ warnings.push(
284
+ `variável(is) de ambiente coincidem com stripEnvPrefixes (${leakedEnv.slice(0, 6).join(', ')}${leakedEnv.length > 6 ? '…' : ''}) — o runtime sanitiza subprocessos, mas comandos manuais fora do runtime podem herdar esse contexto; limpe o shell ou revise stripEnvPrefixes`,
285
+ );
286
+ }
287
+ }
288
+ } catch {
289
+ // optional helper
290
+ }
291
+
292
+ // OXB-222-13: non-blocking worktree hygiene check (read-only; opt-out via worktree.hygiene: false).
293
+ let worktrees = null;
294
+ try {
295
+ const rootCfg = readJson(path.join(projectRoot, 'oxe.config.json')) || {};
296
+ const mergedCfg = { ...rootCfg, ...(oxeConfig || {}) };
297
+ const wtCfg = mergedCfg.worktree && typeof mergedCfg.worktree === 'object' ? mergedCfg.worktree : {};
298
+ if (wtCfg.hygiene !== false && machine.worktrees !== false) {
299
+ const wtGc = require('./oxe-worktree-gc.cjs');
300
+ if (typeof wtGc.summarizeWorktreeHygiene === 'function') {
301
+ worktrees = wtGc.summarizeWorktreeHygiene(projectRoot, {
302
+ warnAbove: wtCfg.warn_above,
303
+ spawn: machine.spawn,
304
+ });
305
+ if (worktrees && worktrees.needs_gc) {
306
+ const parts = [`${worktrees.secondary} worktree(s) secundária(s)`];
307
+ if (worktrees.clean_merged) parts.push(`${worktrees.clean_merged} mergeada(s) limpa(s)`);
308
+ if (worktrees.prunable) parts.push(`${worktrees.prunable} órfã(s)/prunable`);
309
+ if (worktrees.nested_agent) parts.push(`${worktrees.nested_agent} aninhada(s) de agente`);
310
+ if (worktrees.with_real_node_modules) parts.push(`${worktrees.with_real_node_modules} com node_modules próprio`);
311
+ if (worktrees.protected_junction_targets) parts.push(`${worktrees.protected_junction_targets} protegida(s) por junction ativa`);
312
+ const cmd = worktrees.nested_agent > 0
313
+ ? 'oxe-cc gc-worktrees --merged --include-nested --ignore-agent-settings --apply'
314
+ : 'oxe-cc gc-worktrees --merged --apply';
315
+ warnings.push(`higiene de worktrees: ${parts.join(', ')} — rode \`${cmd}\` (ou configure worktree.auto_gc)`);
316
+ }
317
+ }
318
+ }
319
+ } catch {
320
+ // optional hygiene helper
321
+ }
322
+
323
+ // OXB-222-14: warn (non-blocking) when an accidental `.git` exists in $HOME (can leak into non-git/temp dirs).
324
+ let homeGitHazard = null;
325
+ try {
326
+ const gitRootLib = require('./oxe-git-root.cjs');
327
+ if (typeof gitRootLib.detectHomeGitHazard === 'function') {
328
+ homeGitHazard = gitRootLib.detectHomeGitHazard(projectRoot, { homeDir: machine.homeDir });
329
+ if (homeGitHazard && homeGitHazard.hazard) {
330
+ warnings.push(
331
+ `diretório .git detectado no home do usuário (${homeGitHazard.home_git}) — pastas sem repositório próprio sob o home podem herdar esse .git fantasma; remova se for acidental`,
332
+ );
333
+ }
334
+ }
335
+ } catch {
336
+ // optional helper
337
+ }
338
+
263
339
  return {
264
340
  ok: problems.length === 0,
265
341
  problems,
266
342
  warnings,
267
343
  scrubbed_env: scrubbedEnv,
344
+ leaked_env: leakedEnv,
345
+ worktrees,
346
+ home_git_hazard: homeGitHazard,
268
347
  toolchain: { node, npm: npm || null, platform: process.platform, arch: process.arch, free_mb: freeMb },
269
348
  wanted: { engines, nvmrc: nvmrc || null, packageManager: (pkg && pkg.packageManager) || null },
270
349
  };
@@ -25,6 +25,8 @@ const ALLOWED_CONFIG_KEYS = [
25
25
  'spec_required_sections',
26
26
  'plan_max_tasks_per_wave',
27
27
  'profile',
28
+ 'preset',
29
+ 'presets',
28
30
  'verification_depth',
29
31
  'plan_confidence_threshold',
30
32
  'plan_ceremony',
@@ -0,0 +1,198 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * 1.22.2 (OXB-222-18): Continuous solution re-evaluation (`oxe-cc reevaluate [--against <ref>]`).
5
+ * Compares commits landed on the base branch since `phase.base_commit` (or merge-base) against
6
+ * pending tasks in `PLAN.json` / `IMPLEMENTATION-PACK.json` and classifies each task into:
7
+ * - `no_impact`: disjoint files and sequential resources
8
+ * - `mechanical_sync`: migration/ratchet/version-pin collision solvable by `oxe-cc sync --apply`
9
+ * - `contract_drift`: upstream changed files/contracts touched by the task -> focused CR recommended
10
+ */
11
+
12
+ const fs = require('fs');
13
+ const path = require('path');
14
+ const { spawnSync } = require('child_process');
15
+ const { resolveProjectGitRoot } = require('./oxe-git-root.cjs');
16
+
17
+ const MIGRATION_FILE_RE = /(?:^|\/)(?:migrations|db\/migrations)\/\d+[^/]*$/i;
18
+
19
+ function runGit(cwd, args, spawn = spawnSync) {
20
+ const r = spawn('git', args, { cwd, encoding: 'utf8', windowsHide: true });
21
+ return { ok: r && r.status === 0, stdout: String((r && r.stdout) || ''), stderr: String((r && r.stderr) || '') };
22
+ }
23
+
24
+ function readJsonQuiet(file) {
25
+ try {
26
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
27
+ } catch {
28
+ return null;
29
+ }
30
+ }
31
+
32
+ function normRel(p) {
33
+ return String(p || '').trim().replace(/\\/g, '/').replace(/^\.\//, '').replace(/\/+$/, '');
34
+ }
35
+
36
+ function resolveBase(root, requested, spawn) {
37
+ if (requested) {
38
+ const chk = runGit(root, ['rev-parse', '--verify', '--quiet', `${requested}^{commit}`], spawn);
39
+ if (!chk.ok) throw new Error(`ref base não encontrada: ${requested}`);
40
+ return requested;
41
+ }
42
+ for (const cand of ['origin/main', 'main', 'origin/master', 'master']) {
43
+ if (runGit(root, ['rev-parse', '--verify', '--quiet', `${cand}^{commit}`], spawn).ok) return cand;
44
+ }
45
+ throw new Error('nenhuma branch base encontrada — informe --against <ref>');
46
+ }
47
+
48
+ function isSequentialResourcePath(relPath, config = {}) {
49
+ const p = normRel(relPath);
50
+ if (MIGRATION_FILE_RE.test(p)) return true;
51
+ const syncCfg = config.sync && typeof config.sync === 'object' ? config.sync : {};
52
+ const pins = Array.isArray(syncCfg.version_pins) ? syncCfg.version_pins : [];
53
+ if (pins.some((pin) => pin && normRel(pin.file) === p)) return true;
54
+ const ratchets = config.lint && Array.isArray(config.lint.ratchets) ? config.lint.ratchets : [];
55
+ if (ratchets.some((r) => r && normRel(r.file) === p)) return true;
56
+ return false;
57
+ }
58
+
59
+ function migrationDirOf(relPath) {
60
+ const p = normRel(relPath);
61
+ if (!MIGRATION_FILE_RE.test(p)) return null;
62
+ return path.posix.dirname(p);
63
+ }
64
+
65
+ /**
66
+ * Evaluates upstream drift on `base` against pending plan tasks in `projectRoot`.
67
+ */
68
+ function reevaluateAgainstBase(projectRoot, options = {}) {
69
+ const spawn = options.spawn || spawnSync;
70
+ const rootAbs = path.resolve(projectRoot || process.cwd());
71
+ const gitRoot = resolveProjectGitRoot(rootAbs, { spawn });
72
+ if (!gitRoot) {
73
+ return {
74
+ ok: false,
75
+ error: 'repositório git não encontrado para reevaluate',
76
+ base: null,
77
+ since: null,
78
+ upstream_commits_count: 0,
79
+ upstream_changed_files: [],
80
+ overall_status: 'error',
81
+ tasks: [],
82
+ summary: { no_impact: 0, mechanical_sync: 0, contract_drift: 0 },
83
+ };
84
+ }
85
+
86
+ const base = resolveBase(rootAbs, options.against || options.base || null, spawn);
87
+ const cfg = {
88
+ ...(readJsonQuiet(path.join(rootAbs, 'oxe.config.json')) || {}),
89
+ ...(readJsonQuiet(path.join(rootAbs, '.oxe', 'config.json')) || {}),
90
+ };
91
+
92
+ // Resolve `since` commit: explicit `--since`, active phase `base_commit`, or merge-base(HEAD, base)
93
+ let since = options.since || null;
94
+ if (!since) {
95
+ const mb = runGit(rootAbs, ['merge-base', 'HEAD', base], spawn);
96
+ if (mb.ok && mb.stdout.trim()) since = mb.stdout.trim();
97
+ }
98
+ if (!since) throw new Error(`não foi possível determinar commit base comum com ${base} — informe --since <sha>`);
99
+
100
+ const logRes = runGit(rootAbs, ['log', '--oneline', `${since}..${base}`], spawn);
101
+ const commits = logRes.ok ? logRes.stdout.split(/\r?\n/).map((l) => l.trim()).filter(Boolean) : [];
102
+ const diffRes = runGit(rootAbs, ['diff', '--name-only', `${since}..${base}`], spawn);
103
+ const upstreamChanged = diffRes.ok
104
+ ? [...new Set(diffRes.stdout.split(/\r?\n/).map(normRel).filter(Boolean))].sort()
105
+ : [];
106
+ const upstreamSet = new Set(upstreamChanged);
107
+ const upstreamMigrationDirs = new Set(upstreamChanged.map(migrationDirOf).filter(Boolean));
108
+
109
+ const planDoc = readJsonQuiet(path.join(rootAbs, '.oxe', 'PLAN.json')) || { tasks: [], acceptance_tests: [] };
110
+ const pendingTasks = (Array.isArray(planDoc.tasks) ? planDoc.tasks : []).filter((t) => t && !t.done);
111
+ const evaluated = [];
112
+
113
+ for (const t of pendingTasks) {
114
+ const taskFiles = [
115
+ ...(Array.isArray(t.files) ? t.files : []),
116
+ ...(Array.isArray(t.read_only) ? t.read_only : []),
117
+ ...(Array.isArray(t.reads) ? t.reads : []),
118
+ ].map(normRel).filter(Boolean);
119
+
120
+ const directOverlaps = [];
121
+ const mechanicalReasons = [];
122
+ for (const tf of taskFiles) {
123
+ const exactOrDirHit = upstreamChanged.filter((uf) => uf === tf || uf.startsWith(`${tf}/`) || tf.startsWith(`${uf}/`));
124
+ if (exactOrDirHit.length) {
125
+ if (exactOrDirHit.every((uf) => isSequentialResourcePath(uf, cfg))) {
126
+ mechanicalReasons.push(...exactOrDirHit.map((uf) => `recurso sequencial tocado na base: ${uf}`));
127
+ } else {
128
+ directOverlaps.push(...exactOrDirHit.filter((uf) => !isSequentialResourcePath(uf, cfg)));
129
+ }
130
+ }
131
+ const mDir = migrationDirOf(tf);
132
+ if (mDir && upstreamMigrationDirs.has(mDir)) {
133
+ mechanicalReasons.push(`nova migração na base em ${mDir}/ (possível colisão de número com ${tf})`);
134
+ }
135
+ }
136
+
137
+ // Also check if frozen acceptance test files for task's criteria were touched upstream
138
+ const critSet = new Set(Array.isArray(t.acceptance) ? t.acceptance : []);
139
+ for (const at of Array.isArray(planDoc.acceptance_tests) ? planDoc.acceptance_tests : []) {
140
+ if (!at || !critSet.has(at.criterion)) continue;
141
+ for (const af of Array.isArray(at.files) ? at.files : []) {
142
+ const nf = normRel(af);
143
+ if (upstreamSet.has(nf)) directOverlaps.push(nf);
144
+ }
145
+ }
146
+
147
+ const uniqDirect = [...new Set(directOverlaps)];
148
+ const uniqMech = [...new Set(mechanicalReasons)];
149
+ let classification = 'no_impact';
150
+ let recommendedAction = 'seguir execução normal';
151
+
152
+ if (uniqDirect.length) {
153
+ classification = 'contract_drift';
154
+ recommendedAction = `oxe-cc runtime feedback --class constraint --tasks ${t.id} --summary "Upstream ${base} alterou ${uniqDirect.slice(0, 3).join(', ')}"`;
155
+ } else if (uniqMech.length) {
156
+ classification = 'mechanical_sync';
157
+ recommendedAction = `oxe-cc sync --base ${base} --apply`;
158
+ }
159
+
160
+ evaluated.push({
161
+ id: t.id,
162
+ title: t.title || '',
163
+ classification,
164
+ overlapping_files: uniqDirect,
165
+ mechanical_reasons: uniqMech,
166
+ affected_criteria: Array.isArray(t.acceptance) ? t.acceptance : [],
167
+ recommended_action: recommendedAction,
168
+ });
169
+ }
170
+
171
+ const summary = {
172
+ no_impact: evaluated.filter((x) => x.classification === 'no_impact').length,
173
+ mechanical_sync: evaluated.filter((x) => x.classification === 'mechanical_sync').length,
174
+ contract_drift: evaluated.filter((x) => x.classification === 'contract_drift').length,
175
+ };
176
+ const overallStatus = summary.contract_drift > 0
177
+ ? 'replan_recommended'
178
+ : summary.mechanical_sync > 0
179
+ ? 'mechanical_sync_needed'
180
+ : 'clean';
181
+
182
+ return {
183
+ ok: true,
184
+ base,
185
+ since,
186
+ upstream_commits_count: commits.length,
187
+ upstream_commits_sample: commits.slice(0, 10),
188
+ upstream_changed_files: upstreamChanged,
189
+ overall_status: overallStatus,
190
+ tasks: evaluated,
191
+ summary,
192
+ };
193
+ }
194
+
195
+ module.exports = {
196
+ reevaluateAgainstBase,
197
+ isSequentialResourcePath,
198
+ };
@@ -15,10 +15,29 @@
15
15
  const fs = require('fs');
16
16
  const path = require('path');
17
17
  const { spawnSync } = require('child_process');
18
+ const presets = require('./oxe-presets.cjs');
18
19
 
19
20
  const DEFAULT_REQUIRED_GATES = Object.freeze(['hml-packaged-pass', 'perf-gate', 'packaged-smoke', 'acceptance']);
20
21
  const DEFAULT_READY_STATES = Object.freeze(['homologado', 'done', 'lançado', 'lancado', 'released']);
21
22
  const DEFAULT_TARGET_STATE = 'Lançado';
23
+ const DEFAULT_DESKTOP_MOBILE_ASSETS = Object.freeze([
24
+ { label: 'Desktop installer (.exe/.dmg/.AppImage/.deb)', patterns: ['*.exe', '*.dmg', '*.AppImage', '*.deb', '*.msi'] },
25
+ { label: 'Android APK (.apk)', patterns: ['*.apk'] },
26
+ { label: 'Checksums (SHA256SUMS / checksums)', patterns: ['*checksum*', '*sha256*'] },
27
+ ]);
28
+
29
+ function resolveExpectedAssets(cfg = {}) {
30
+ if (cfg && cfg.release && Array.isArray(cfg.release.expectedAssets)) {
31
+ return cfg.release.expectedAssets;
32
+ }
33
+ const presetCfg = presets.resolvePresetConfig(cfg);
34
+ if (presetCfg.hasExplicitPreset) {
35
+ return Array.isArray(presetCfg.release && presetCfg.release.expectedAssets)
36
+ ? presetCfg.release.expectedAssets
37
+ : [];
38
+ }
39
+ return DEFAULT_DESKTOP_MOBILE_ASSETS;
40
+ }
22
41
 
23
42
  function readJsonQuiet(file) {
24
43
  try { return fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : null; } catch { return null; }
@@ -45,13 +64,14 @@ function assetMatchesPattern(name, pattern) {
45
64
 
46
65
  function checkMultiPlatformAssets(assets, cfgRelease = {}) {
47
66
  const names = (Array.isArray(assets) ? assets : []).map((a) => (typeof a === 'string' ? a : (a && a.name) || '')).filter(Boolean);
48
- const expected = Array.isArray(cfgRelease.expectedAssets) && cfgRelease.expectedAssets.length
49
- ? cfgRelease.expectedAssets
50
- : [
51
- { label: 'Desktop installer (.exe/.dmg/.AppImage/.deb)', patterns: ['*.exe', '*.dmg', '*.AppImage', '*.deb', '*.msi'] },
52
- { label: 'Android APK (.apk)', patterns: ['*.apk'] },
53
- { label: 'Checksums (SHA256SUMS / checksums)', patterns: ['*checksum*', '*sha256*'] },
54
- ];
67
+ let expected;
68
+ if (cfgRelease && Array.isArray(cfgRelease.expectedAssets)) {
69
+ expected = cfgRelease.expectedAssets;
70
+ } else if (cfgRelease && (cfgRelease.preset || cfgRelease.presets || cfgRelease.release)) {
71
+ expected = resolveExpectedAssets(cfgRelease);
72
+ } else {
73
+ expected = DEFAULT_DESKTOP_MOBILE_ASSETS;
74
+ }
55
75
  const missing = [];
56
76
  const matched = [];
57
77
  for (const spec of expected) {
@@ -67,15 +87,22 @@ function checkMultiPlatformAssets(assets, cfgRelease = {}) {
67
87
  function fetchReleaseAssets(root, tag, options = {}) {
68
88
  if (Array.isArray(options.assets)) return { ok: true, tag, assets: options.assets };
69
89
  const spawn = options.spawn || spawnSync;
90
+ const ciAdapter = require('./oxe-ci-adapter.cjs');
91
+ const explicitProvider = options.provider ? String(options.provider).toLowerCase() : null;
92
+ const detected = explicitProvider || ciAdapter.detectCiProvider(root);
93
+ const effectiveProvider = explicitProvider || (['gitlab', 'azure-devops'].includes(detected) ? detected : 'github');
94
+ if (effectiveProvider !== 'github') {
95
+ return ciAdapter.listReleaseAssets(root, tag, { ...options, provider: effectiveProvider, spawn });
96
+ }
70
97
  const r = spawn('gh', ['release', 'view', tag, '--json', 'tagName,isDraft,assets'], { cwd: root, encoding: 'utf8', windowsHide: true });
71
98
  if (r.status !== 0) {
72
- return { ok: false, tag, assets: [], error: String(r.stderr || r.stdout || 'gh release view falhou').trim() };
99
+ return { ok: false, provider: 'github', tag, assets: [], error: String(r.stderr || r.stdout || 'gh release view falhou').trim() };
73
100
  }
74
101
  try {
75
102
  const j = JSON.parse(String(r.stdout || '{}'));
76
- return { ok: true, tag: j.tagName || tag, draft: Boolean(j.isDraft), assets: Array.isArray(j.assets) ? j.assets : [] };
103
+ return { ok: true, provider: 'github', tag: j.tagName || tag, draft: Boolean(j.isDraft), assets: Array.isArray(j.assets) ? j.assets : [] };
77
104
  } catch (err) {
78
- return { ok: false, tag, assets: [], error: err.message };
105
+ return { ok: false, provider: 'github', tag, assets: [], error: err.message };
79
106
  }
80
107
  }
81
108
 
@@ -97,10 +124,11 @@ function validateChecksumsText(checksumsText, assetNames) {
97
124
  }
98
125
 
99
126
  function makeJiraClient(cfg, options = {}) {
100
- const alm = cfg && cfg.alm && typeof cfg.alm === 'object' ? cfg.alm : {};
101
- const site = String(options.site || alm.site || process.env.JIRA_SITE || '').replace(/\/+$/, '');
102
- const project = String(options.project || alm.project || '').trim();
103
127
  const env = options.env || process.env;
128
+ const alm = cfg && cfg.alm && typeof cfg.alm === 'object' ? cfg.alm : {};
129
+ const almJira = alm.jira && typeof alm.jira === 'object' ? alm.jira : {};
130
+ const site = String(options.site || almJira.site || alm.site || env.JIRA_SITE || '').trim().replace(/\/+$/, '');
131
+ const project = String(options.project || almJira.project || alm.project || env.JIRA_PROJECT || '').trim();
104
132
  if (typeof options.jiraRequest === 'function') {
105
133
  return { configured: true, site, project, request: options.jiraRequest };
106
134
  }
@@ -131,7 +159,10 @@ async function checkReleaseReadiness(projectRoot, options = {}) {
131
159
  if (!version) throw new Error('informe a versão: oxe-cc release-readiness --version <X.Y.Z>');
132
160
  const rootAbs = path.resolve(projectRoot);
133
161
  const cfg = options.config || readMergedConfig(rootAbs);
134
- const relCfg = cfg.release && typeof cfg.release === 'object' ? cfg.release : {};
162
+ const relCfg = {
163
+ ...(cfg.release && typeof cfg.release === 'object' ? cfg.release : {}),
164
+ expectedAssets: resolveExpectedAssets(cfg),
165
+ };
135
166
  const tag = `v${version}`;
136
167
  const blockers = [];
137
168
  const warnings = [];
@@ -229,7 +260,10 @@ async function finalizeRelease(projectRoot, options = {}) {
229
260
  if (!version) throw new Error('informe a versão: oxe-cc release-finalize --version <X.Y.Z>');
230
261
  const rootAbs = path.resolve(projectRoot);
231
262
  const cfg = options.config || readMergedConfig(rootAbs);
232
- const relCfg = cfg.release && typeof cfg.release === 'object' ? cfg.release : {};
263
+ const relCfg = {
264
+ ...(cfg.release && typeof cfg.release === 'object' ? cfg.release : {}),
265
+ expectedAssets: resolveExpectedAssets(cfg),
266
+ };
233
267
  const tag = `v${version}`;
234
268
  const apply = Boolean(options.apply);
235
269
  const errors = [];
@@ -318,6 +352,8 @@ async function finalizeRelease(projectRoot, options = {}) {
318
352
 
319
353
  module.exports = {
320
354
  DEFAULT_REQUIRED_GATES,
355
+ makeJiraClient,
356
+ fetchReleaseAssets,
321
357
  checkMultiPlatformAssets,
322
358
  validateChecksumsText,
323
359
  checkReleaseReadiness,