pumuki 6.3.113 → 6.3.115

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 (99) hide show
  1. package/CHANGELOG.md +52 -5
  2. package/README.md +4 -2
  3. package/VERSION +1 -1
  4. package/core/facts/detectors/typescript/index.test.ts +0 -229
  5. package/core/facts/detectors/typescript/index.ts +0 -278
  6. package/core/facts/extractHeuristicFacts.ts +0 -4
  7. package/core/rules/presets/heuristics/typescript.test.ts +1 -21
  8. package/core/rules/presets/heuristics/typescript.ts +0 -72
  9. package/docs/README.md +13 -9
  10. package/docs/codex-skills/backend-enterprise-rules.md +3 -3
  11. package/docs/operations/RELEASE_NOTES.md +41 -4
  12. package/docs/product/API_REFERENCE.md +1 -1
  13. package/docs/product/HOW_IT_WORKS.md +6 -0
  14. package/docs/product/INSTALLATION.md +1 -1
  15. package/docs/product/USAGE.md +42 -5
  16. package/docs/tracking/plan-curso-pumuki-stack-my-architecture.md +100 -44
  17. package/docs/validation/README.md +6 -3
  18. package/integrations/config/skillsDetectorRegistry.ts +0 -24
  19. package/integrations/config/skillsMarkdownRules.ts +0 -57
  20. package/integrations/evidence/buildEvidence.ts +0 -24
  21. package/integrations/evidence/repoState.ts +9 -7
  22. package/integrations/evidence/schema.ts +0 -18
  23. package/integrations/evidence/writeEvidence.ts +0 -24
  24. package/integrations/gate/evaluateAiGate.ts +8 -251
  25. package/integrations/gate/remediationCatalog.ts +0 -8
  26. package/integrations/git/GitService.ts +44 -5
  27. package/integrations/git/aiGateRepoPolicyFindings.ts +86 -17
  28. package/integrations/git/runPlatformGate.ts +1 -9
  29. package/integrations/git/runPlatformGateFacts.ts +19 -1
  30. package/integrations/git/runPlatformGateOutput.ts +41 -42
  31. package/integrations/lifecycle/adapter.templates.json +1 -0
  32. package/integrations/lifecycle/adapter.ts +0 -24
  33. package/integrations/lifecycle/audit.ts +101 -0
  34. package/integrations/lifecycle/cli.ts +120 -99
  35. package/integrations/lifecycle/cliSdd.ts +4 -26
  36. package/integrations/lifecycle/doctor.ts +40 -102
  37. package/integrations/lifecycle/index.ts +2 -0
  38. package/integrations/lifecycle/install.ts +0 -21
  39. package/integrations/lifecycle/packageInfo.ts +1 -118
  40. package/integrations/lifecycle/state.ts +1 -8
  41. package/integrations/lifecycle/status.ts +40 -59
  42. package/integrations/lifecycle/watch.ts +1 -1
  43. package/integrations/mcp/aiGateCheck.ts +10 -194
  44. package/integrations/mcp/autoExecuteAiStart.ts +116 -92
  45. package/integrations/mcp/enterpriseServer.ts +7 -23
  46. package/integrations/mcp/enterpriseStdioServer.cli.ts +4 -31
  47. package/integrations/mcp/preFlightCheck.ts +5 -67
  48. package/integrations/platform/detectPlatforms.ts +37 -0
  49. package/integrations/sdd/policy.ts +28 -20
  50. package/package.json +1 -1
  51. package/scripts/check-tracking-single-active.sh +1 -1
  52. package/scripts/consumer-menu-matrix-baseline-report-lib.ts +13 -38
  53. package/scripts/consumer-postinstall-resolve-args.cjs +44 -0
  54. package/scripts/consumer-postinstall.cjs +76 -21
  55. package/scripts/framework-menu-advanced-view-lib.ts +0 -49
  56. package/scripts/framework-menu-consumer-actions-lib.ts +28 -4
  57. package/scripts/framework-menu-consumer-preflight-hints.ts +5 -2
  58. package/scripts/framework-menu-consumer-preflight-render.ts +0 -10
  59. package/scripts/framework-menu-consumer-preflight-run.ts +0 -23
  60. package/scripts/framework-menu-consumer-preflight-types.ts +0 -12
  61. package/scripts/framework-menu-consumer-runtime-actions.ts +87 -17
  62. package/scripts/framework-menu-consumer-runtime-audit.ts +36 -2
  63. package/scripts/framework-menu-consumer-runtime-evidence-classic.ts +140 -0
  64. package/scripts/framework-menu-consumer-runtime-lib.ts +2 -38
  65. package/scripts/framework-menu-consumer-runtime-menu.ts +4 -31
  66. package/scripts/framework-menu-consumer-runtime-types.ts +3 -5
  67. package/scripts/framework-menu-evidence-summary-lib.ts +1 -0
  68. package/scripts/framework-menu-evidence-summary-read.ts +57 -5
  69. package/scripts/framework-menu-evidence-summary-severity.ts +3 -1
  70. package/scripts/framework-menu-evidence-summary-types.ts +7 -0
  71. package/scripts/framework-menu-gate-lib.ts +9 -0
  72. package/scripts/framework-menu-layout-data.ts +5 -0
  73. package/scripts/framework-menu-matrix-baseline-lib.ts +15 -14
  74. package/scripts/framework-menu-matrix-canary-lib.ts +22 -1
  75. package/scripts/framework-menu-matrix-evidence-lib.ts +1 -0
  76. package/scripts/framework-menu-matrix-evidence-types.ts +13 -1
  77. package/scripts/framework-menu-matrix-runner-lib.ts +35 -0
  78. package/scripts/framework-menu-system-notifications-cause.ts +0 -3
  79. package/scripts/framework-menu-system-notifications-macos-swift-source.ts +24 -204
  80. package/scripts/framework-menu-system-notifications-macos.ts +4 -0
  81. package/scripts/framework-menu-system-notifications-payloads-blocked.ts +1 -1
  82. package/scripts/framework-menu-system-notifications-text.ts +1 -7
  83. package/scripts/framework-menu.ts +3 -24
  84. package/scripts/package-install-smoke-consumer-git-repo-lib.ts +1 -10
  85. package/scripts/package-install-smoke-consumer-npm-lib.ts +9 -46
  86. package/scripts/pumuki-full-surface-smoke-lib.ts +37 -0
  87. package/scripts/pumuki-full-surface-smoke.ts +346 -0
  88. package/scripts/pumuki-smoke-installed-wrapper.cjs +31 -0
  89. package/integrations/evidence/trackingContract.ts +0 -17
  90. package/integrations/gate/governanceActionCatalog.ts +0 -275
  91. package/integrations/lifecycle/bootstrapManifest.ts +0 -248
  92. package/integrations/lifecycle/cliGovernanceConsole.ts +0 -69
  93. package/integrations/lifecycle/governanceNextAction.ts +0 -171
  94. package/integrations/lifecycle/governanceObservationSnapshot.ts +0 -369
  95. package/integrations/lifecycle/trackingState.ts +0 -403
  96. package/integrations/mcp/alignedPlatformGate.ts +0 -232
  97. package/integrations/mcp/readMcpPrePushStdin.ts +0 -7
  98. package/scripts/build-ruralgo-s1-evidence-pack.ts +0 -85
  99. package/scripts/ruralgo-s1-evidence-pack-lib.ts +0 -200
@@ -0,0 +1,346 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { existsSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import {
5
+ installedBinMarkerPath,
6
+ resolveSmokeLayout,
7
+ } from './pumuki-full-surface-smoke-lib';
8
+
9
+ type SmokeRowKind = 'core' | 'diagnostic';
10
+
11
+ type SmokeRow = {
12
+ id: string;
13
+ bin: string;
14
+ args: ReadonlyArray<string>;
15
+ timeoutMs: number;
16
+ allowNonZero?: boolean;
17
+ kind: SmokeRowKind;
18
+ };
19
+
20
+ const parseBooleanEnv = (raw: string | undefined): boolean => {
21
+ const value = (raw ?? '').trim().toLowerCase();
22
+ return value === '1' || value === 'true' || value === 'yes';
23
+ };
24
+
25
+ const includeDiagnosticRowsInStrict = parseBooleanEnv(
26
+ process.env.PUMUKI_SMOKE_INCLUDE_DIAGNOSTIC_ROWS
27
+ );
28
+
29
+ const layout = resolveSmokeLayout({
30
+ scriptFileUrl: import.meta.url,
31
+ env: process.env,
32
+ });
33
+
34
+ const { pumukiPackageRoot, smokeCwd, binStrategy, binRoot } = layout;
35
+ const node = process.execPath;
36
+ const binPath = (name: string): string => join(binRoot, 'bin', name);
37
+
38
+ const run = (row: SmokeRow): { code: number | null; signal: NodeJS.Signals | null; ms: number } => {
39
+ const started = Date.now();
40
+ const r = spawnSync(node, [binPath(row.bin), ...row.args], {
41
+ cwd: smokeCwd,
42
+ encoding: 'utf8',
43
+ timeout: row.timeoutMs,
44
+ maxBuffer: 50 * 1024 * 1024,
45
+ env: { ...process.env, FORCE_COLOR: '0' },
46
+ });
47
+ return { code: r.status, signal: r.signal, ms: Date.now() - started };
48
+ };
49
+
50
+ const rows: ReadonlyArray<SmokeRow> = [
51
+ { id: 'cli.help_implicit', bin: 'pumuki.js', args: [], timeoutMs: 15_000, kind: 'core', allowNonZero: true },
52
+ { id: 'cli.help_explicit', bin: 'pumuki.js', args: ['--help'], timeoutMs: 15_000, kind: 'core' },
53
+ {
54
+ id: 'cli.unknown_subcommand',
55
+ bin: 'pumuki.js',
56
+ args: ['__no_such_lifecycle_command__'],
57
+ timeoutMs: 15_000,
58
+ kind: 'core',
59
+ allowNonZero: true,
60
+ },
61
+ { id: 'doctor.json', bin: 'pumuki.js', args: ['doctor', '--json'], timeoutMs: 60_000, kind: 'core' },
62
+ {
63
+ id: 'doctor.deep_json',
64
+ bin: 'pumuki.js',
65
+ args: ['doctor', '--deep', '--json'],
66
+ timeoutMs: 180_000,
67
+ kind: 'core',
68
+ allowNonZero: true,
69
+ },
70
+ { id: 'doctor.parity_json', bin: 'pumuki.js', args: ['doctor', '--parity', '--json'], timeoutMs: 120_000, kind: 'core' },
71
+ { id: 'status.json', bin: 'pumuki.js', args: ['status', '--json'], timeoutMs: 90_000, kind: 'core' },
72
+ {
73
+ id: 'audit.default_json',
74
+ bin: 'pumuki.js',
75
+ args: ['audit', '--json'],
76
+ timeoutMs: 300_000,
77
+ kind: 'core',
78
+ allowNonZero: true,
79
+ },
80
+ {
81
+ id: 'audit.pre_push_json',
82
+ bin: 'pumuki.js',
83
+ args: ['audit', '--stage=PRE_PUSH', '--json'],
84
+ timeoutMs: 300_000,
85
+ kind: 'core',
86
+ allowNonZero: true,
87
+ },
88
+ {
89
+ id: 'audit.ci_engine_json',
90
+ bin: 'pumuki.js',
91
+ args: ['audit', '--stage=CI', '--engine', '--json'],
92
+ timeoutMs: 300_000,
93
+ kind: 'core',
94
+ allowNonZero: true,
95
+ },
96
+ {
97
+ id: 'watch.once_json',
98
+ bin: 'pumuki.js',
99
+ args: [
100
+ 'watch',
101
+ '--once',
102
+ '--json',
103
+ '--stage=PRE_COMMIT',
104
+ '--scope=repo',
105
+ '--interval-ms=200',
106
+ '--no-notify',
107
+ ],
108
+ timeoutMs: 180_000,
109
+ kind: 'diagnostic',
110
+ },
111
+ {
112
+ id: 'watch.once_staged_json',
113
+ bin: 'pumuki.js',
114
+ args: [
115
+ 'watch',
116
+ '--once',
117
+ '--json',
118
+ '--stage=PRE_COMMIT',
119
+ '--scope=staged',
120
+ '--interval-ms=200',
121
+ '--no-notify',
122
+ ],
123
+ timeoutMs: 180_000,
124
+ kind: 'diagnostic',
125
+ allowNonZero: true,
126
+ },
127
+ {
128
+ id: 'loop.list_json',
129
+ bin: 'pumuki.js',
130
+ args: ['loop', 'list', '--json'],
131
+ timeoutMs: 30_000,
132
+ kind: 'core',
133
+ },
134
+ {
135
+ id: 'loop.run_smoke',
136
+ bin: 'pumuki.js',
137
+ args: ['loop', 'run', '--objective=smoke-surface', '--max-attempts=1', '--json'],
138
+ timeoutMs: 300_000,
139
+ kind: 'core',
140
+ allowNonZero: true,
141
+ },
142
+ {
143
+ id: 'adapter.install_dry_repo_json',
144
+ bin: 'pumuki.js',
145
+ args: ['adapter', 'install', '--agent=repo', '--dry-run', '--json'],
146
+ timeoutMs: 30_000,
147
+ kind: 'core',
148
+ },
149
+ {
150
+ id: 'adapter.install_dry_codex_json',
151
+ bin: 'pumuki.js',
152
+ args: ['adapter', 'install', '--agent=codex', '--dry-run', '--json'],
153
+ timeoutMs: 30_000,
154
+ kind: 'core',
155
+ },
156
+ {
157
+ id: 'analytics.hotspots_report',
158
+ bin: 'pumuki.js',
159
+ args: ['analytics', 'hotspots', 'report', '--top=3', '--since-days=30', '--json'],
160
+ timeoutMs: 120_000,
161
+ kind: 'diagnostic',
162
+ allowNonZero: true,
163
+ },
164
+ {
165
+ id: 'analytics.hotspots_diagnose',
166
+ bin: 'pumuki.js',
167
+ args: ['analytics', 'hotspots', 'diagnose', '--json'],
168
+ timeoutMs: 120_000,
169
+ kind: 'diagnostic',
170
+ allowNonZero: true,
171
+ },
172
+ {
173
+ id: 'policy.reconcile_json',
174
+ bin: 'pumuki.js',
175
+ args: ['policy', 'reconcile', '--json'],
176
+ timeoutMs: 120_000,
177
+ kind: 'diagnostic',
178
+ allowNonZero: true,
179
+ },
180
+ {
181
+ id: 'policy.reconcile_strict_json',
182
+ bin: 'pumuki.js',
183
+ args: ['policy', 'reconcile', '--strict', '--json'],
184
+ timeoutMs: 120_000,
185
+ kind: 'diagnostic',
186
+ allowNonZero: true,
187
+ },
188
+ {
189
+ id: 'sdd.status_json',
190
+ bin: 'pumuki.js',
191
+ args: ['sdd', 'status', '--json'],
192
+ timeoutMs: 60_000,
193
+ kind: 'diagnostic',
194
+ },
195
+ {
196
+ id: 'sdd.validate_pre_write_json',
197
+ bin: 'pumuki.js',
198
+ args: ['sdd', 'validate', '--stage=PRE_WRITE', '--json'],
199
+ timeoutMs: 120_000,
200
+ kind: 'diagnostic',
201
+ allowNonZero: true,
202
+ },
203
+ {
204
+ id: 'sdd.validate_precommit_json',
205
+ bin: 'pumuki.js',
206
+ args: ['sdd', 'validate', '--stage=PRE_COMMIT', '--json'],
207
+ timeoutMs: 120_000,
208
+ kind: 'diagnostic',
209
+ allowNonZero: true,
210
+ },
211
+ {
212
+ id: 'sdd.validate_prepush_json',
213
+ bin: 'pumuki.js',
214
+ args: ['sdd', 'validate', '--stage=PRE_PUSH', '--json'],
215
+ timeoutMs: 120_000,
216
+ kind: 'diagnostic',
217
+ allowNonZero: true,
218
+ },
219
+ {
220
+ id: 'sdd.validate_ci_json',
221
+ bin: 'pumuki.js',
222
+ args: ['sdd', 'validate', '--stage=CI', '--json'],
223
+ timeoutMs: 120_000,
224
+ kind: 'diagnostic',
225
+ allowNonZero: true,
226
+ },
227
+ {
228
+ id: 'hook.pre_write',
229
+ bin: 'pumuki-pre-write.js',
230
+ args: [],
231
+ timeoutMs: 300_000,
232
+ kind: 'diagnostic',
233
+ allowNonZero: true,
234
+ },
235
+ {
236
+ id: 'hook.pre_commit',
237
+ bin: 'pumuki-pre-commit.js',
238
+ args: [],
239
+ timeoutMs: 300_000,
240
+ kind: 'diagnostic',
241
+ allowNonZero: true,
242
+ },
243
+ {
244
+ id: 'hook.pre_push',
245
+ bin: 'pumuki-pre-push.js',
246
+ args: [],
247
+ timeoutMs: 300_000,
248
+ kind: 'diagnostic',
249
+ allowNonZero: true,
250
+ },
251
+ {
252
+ id: 'hook.ci',
253
+ bin: 'pumuki-ci.js',
254
+ args: [],
255
+ timeoutMs: 300_000,
256
+ kind: 'diagnostic',
257
+ allowNonZero: true,
258
+ },
259
+ ];
260
+
261
+ const main = (): number => {
262
+ if (binStrategy === 'installed') {
263
+ const marker = installedBinMarkerPath(layout);
264
+ if (!existsSync(marker)) {
265
+ process.stderr.write(
266
+ `[pumuki] smoke: PUMUKI_SMOKE_BIN_STRATEGY=installed pero no existe ${marker}. ` +
267
+ 'Ejecuta npm install en el consumidor o revisa PUMUKI_SMOKE_REPO_ROOT.\n'
268
+ );
269
+ return 2;
270
+ }
271
+ }
272
+
273
+ const lines: string[] = [];
274
+ lines.push('# Pumuki superficie — smoke');
275
+ lines.push('');
276
+ lines.push(`- binStrategy: \`${binStrategy}\` (PUMUKI_SMOKE_BIN_STRATEGY=source|installed)`);
277
+ lines.push(`- binRoot: \`${binRoot}\``);
278
+ lines.push(`- pumukiPackageRoot (script host): \`${pumukiPackageRoot}\``);
279
+ lines.push(`- smokeCwd (gate/doctor cwd): \`${smokeCwd}\``);
280
+ lines.push(`- node: \`${node}\``);
281
+ lines.push(
282
+ `- filas: **${rows.length}** (incluye CLI, doctor/status, audit×3, watch×2, loop, adapter×2, analytics×2, policy×2, sdd×5, hooks×4)`
283
+ );
284
+ lines.push(
285
+ `- modo: \`${includeDiagnosticRowsInStrict ? 'strict+diagnostic' : 'strict-only'}\`` +
286
+ ' (activar diagnóstico con `PUMUKI_SMOKE_INCLUDE_DIAGNOSTIC_ROWS=1`)'
287
+ );
288
+ lines.push('');
289
+ lines.push('| id | tipo | exit | ms | ok |');
290
+ lines.push('|----|----|------|----|----|');
291
+ let strictFailed = 0;
292
+ let diagnosticFailed = 0;
293
+ for (const row of rows) {
294
+ const { code, signal, ms } = run(row);
295
+ const exit = signal ? `signal:${signal}` : String(code ?? 'null');
296
+ const ok =
297
+ signal !== null
298
+ ? false
299
+ : row.allowNonZero
300
+ ? true
301
+ : code === 0;
302
+ const isStrict = row.kind === 'core' || includeDiagnosticRowsInStrict;
303
+ if (!ok) {
304
+ if (isStrict) {
305
+ strictFailed += 1;
306
+ } else {
307
+ diagnosticFailed += 1;
308
+ }
309
+ }
310
+ lines.push(`| ${row.id} | ${row.kind} | ${exit} | ${ms} | ${ok ? 'yes' : 'no'} |`);
311
+ }
312
+ lines.push('');
313
+ lines.push('## Interpretación de exit codes');
314
+ lines.push('');
315
+ lines.push('- `audit` devuelve el **mismo código que el gate** del alcance auditado (p. ej. 1 si hay `BLOCK` en el repo). Eso es correcto, no indica CLI roto.');
316
+ lines.push('- `doctor --deep` puede devolver **1** si `doctorHasBlockingIssues` (issues `error` o `deep.blocking`) o mismatch de parity esperado.');
317
+ lines.push('- Los comandos de diagnóstico (`diagnostic`) quedan fuera de fallo estricto por defecto.');
318
+ lines.push('- `sdd validate` y `policy reconcile --strict` pueden devolver **1** según política del repo; el smoke los marca con `allowNonZero`.');
319
+ lines.push('');
320
+ lines.push('## No cubierto aquí (manual o destructivo)');
321
+ lines.push('');
322
+ lines.push('- `pumuki install|uninstall|remove|update|bootstrap` (mutan hooks/artefactos).');
323
+ lines.push('- `pumuki framework` / menú interactivo (`pumuki-framework.js`).');
324
+ lines.push('- Servidores MCP stdio (`pumuki-mcp-*-stdio.js`): esperan JSON-RPC por stdin; probar con cliente MCP.');
325
+ lines.push('- `pumuki sdd session|sync|learn|evidence|state-sync|auto-sync`: requieren ids / evidencia / cambios reales.');
326
+ lines.push('- `pumuki doctor|status --remote-checks`: dependen de red / GitHub.');
327
+ lines.push('');
328
+ lines.push('## Otro repo (consumidor)');
329
+ lines.push('');
330
+ lines.push(
331
+ '- **Bins del tree pumuki (desarrollo):** `PUMUKI_SMOKE_REPO_ROOT=/ruta/al/repo npm run -s smoke:pumuki-surface` desde la raíz de **pumuki** (`PUMUKI_SMOKE_BIN_STRATEGY=source` por defecto).'
332
+ );
333
+ lines.push(
334
+ '- **Bins instalados en el consumidor (`node_modules/pumuki`):** `PUMUKI_SMOKE_REPO_ROOT=/ruta/al/repo PUMUKI_SMOKE_BIN_STRATEGY=installed npm run -s smoke:pumuki-surface` o `npm run -s smoke:pumuki-surface-installed` (exige `PUMUKI_SMOKE_REPO_ROOT`).'
335
+ );
336
+ lines.push('');
337
+ lines.push(
338
+ `**Resumen:** ${strictFailed} filas críticas con fallo estricto (sin allowNonZero),` +
339
+ ` ${diagnosticFailed} filas diagnósticas con fallo no bloqueante.`
340
+ );
341
+ process.stdout.write(lines.join('\n'));
342
+ process.stdout.write('\n');
343
+ return strictFailed > 0 ? 1 : 0;
344
+ };
345
+
346
+ process.exitCode = main();
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const { spawnSync } = require('node:child_process');
5
+ const { join } = require('node:path');
6
+
7
+ if (!process.env.PUMUKI_SMOKE_REPO_ROOT || !String(process.env.PUMUKI_SMOKE_REPO_ROOT).trim()) {
8
+ console.error(
9
+ '[pumuki] smoke:pumuki-surface-installed requires PUMUKI_SMOKE_REPO_ROOT (absolute path to consumer repo).'
10
+ );
11
+ process.exit(1);
12
+ }
13
+
14
+ const root = join(__dirname, '..');
15
+ const env = {
16
+ ...process.env,
17
+ PUMUKI_SMOKE_BIN_STRATEGY: 'installed',
18
+ };
19
+
20
+ const result = spawnSync(
21
+ 'npx',
22
+ ['--yes', 'tsx@4.21.0', 'scripts/pumuki-full-surface-smoke.ts'],
23
+ {
24
+ cwd: root,
25
+ env,
26
+ stdio: 'inherit',
27
+ }
28
+ );
29
+
30
+ const code = typeof result.status === 'number' ? result.status : 1;
31
+ process.exitCode = code;
@@ -1,17 +0,0 @@
1
- import type { RepoTrackingDeclaration, RepoTrackingState } from './schema';
2
- import { resolveRepoTrackingState } from '../lifecycle/trackingState';
3
-
4
- export const readRepoTrackingState = (repoRoot: string): RepoTrackingState => {
5
- const state = resolveRepoTrackingState(repoRoot);
6
-
7
- return {
8
- enforced: state.enforced,
9
- canonical_path: state.canonical_path,
10
- canonical_present: state.canonical_present,
11
- source_file: state.source_file,
12
- in_progress_count: state.in_progress_count,
13
- single_in_progress_valid: state.single_in_progress_valid,
14
- conflict: state.conflict,
15
- declarations: state.declarations as ReadonlyArray<RepoTrackingDeclaration>,
16
- };
17
- };
@@ -1,275 +0,0 @@
1
- import type { AiGateStage } from './evaluateAiGate';
2
-
3
- export type GovernanceCatalogNextAction = {
4
- kind: 'info' | 'run_command';
5
- message: string;
6
- command?: string;
7
- };
8
-
9
- export type GovernanceCatalogAction = {
10
- reason_code: string;
11
- instruction: string;
12
- next_action: GovernanceCatalogNextAction;
13
- };
14
-
15
- const PRE_WRITE_VALIDATE_COMMAND =
16
- 'npx --yes --package pumuki@latest pumuki sdd validate --stage=PRE_WRITE --json';
17
-
18
- export const buildGovernanceValidateCommand = (stage: AiGateStage): string =>
19
- PRE_WRITE_VALIDATE_COMMAND.replace('PRE_WRITE', stage);
20
-
21
- export const buildGovernancePolicyReconcileCommand = (stage: AiGateStage): string =>
22
- `npx --yes --package pumuki@latest pumuki policy reconcile --strict --json && ${buildGovernanceValidateCommand(stage)}`;
23
-
24
- const buildFallbackAction = (code: string): GovernanceCatalogAction => ({
25
- reason_code: code,
26
- instruction: 'Corrige el bloqueante primario y vuelve a ejecutar la validación del stage actual.',
27
- next_action: {
28
- kind: 'info',
29
- message: 'Corrige el bloqueante primario y vuelve a ejecutar el mismo comando.',
30
- },
31
- });
32
-
33
- export const resolveGovernanceCatalogAction = (params: {
34
- code: string;
35
- stage?: AiGateStage;
36
- fallback?: GovernanceCatalogAction;
37
- }): GovernanceCatalogAction => {
38
- const stage = params.stage ?? 'PRE_WRITE';
39
- const validateCommand = buildGovernanceValidateCommand(stage);
40
- switch (params.code) {
41
- case 'READY':
42
- return {
43
- reason_code: 'READY',
44
- instruction: 'Puedes continuar con la siguiente slice mínima y volver a validar al cerrar.',
45
- next_action: {
46
- kind: 'info',
47
- message: 'Gate en verde. Continúa con la implementación.',
48
- },
49
- };
50
- case 'EVIDENCE_INVALID_OR_CHAIN':
51
- return {
52
- reason_code: 'EVIDENCE_INVALID_OR_CHAIN',
53
- instruction: 'Regenera la evidencia canónica antes de continuar.',
54
- next_action: {
55
- kind: 'run_command',
56
- message: 'Regenera o corrige la evidencia canónica (.ai_evidence.json) y vuelve a validar governance.',
57
- command: validateCommand,
58
- },
59
- };
60
- case 'AI_GATE_BLOCKED':
61
- return {
62
- reason_code: 'AI_GATE_BLOCKED',
63
- instruction: 'Corrige primero el bloqueo principal del gate antes de continuar.',
64
- next_action: {
65
- kind: 'run_command',
66
- message: 'Revalida el stage tras corregir la evidencia y el bloqueo principal.',
67
- command: validateCommand,
68
- },
69
- };
70
- case 'SDD_SESSION_MISSING':
71
- return {
72
- reason_code: 'SDD_SESSION_MISSING',
73
- instruction: 'Abre una sesión SDD válida antes de seguir trabajando.',
74
- next_action: {
75
- kind: 'run_command',
76
- message: 'Abre la sesión SDD del cambio activo y vuelve a validar.',
77
- command: 'npx --yes --package pumuki@latest pumuki sdd session --open --change=<id>',
78
- },
79
- };
80
- case 'SDD_SESSION_INVALID':
81
- case 'SDD_SESSION_INVALID_OR_EXPIRED':
82
- return {
83
- reason_code: 'SDD_SESSION_INVALID_OR_EXPIRED',
84
- instruction: 'Refresca o reabre la sesión SDD antes de seguir trabajando.',
85
- next_action: {
86
- kind: 'run_command',
87
- message: 'Refresca la sesión SDD y vuelve a validar governance.',
88
- command: 'npx --yes --package pumuki@latest pumuki sdd session --refresh --ttl-minutes=90',
89
- },
90
- };
91
- case 'PRE_PUSH_UPSTREAM_MISSING':
92
- return {
93
- reason_code: 'PRE_PUSH_UPSTREAM_MISSING',
94
- instruction: 'Configura el upstream remoto antes de continuar con PRE_PUSH.',
95
- next_action: {
96
- kind: 'run_command',
97
- message: 'Configura tracking remoto para la rama actual.',
98
- command: 'git push --set-upstream origin <branch>',
99
- },
100
- };
101
- case 'PRE_PUSH_UPSTREAM_MISALIGNED':
102
- return {
103
- reason_code: 'PRE_PUSH_UPSTREAM_MISALIGNED',
104
- instruction: 'Alinea el upstream remoto con la rama actual antes de continuar.',
105
- next_action: {
106
- kind: 'run_command',
107
- message: 'Reconfigura el upstream remoto de la rama actual.',
108
- command: 'git branch --unset-upstream && git push --set-upstream origin <branch>',
109
- },
110
- };
111
- case 'GITFLOW_PROTECTED_BRANCH':
112
- case 'GITFLOW_PROTECTED_BRANCH_CONTEXT':
113
- return {
114
- reason_code: 'GITFLOW_PROTECTED_BRANCH_CONTEXT',
115
- instruction: 'Sal de la rama protegida y mueve el trabajo a feature/* o refactor/*.',
116
- next_action: {
117
- kind: 'run_command',
118
- message: 'Crea una rama válida de trabajo antes de seguir.',
119
- command: 'git checkout -b feature/<descripcion-kebab-case>',
120
- },
121
- };
122
- case 'GITFLOW_BRANCH_NAMING_INVALID':
123
- case 'GITFLOW_BRANCH_NAMING_INVALID_CONTEXT':
124
- return {
125
- reason_code: 'GITFLOW_BRANCH_NAMING_INVALID_CONTEXT',
126
- instruction:
127
- 'Renombra o recrea la rama actual con un prefijo GitFlow válido antes de continuar.',
128
- next_action: {
129
- kind: 'run_command',
130
- message: 'Crea una rama válida y mueve el trabajo a esa rama antes de seguir.',
131
- command: 'git checkout -b feature/<descripcion-kebab-case>',
132
- },
133
- };
134
- case 'TRACKING_CANONICAL_SOURCE_CONFLICT':
135
- return {
136
- reason_code: 'TRACKING_CANONICAL_SOURCE_CONFLICT',
137
- instruction:
138
- 'Alinea AGENTS.md y los README canónicos para que todos apunten al mismo MD de seguimiento.',
139
- next_action: {
140
- kind: 'info',
141
- message:
142
- 'Deja una única fuente canónica de tracking y elimina referencias legacy o contradictorias.',
143
- },
144
- };
145
- case 'TRACKING_CANONICAL_FILE_MISSING':
146
- return {
147
- reason_code: 'TRACKING_CANONICAL_FILE_MISSING',
148
- instruction:
149
- 'Crea o restaura el MD de seguimiento canónico declarado por el repo antes de continuar.',
150
- next_action: {
151
- kind: 'info',
152
- message:
153
- 'Restaura el archivo canónico de tracking y vuelve a validar governance.',
154
- },
155
- };
156
- case 'TRACKING_CANONICAL_IN_PROGRESS_INVALID':
157
- return {
158
- reason_code: 'TRACKING_CANONICAL_IN_PROGRESS_INVALID',
159
- instruction:
160
- 'El tracking canónico debe tener exactamente una tarea o fase en construcción.',
161
- next_action: {
162
- kind: 'info',
163
- message:
164
- 'Corrige el MD canónico para dejar exactamente una `🚧` antes de continuar.',
165
- },
166
- };
167
- case 'POLICY_STAGE_NOT_STRICT':
168
- return {
169
- reason_code: 'POLICY_STAGE_NOT_STRICT',
170
- instruction: 'Reconcilia policy/skills en modo estricto antes de seguir.',
171
- next_action: {
172
- kind: 'run_command',
173
- message: 'Converge policy-as-code y revalida el stage actual.',
174
- command: buildGovernancePolicyReconcileCommand(stage),
175
- },
176
- };
177
- case 'SKILLS_CONTRACT_SURFACE_INCOMPLETE':
178
- case 'EVIDENCE_SKILLS_CONTRACT_INCOMPLETE':
179
- return {
180
- reason_code: 'SKILLS_CONTRACT_SURFACE_INCOMPLETE',
181
- instruction: 'Materializa el lock/sources de skills antes de dar governance efectiva.',
182
- next_action: {
183
- kind: 'run_command',
184
- message: 'Reconcilia policy/skills y vuelve a validar governance.',
185
- command: buildGovernancePolicyReconcileCommand(stage),
186
- },
187
- };
188
- case 'ADAPTER_WIRING_MISSING':
189
- return {
190
- reason_code: 'ADAPTER_WIRING_MISSING',
191
- instruction: 'Instala el adaptador canónico si quieres wiring explícito de IDE/MCP.',
192
- next_action: {
193
- kind: 'run_command',
194
- message: 'Genera `.pumuki/adapter.json` desde la instalación canónica.',
195
- command: 'npx --yes --package pumuki@latest pumuki install --with-mcp',
196
- },
197
- };
198
- case 'EVIDENCE_STALE':
199
- case 'EVIDENCE_BRANCH_MISMATCH':
200
- case 'EVIDENCE_SNAPSHOT_WARN':
201
- return {
202
- reason_code: params.code === 'EVIDENCE_SNAPSHOT_WARN' ? 'EVIDENCE_SNAPSHOT_WARN' : 'EVIDENCE_STALE',
203
- instruction: 'Refresca evidencia y revisa hallazgos WARN antes de continuar.',
204
- next_action: {
205
- kind: 'run_command',
206
- message: 'Revalida el stage actual y revisa findings WARN.',
207
- command: validateCommand,
208
- },
209
- };
210
- case 'ACTIVE_RULE_IDS_EMPTY_FOR_CODE_CHANGES_HIGH':
211
- case 'EVIDENCE_ACTIVE_RULE_IDS_EMPTY_FOR_CODE_CHANGES':
212
- return {
213
- reason_code: 'EVIDENCE_ACTIVE_RULE_IDS_EMPTY_FOR_CODE_CHANGES',
214
- instruction: 'Reconcilia policy/skills en modo estricto y revalida el stage actual.',
215
- next_action: {
216
- kind: 'run_command',
217
- message: 'Converge policy-as-code y vuelve a validar cobertura de active_rule_ids para reglas activas.',
218
- command: buildGovernancePolicyReconcileCommand(stage),
219
- },
220
- };
221
- case 'EVIDENCE_PLATFORM_SKILLS_SCOPE_INCOMPLETE':
222
- case 'EVIDENCE_PLATFORM_SKILLS_BUNDLES_MISSING':
223
- return {
224
- reason_code: params.code,
225
- instruction: 'Completa cobertura de skills por plataforma y vuelve a validar.',
226
- next_action: {
227
- kind: 'run_command',
228
- message: 'Completa bundles/prefijos de skills requeridos y revalida el stage actual.',
229
- command: validateCommand,
230
- },
231
- };
232
- case 'EVIDENCE_PLATFORM_CRITICAL_SKILLS_RULES_MISSING':
233
- case 'EVIDENCE_CROSS_PLATFORM_CRITICAL_ENFORCEMENT_INCOMPLETE':
234
- return {
235
- reason_code: params.code,
236
- instruction: 'Reconcilia policy/skills en modo estricto para enforcement crítico y revalida.',
237
- next_action: {
238
- kind: 'run_command',
239
- message: 'Materializa reglas críticas de plataforma y vuelve a validar el stage actual.',
240
- command: buildGovernancePolicyReconcileCommand(stage),
241
- },
242
- };
243
- case 'EVIDENCE_PREWRITE_WORKTREE_OVER_LIMIT':
244
- case 'EVIDENCE_PREWRITE_WORKTREE_WARN':
245
- return {
246
- reason_code: params.code,
247
- instruction: 'Particiona el worktree en slices atómicos antes de continuar.',
248
- next_action: {
249
- kind: 'run_command',
250
- message: 'Reduce el worktree pendiente y revalida el stage actual.',
251
- command: `git status --short && git add -p && ${validateCommand}`,
252
- },
253
- };
254
- case 'SKILLS_SKILLS_FRONTEND_NO_SOLID_VIOLATIONS':
255
- return {
256
- reason_code: 'SKILLS_SKILLS_FRONTEND_NO_SOLID_VIOLATIONS',
257
- instruction: 'Aplica refactor incremental por componente/hook y vuelve a validar.',
258
- next_action: {
259
- kind: 'info',
260
- message: 'Aplica refactor incremental: extrae 1 componente/hook por commit y vuelve a ejecutar el gate.',
261
- },
262
- };
263
- case 'GOVERNANCE_ATTENTION':
264
- return {
265
- reason_code: 'GOVERNANCE_ATTENTION',
266
- instruction: 'Revisa governance truth y corrige el primer hueco del contrato antes de continuar.',
267
- next_action: {
268
- kind: 'info',
269
- message: 'Revisa governance truth, corrige el primer gap visible y vuelve a validar.',
270
- },
271
- };
272
- default:
273
- return params.fallback ?? buildFallbackAction(params.code);
274
- }
275
- };