@vfarcic/dot-ai 0.115.0 → 0.117.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.
Files changed (143) hide show
  1. package/README.md +21 -18
  2. package/dist/core/ai-provider-factory.d.ts +4 -2
  3. package/dist/core/ai-provider-factory.d.ts.map +1 -1
  4. package/dist/core/ai-provider-factory.js +17 -6
  5. package/dist/core/capability-operations.js +1 -1
  6. package/dist/core/generic-session-manager.d.ts +67 -0
  7. package/dist/core/generic-session-manager.d.ts.map +1 -0
  8. package/dist/core/generic-session-manager.js +192 -0
  9. package/dist/core/pattern-operations.js +1 -1
  10. package/dist/core/providers/noop-provider.d.ts +47 -0
  11. package/dist/core/providers/noop-provider.d.ts.map +1 -0
  12. package/dist/core/providers/noop-provider.js +63 -0
  13. package/dist/core/schema.d.ts.map +1 -1
  14. package/dist/core/schema.js +13 -13
  15. package/dist/core/session-utils.d.ts +3 -6
  16. package/dist/core/session-utils.d.ts.map +1 -1
  17. package/dist/core/session-utils.js +5 -13
  18. package/dist/core/shared-prompt-loader.d.ts +15 -3
  19. package/dist/core/shared-prompt-loader.d.ts.map +1 -1
  20. package/dist/core/shared-prompt-loader.js +67 -14
  21. package/dist/core/unified-creation-session.d.ts +3 -10
  22. package/dist/core/unified-creation-session.d.ts.map +1 -1
  23. package/dist/core/unified-creation-session.js +34 -75
  24. package/dist/core/unified-creation-types.d.ts +31 -22
  25. package/dist/core/unified-creation-types.d.ts.map +1 -1
  26. package/dist/evaluation/eval-runner.js +12 -3
  27. package/dist/evaluation/evaluators/base-comparative.d.ts +2 -0
  28. package/dist/evaluation/evaluators/base-comparative.d.ts.map +1 -1
  29. package/dist/evaluation/evaluators/base-comparative.js +13 -1
  30. package/dist/evaluation/graph-generator.d.ts +56 -0
  31. package/dist/evaluation/graph-generator.d.ts.map +1 -0
  32. package/dist/evaluation/graph-generator.js +694 -0
  33. package/dist/evaluation/metadata-loader.d.ts +39 -0
  34. package/dist/evaluation/metadata-loader.d.ts.map +1 -0
  35. package/dist/evaluation/metadata-loader.js +74 -0
  36. package/dist/evaluation/platform-synthesizer.d.ts +5 -1
  37. package/dist/evaluation/platform-synthesizer.d.ts.map +1 -1
  38. package/dist/evaluation/platform-synthesizer.js +65 -23
  39. package/dist/evaluation/run-platform-synthesis.js +22 -5
  40. package/dist/interfaces/mcp.d.ts.map +1 -1
  41. package/dist/interfaces/mcp.js +9 -34
  42. package/dist/tools/answer-question.d.ts.map +1 -1
  43. package/dist/tools/answer-question.js +12 -12
  44. package/dist/tools/choose-solution.js +1 -1
  45. package/dist/tools/generate-manifests.d.ts.map +1 -1
  46. package/dist/tools/generate-manifests.js +9 -10
  47. package/dist/tools/index.d.ts +1 -1
  48. package/dist/tools/index.d.ts.map +1 -1
  49. package/dist/tools/index.js +6 -6
  50. package/dist/tools/organizational-data.js +12 -12
  51. package/dist/tools/project-setup/discovery.d.ts +15 -0
  52. package/dist/tools/project-setup/discovery.d.ts.map +1 -0
  53. package/dist/tools/project-setup/discovery.js +104 -0
  54. package/dist/tools/project-setup/generate-scope.d.ts +15 -0
  55. package/dist/tools/project-setup/generate-scope.d.ts.map +1 -0
  56. package/dist/tools/project-setup/generate-scope.js +237 -0
  57. package/dist/tools/project-setup/report-scan.d.ts +15 -0
  58. package/dist/tools/project-setup/report-scan.d.ts.map +1 -0
  59. package/dist/tools/project-setup/report-scan.js +156 -0
  60. package/dist/tools/project-setup/types.d.ts +111 -0
  61. package/dist/tools/project-setup/types.d.ts.map +1 -0
  62. package/dist/tools/project-setup/types.js +8 -0
  63. package/dist/tools/project-setup.d.ts +28 -0
  64. package/dist/tools/project-setup.d.ts.map +1 -0
  65. package/dist/tools/project-setup.js +134 -0
  66. package/dist/tools/recommend.js +1 -1
  67. package/dist/tools/remediate.js +1 -1
  68. package/dist/tools/version.d.ts +0 -7
  69. package/dist/tools/version.d.ts.map +1 -1
  70. package/dist/tools/version.js +5 -34
  71. package/package.json +4 -2
  72. package/prompts/capability-inference.md +2 -2
  73. package/prompts/infrastructure-trigger-expansion.md +2 -2
  74. package/prompts/intent-analysis.md +2 -2
  75. package/prompts/kyverno-generation.md +14 -14
  76. package/prompts/manifest-generation.md +5 -5
  77. package/prompts/map-intent-to-operation.md +2 -2
  78. package/prompts/pattern-complete-error.md +1 -1
  79. package/prompts/pattern-complete-success.md +4 -4
  80. package/prompts/pattern-rationale.md +1 -1
  81. package/prompts/pattern-resources.md +1 -1
  82. package/prompts/pattern-review.md +5 -5
  83. package/prompts/policy-complete-apply.md +4 -4
  84. package/prompts/policy-complete-discard.md +1 -1
  85. package/prompts/policy-complete-error.md +1 -1
  86. package/prompts/policy-complete-save.md +4 -4
  87. package/prompts/policy-complete-success.md +4 -4
  88. package/prompts/policy-namespace-scope.md +1 -1
  89. package/prompts/question-generation.md +5 -5
  90. package/prompts/resource-analysis.md +3 -3
  91. package/prompts/resource-selection.md +3 -3
  92. package/prompts/solution-enhancement.md +4 -4
  93. package/scripts/anthropic.nu +9 -13
  94. package/scripts/common.nu +31 -33
  95. package/scripts/ingress.nu +5 -4
  96. package/scripts/kubernetes.nu +38 -53
  97. package/dist/core/doc-discovery.d.ts +0 -38
  98. package/dist/core/doc-discovery.d.ts.map +0 -1
  99. package/dist/core/doc-discovery.js +0 -231
  100. package/dist/core/doc-testing-session.d.ts +0 -109
  101. package/dist/core/doc-testing-session.d.ts.map +0 -1
  102. package/dist/core/doc-testing-session.js +0 -696
  103. package/dist/core/doc-testing-types.d.ts +0 -127
  104. package/dist/core/doc-testing-types.d.ts.map +0 -1
  105. package/dist/core/doc-testing-types.js +0 -53
  106. package/dist/core/nushell-runtime.d.ts +0 -39
  107. package/dist/core/nushell-runtime.d.ts.map +0 -1
  108. package/dist/core/nushell-runtime.js +0 -103
  109. package/dist/core/platform-operations.d.ts +0 -70
  110. package/dist/core/platform-operations.d.ts.map +0 -1
  111. package/dist/core/platform-operations.js +0 -294
  112. package/dist/tools/build-platform.d.ts +0 -25
  113. package/dist/tools/build-platform.d.ts.map +0 -1
  114. package/dist/tools/build-platform.js +0 -277
  115. package/dist/tools/test-docs.d.ts +0 -22
  116. package/dist/tools/test-docs.d.ts.map +0 -1
  117. package/dist/tools/test-docs.js +0 -351
  118. package/prompts/doc-testing-done.md +0 -51
  119. package/prompts/doc-testing-fix.md +0 -120
  120. package/prompts/doc-testing-scan.md +0 -140
  121. package/prompts/doc-testing-test-section.md +0 -169
  122. package/prompts/platform-operations-parse-script-help.md +0 -68
  123. package/scripts/ack.nu +0 -195
  124. package/scripts/argo-workflows.nu +0 -47
  125. package/scripts/argocd.nu +0 -85
  126. package/scripts/aso.nu +0 -74
  127. package/scripts/backstage.nu +0 -349
  128. package/scripts/cert-manager.nu +0 -13
  129. package/scripts/cnpg.nu +0 -14
  130. package/scripts/dot.nu +0 -32
  131. package/scripts/external-secrets.nu +0 -110
  132. package/scripts/gatekeeper.nu +0 -19
  133. package/scripts/github.nu +0 -42
  134. package/scripts/image.nu +0 -67
  135. package/scripts/kro.nu +0 -11
  136. package/scripts/kubevela.nu +0 -22
  137. package/scripts/port.nu +0 -71
  138. package/scripts/prometheus.nu +0 -21
  139. package/scripts/registry.nu +0 -55
  140. package/scripts/storage.nu +0 -210
  141. package/scripts/tests.nu +0 -12
  142. package/scripts/velero.nu +0 -45
  143. package/shared-prompts/validate-docs.md +0 -22
@@ -43,21 +43,14 @@ exports.getAndValidateSessionDirectory = getAndValidateSessionDirectory;
43
43
  const fs = __importStar(require("fs"));
44
44
  const path = __importStar(require("path"));
45
45
  /**
46
- * Get session directory from CLI args or environment variable
47
- * CLI parameter takes precedence over environment variable
46
+ * Get session directory from environment variable
48
47
  *
49
- * @param args - Tool arguments that may contain sessionDir
50
48
  * @returns Resolved session directory path (can be relative or absolute)
51
49
  */
52
- function getSessionDirectory(args) {
53
- // For CLI interface, sessionDir is required as parameter
54
- if (args.sessionDir) {
55
- return args.sessionDir;
56
- }
57
- // For MCP interface, sessionDir comes from environment
50
+ function getSessionDirectory() {
58
51
  const envSessionDir = process.env.DOT_AI_SESSION_DIR;
59
52
  if (!envSessionDir) {
60
- throw new Error('Session directory must be specified via --session-dir parameter or DOT_AI_SESSION_DIR environment variable');
53
+ throw new Error('Session directory must be specified via DOT_AI_SESSION_DIR environment variable');
61
54
  }
62
55
  return envSessionDir;
63
56
  }
@@ -110,12 +103,11 @@ function validateSessionDirectory(sessionDir, requireWrite = false) {
110
103
  /**
111
104
  * Get and validate session directory in one call
112
105
  *
113
- * @param args - Tool arguments that may contain sessionDir
114
106
  * @param requireWrite - Whether to test write permissions (default: false)
115
107
  * @returns Validated session directory path
116
108
  */
117
- function getAndValidateSessionDirectory(args, requireWrite = false) {
118
- const sessionDir = getSessionDirectory(args);
109
+ function getAndValidateSessionDirectory(requireWrite = false) {
110
+ const sessionDir = getSessionDirectory();
119
111
  validateSessionDirectory(sessionDir, requireWrite);
120
112
  return sessionDir;
121
113
  }
@@ -1,13 +1,25 @@
1
1
  /**
2
2
  * Shared Prompt Loader
3
3
  *
4
- * Loads prompt templates from markdown files and replaces variables
4
+ * Loads prompt templates from files and replaces variables using Handlebars
5
5
  * Following CLAUDE.md guidelines for file-based prompts
6
6
  *
7
7
  * Extracted from unified-creation-session.ts to be shared across all creation workflows
8
+ * Extended to support custom base directories and file extensions
8
9
  */
9
10
  /**
10
- * Load prompt template from file and replace variables
11
+ * Load template from file and replace variables using Handlebars
12
+ *
13
+ * @param templateName - Name of the template file (without extension)
14
+ * @param variables - Key-value pairs to replace in template
15
+ * @param baseDir - Base directory (relative to project root or absolute path; default: 'prompts')
16
+ * @param fileExtension - File extension (default: '.md')
17
+ * @returns Processed template content
18
+ *
19
+ * Supports Handlebars syntax:
20
+ * - {{variable}} - Variable interpolation
21
+ * - {{#if variable}}...{{/if}} - Conditional blocks
22
+ * - {{#each array}}...{{/each}} - Iteration
11
23
  */
12
- export declare function loadPrompt(promptName: string, variables?: Record<string, string>): string;
24
+ export declare function loadPrompt(templateName: string, variables?: Record<string, any>, baseDir?: string, fileExtension?: string): string;
13
25
  //# sourceMappingURL=shared-prompt-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-prompt-loader.d.ts","sourceRoot":"","sources":["../../src/core/shared-prompt-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH;;GAEG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAAG,MAAM,CAiB7F"}
1
+ {"version":3,"file":"shared-prompt-loader.d.ts","sourceRoot":"","sources":["../../src/core/shared-prompt-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAyCH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CACxB,YAAY,EAAE,MAAM,EACpB,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EACnC,OAAO,GAAE,MAAkB,EAC3B,aAAa,GAAE,MAAc,GAC5B,MAAM,CAyBR"}
@@ -2,10 +2,11 @@
2
2
  /**
3
3
  * Shared Prompt Loader
4
4
  *
5
- * Loads prompt templates from markdown files and replaces variables
5
+ * Loads prompt templates from files and replaces variables using Handlebars
6
6
  * Following CLAUDE.md guidelines for file-based prompts
7
7
  *
8
8
  * Extracted from unified-creation-session.ts to be shared across all creation workflows
9
+ * Extended to support custom base directories and file extensions
9
10
  */
10
11
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
12
  if (k2 === undefined) k2 = k;
@@ -40,27 +41,79 @@ var __importStar = (this && this.__importStar) || (function () {
40
41
  return result;
41
42
  };
42
43
  })();
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
43
47
  Object.defineProperty(exports, "__esModule", { value: true });
44
48
  exports.loadPrompt = loadPrompt;
45
49
  const fs = __importStar(require("fs"));
46
50
  const path = __importStar(require("path"));
51
+ const handlebars_1 = __importDefault(require("handlebars"));
52
+ // Register custom Handlebars helpers
53
+ // Block helper for equality comparison: {{#eq a b}}...{{/eq}}
54
+ handlebars_1.default.registerHelper('eq', function (a, b, options) {
55
+ if (a === b) {
56
+ return options.fn(this);
57
+ }
58
+ else {
59
+ return options.inverse(this);
60
+ }
61
+ });
62
+ // Block helper for truthy check: {{#isTrue value}}...{{/isTrue}}
63
+ // Treats various truthy values as true (case-insensitive for strings)
64
+ // Truthy: true, "yes", "true", "1", "on" (any case)
65
+ handlebars_1.default.registerHelper('isTrue', function (value, options) {
66
+ // Handle boolean true
67
+ if (value === true) {
68
+ return options.fn(this);
69
+ }
70
+ // Handle string values (case-insensitive)
71
+ if (typeof value === 'string') {
72
+ const normalized = value.toLowerCase();
73
+ if (normalized === 'yes' || normalized === 'true' || normalized === '1' || normalized === 'on') {
74
+ return options.fn(this);
75
+ }
76
+ }
77
+ // Handle numeric 1
78
+ if (value === 1) {
79
+ return options.fn(this);
80
+ }
81
+ return options.inverse(this);
82
+ });
47
83
  /**
48
- * Load prompt template from file and replace variables
84
+ * Load template from file and replace variables using Handlebars
85
+ *
86
+ * @param templateName - Name of the template file (without extension)
87
+ * @param variables - Key-value pairs to replace in template
88
+ * @param baseDir - Base directory (relative to project root or absolute path; default: 'prompts')
89
+ * @param fileExtension - File extension (default: '.md')
90
+ * @returns Processed template content
91
+ *
92
+ * Supports Handlebars syntax:
93
+ * - {{variable}} - Variable interpolation
94
+ * - {{#if variable}}...{{/if}} - Conditional blocks
95
+ * - {{#each array}}...{{/each}} - Iteration
49
96
  */
50
- function loadPrompt(promptName, variables = {}) {
97
+ function loadPrompt(templateName, variables = {}, baseDir = 'prompts', fileExtension = '.md') {
51
98
  try {
52
- // Use __dirname to resolve paths relative to the module location
53
- // This works both locally and when installed as an npm package
54
- const promptPath = path.join(__dirname, '..', '..', 'prompts', `${promptName}.md`);
55
- let template = fs.readFileSync(promptPath, 'utf8');
56
- // Replace template variables
57
- for (const [key, value] of Object.entries(variables)) {
58
- template = template.replace(new RegExp(`\\{${key}\\}`, 'g'), value);
59
- }
60
- return template;
99
+ // Support both absolute and relative paths for baseDir
100
+ // If baseDir is absolute, use it directly; otherwise resolve relative to project root
101
+ const resolvedBaseDir = path.isAbsolute(baseDir)
102
+ ? baseDir
103
+ : path.join(__dirname, '..', '..', baseDir);
104
+ const templatePath = path.join(resolvedBaseDir, `${templateName}${fileExtension}`);
105
+ const templateContent = fs.readFileSync(templatePath, 'utf8');
106
+ // Compile and execute Handlebars template
107
+ const template = handlebars_1.default.compile(templateContent);
108
+ const result = template(variables);
109
+ return result;
61
110
  }
62
111
  catch (error) {
63
- console.error(`Failed to load prompt ${promptName}:`, error);
64
- return `Error loading prompt: ${promptName}`;
112
+ const errorMessage = error instanceof Error ? error.message : String(error);
113
+ const resolvedPath = path.isAbsolute(baseDir)
114
+ ? path.join(baseDir, `${templateName}${fileExtension}`)
115
+ : path.join(__dirname, '..', '..', baseDir, `${templateName}${fileExtension}`);
116
+ console.error(`Failed to load template "${templateName}" from "${baseDir}" (resolved: ${resolvedPath}): ${errorMessage}`);
117
+ return `Error loading template: ${templateName}`;
65
118
  }
66
119
  }
@@ -10,6 +10,7 @@ import { UnifiedCreationSession, UnifiedWorkflowStepResponse, UnifiedWorkflowCom
10
10
  export declare class UnifiedCreationSessionManager {
11
11
  private config;
12
12
  private discovery;
13
+ private sessionManager;
13
14
  constructor(entityType: EntityType, discovery?: KubernetesDiscovery);
14
15
  /**
15
16
  * Create a new creation session
@@ -18,11 +19,11 @@ export declare class UnifiedCreationSessionManager {
18
19
  /**
19
20
  * Load existing session
20
21
  */
21
- loadSession(sessionId: string, args: any): UnifiedCreationSession | null;
22
+ loadSession(sessionId: string, _args: any): UnifiedCreationSession | null;
22
23
  /**
23
24
  * Process user response and advance session
24
25
  */
25
- processResponse(sessionId: string, response: string, args: any): UnifiedCreationSession;
26
+ processResponse(sessionId: string, response: string, _args: any): UnifiedCreationSession;
26
27
  /**
27
28
  * Generate next workflow step
28
29
  */
@@ -71,13 +72,5 @@ export declare class UnifiedCreationSessionManager {
71
72
  * Format schemas for inclusion in the Kyverno generation prompt
72
73
  */
73
74
  private formatSchemasForPrompt;
74
- /**
75
- * Save session to file
76
- */
77
- private saveSession;
78
- /**
79
- * Generate unique session ID
80
- */
81
- private generateSessionId;
82
75
  }
83
76
  //# sourceMappingURL=unified-creation-session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"unified-creation-session.d.ts","sourceRoot":"","sources":["../../src/core/unified-creation-session.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKlD,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,iCAAiC,EACjC,UAAU,EAIX,MAAM,0BAA0B,CAAC;AAKlC,qBAAa,6BAA6B;IACxC,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,SAAS,CAAsB;gBAE3B,UAAU,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,mBAAmB;IAKnE;;OAEG;IACH,aAAa,CAAC,IAAI,EAAE,GAAG,GAAG,sBAAsB;IAqBhD;;OAEG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,sBAAsB,GAAG,IAAI;IAiBxE;;OAEG;IACH,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,sBAAsB;IA2GvF;;OAEG;IACG,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,2BAA2B,GAAG,iCAAiC,CAAC;IAoGhJ;;OAEG;YACW,4BAA4B;IA4C1C;;OAEG;YACW,gCAAgC;IAyC9C;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA6E1B;;OAEG;YACW,gBAAgB;IAsF9B;;OAEG;YACW,4BAA4B;IAoH1C;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAY1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BAA4B;IAoH1C;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAY1B;;OAEG;YACW,qBAAqB;IAqCnC;;OAEG;YACW,mBAAmB;IAyLjC;;OAEG;YACW,uBAAuB;IAmFrC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;OAEG;IACH,OAAO,CAAC,sBAAsB;CAY/B"}
@@ -44,6 +44,7 @@ exports.UnifiedCreationSessionManager = void 0;
44
44
  const fs = __importStar(require("fs"));
45
45
  const path = __importStar(require("path"));
46
46
  const crypto_1 = require("crypto");
47
+ const generic_session_manager_1 = require("./generic-session-manager");
47
48
  const session_utils_1 = require("./session-utils");
48
49
  const shared_prompt_loader_1 = require("./shared-prompt-loader");
49
50
  const capability_vector_service_1 = require("./capability-vector-service");
@@ -57,93 +58,74 @@ const pattern_operations_1 = require("./pattern-operations");
57
58
  class UnifiedCreationSessionManager {
58
59
  config;
59
60
  discovery;
61
+ sessionManager;
60
62
  constructor(entityType, discovery) {
61
63
  this.config = unified_creation_types_1.WORKFLOW_CONFIGS[entityType];
62
64
  this.discovery = discovery || new discovery_1.KubernetesDiscovery();
65
+ this.sessionManager = new generic_session_manager_1.GenericSessionManager(entityType);
63
66
  }
64
67
  /**
65
68
  * Create a new creation session
66
69
  */
67
70
  createSession(args) {
68
- // Validate session directory exists
69
- (0, session_utils_1.getAndValidateSessionDirectory)(args, true);
70
- const sessionId = this.generateSessionId();
71
- const session = {
72
- sessionId,
71
+ const sessionData = {
73
72
  entityType: this.config.entityType,
74
73
  currentStep: this.config.steps[0], // Start with first step
75
- createdAt: new Date().toISOString(),
76
- updatedAt: new Date().toISOString(),
77
- data: {
78
- // Store capabilities collection if provided (for policy testing with pre-populated data)
79
- capabilitiesCollection: args.collection
80
- }
74
+ // Store capabilities collection if provided (for policy testing with pre-populated data)
75
+ capabilitiesCollection: args.collection
81
76
  };
82
- this.saveSession(session, args);
83
- return session;
77
+ return this.sessionManager.createSession(sessionData);
84
78
  }
85
79
  /**
86
80
  * Load existing session
87
81
  */
88
- loadSession(sessionId, args) {
89
- try {
90
- const sessionDir = (0, session_utils_1.getAndValidateSessionDirectory)(args, false);
91
- const sessionFile = path.join(sessionDir, `${this.config.entityType}-sessions`, `${sessionId}.json`);
92
- if (!fs.existsSync(sessionFile)) {
93
- return null;
94
- }
95
- const sessionData = fs.readFileSync(sessionFile, 'utf8');
96
- return JSON.parse(sessionData);
97
- }
98
- catch (error) {
99
- console.error(`Failed to load ${this.config.entityType} session ${sessionId}:`, error);
100
- return null;
101
- }
82
+ loadSession(sessionId, _args) {
83
+ return this.sessionManager.getSession(sessionId);
102
84
  }
103
85
  /**
104
86
  * Process user response and advance session
105
87
  */
106
- processResponse(sessionId, response, args) {
107
- const session = this.loadSession(sessionId, args);
88
+ processResponse(sessionId, response, _args) {
89
+ const session = this.loadSession(sessionId, _args);
108
90
  if (!session) {
109
91
  throw new Error(`${this.config.displayName} session ${sessionId} not found`);
110
92
  }
111
93
  // Process response based on current step
112
- switch (session.currentStep) {
94
+ switch (session.data.currentStep) {
113
95
  case 'description':
114
96
  session.data.description = response.trim();
115
- session.currentStep = (0, unified_creation_types_1.getNextStep)('description', this.config);
97
+ session.data.currentStep = (0, unified_creation_types_1.getNextStep)('description', this.config);
116
98
  break;
117
99
  case 'triggers':
118
100
  session.data.initialTriggers = response.split(',').map(t => t.trim()).filter(t => t.length > 0);
119
- session.currentStep = (0, unified_creation_types_1.getNextStep)('triggers', this.config);
101
+ session.data.currentStep = (0, unified_creation_types_1.getNextStep)('triggers', this.config);
120
102
  break;
121
103
  case 'trigger-expansion':
122
104
  // Parse JSON response for confirmed triggers
123
105
  try {
124
106
  const confirmed = JSON.parse(response);
125
107
  session.data.expandedTriggers = confirmed;
126
- session.currentStep = (0, unified_creation_types_1.getNextStep)('trigger-expansion', this.config);
108
+ session.data.currentStep = (0, unified_creation_types_1.getNextStep)('trigger-expansion', this.config);
127
109
  }
128
110
  catch (error) {
129
111
  // If not JSON, treat as comma-separated list
130
112
  session.data.expandedTriggers = response.split(',').map(t => t.trim()).filter(t => t.length > 0);
131
- session.currentStep = (0, unified_creation_types_1.getNextStep)('trigger-expansion', this.config);
113
+ session.data.currentStep = (0, unified_creation_types_1.getNextStep)('trigger-expansion', this.config);
132
114
  }
133
115
  break;
134
116
  case 'resources':
135
117
  if (this.config.entityType === 'pattern') {
136
118
  session.data.suggestedResources = response.split(',').map(r => r.trim()).filter(r => r.length > 0);
137
- session.currentStep = (0, unified_creation_types_1.getNextStep)('resources', this.config);
119
+ session.data.currentStep = (0, unified_creation_types_1.getNextStep)('resources', this.config);
138
120
  }
139
121
  break;
140
122
  case 'rationale':
141
123
  session.data.rationale = response.trim();
142
- session.currentStep = (0, unified_creation_types_1.getNextStep)('rationale', this.config);
124
+ session.data.currentStep = (0, unified_creation_types_1.getNextStep)('rationale', this.config);
143
125
  break;
144
126
  case 'created-by':
145
127
  session.data.createdBy = response.trim();
146
- session.currentStep = (0, unified_creation_types_1.getNextStep)('created-by', this.config);
128
+ session.data.currentStep = (0, unified_creation_types_1.getNextStep)('created-by', this.config);
147
129
  break;
148
130
  case 'namespace-scope': {
149
131
  // Parse user's namespace selection
@@ -159,7 +141,7 @@ class UnifiedCreationSessionManager {
159
141
  const namespaces = scopeChoice.replace('exclude:', '').split(',').map(ns => ns.trim()).filter(ns => ns.length > 0);
160
142
  session.data.namespaceScope = { type: 'exclude', namespaces };
161
143
  }
162
- session.currentStep = (0, unified_creation_types_1.getNextStep)('namespace-scope', this.config);
144
+ session.data.currentStep = (0, unified_creation_types_1.getNextStep)('namespace-scope', this.config);
163
145
  break;
164
146
  }
165
147
  case 'kyverno-generation':
@@ -172,7 +154,7 @@ class UnifiedCreationSessionManager {
172
154
  session.data.generatedKyvernoPolicy = response;
173
155
  session.data.kyvernoGenerationError = undefined;
174
156
  }
175
- session.currentStep = (0, unified_creation_types_1.getNextStep)('kyverno-generation', this.config);
157
+ session.data.currentStep = (0, unified_creation_types_1.getNextStep)('kyverno-generation', this.config);
176
158
  break;
177
159
  case 'review':
178
160
  // Handle review step based on entity type
@@ -189,18 +171,18 @@ class UnifiedCreationSessionManager {
189
171
  // Handle cancel or any other response as discard
190
172
  session.data.deploymentChoice = 'discard';
191
173
  }
192
- session.currentStep = 'complete';
174
+ session.data.currentStep = 'complete';
193
175
  }
194
176
  else {
195
177
  // For patterns, user confirmed review
196
- session.currentStep = 'complete';
178
+ session.data.currentStep = 'complete';
197
179
  }
198
180
  break;
199
181
  default:
200
- throw new Error(`Unknown step: ${session.currentStep}`);
182
+ throw new Error(`Unknown step: ${session.data.currentStep}`);
201
183
  }
202
184
  session.updatedAt = new Date().toISOString();
203
- this.saveSession(session, args);
185
+ this.sessionManager.replaceSession(session.sessionId, session.data);
204
186
  return session;
205
187
  }
206
188
  /**
@@ -208,7 +190,7 @@ class UnifiedCreationSessionManager {
208
190
  */
209
191
  async getNextWorkflowStep(session, args) {
210
192
  const sessionId = session.sessionId;
211
- switch (session.currentStep) {
193
+ switch (session.data.currentStep) {
212
194
  case 'description':
213
195
  return {
214
196
  sessionId,
@@ -238,7 +220,7 @@ class UnifiedCreationSessionManager {
238
220
  };
239
221
  }
240
222
  // If not pattern, skip to next step
241
- return this.getNextWorkflowStep({ ...session, currentStep: (0, unified_creation_types_1.getNextStep)('resources', this.config) }, args);
223
+ return this.getNextWorkflowStep({ ...session, data: { ...session.data, currentStep: (0, unified_creation_types_1.getNextStep)('resources', this.config) } }, args);
242
224
  case 'rationale':
243
225
  return {
244
226
  sessionId,
@@ -260,7 +242,7 @@ class UnifiedCreationSessionManager {
260
242
  const kyvernoStatus = await (0, version_1.getKyvernoStatus)();
261
243
  if (!kyvernoStatus.installed) {
262
244
  // Skip namespace-scope if Kyverno not installed, go to next step
263
- session.currentStep = (0, unified_creation_types_1.getNextStep)('namespace-scope', this.config);
245
+ session.data.currentStep = (0, unified_creation_types_1.getNextStep)('namespace-scope', this.config);
264
246
  return this.getNextWorkflowStep(session, args);
265
247
  }
266
248
  // Ensure discovery service is connected to cluster before retrieving namespaces
@@ -286,7 +268,7 @@ class UnifiedCreationSessionManager {
286
268
  case 'complete':
287
269
  return await this.completeWorkflow(session);
288
270
  default:
289
- throw new Error(`Unknown step: ${session.currentStep}`);
271
+ throw new Error(`Unknown step: ${session.data.currentStep}`);
290
272
  }
291
273
  }
292
274
  /**
@@ -690,14 +672,14 @@ The policy intent has been stored in the database. The Kyverno policy was not ap
690
672
  const kyvernoStatus = await (0, version_1.getKyvernoStatus)();
691
673
  if (!kyvernoStatus.policyGenerationReady) {
692
674
  // Skip Kyverno generation and go directly to review with intent-only option
693
- session.currentStep = (0, unified_creation_types_1.getNextStep)('kyverno-generation', this.config);
675
+ session.data.currentStep = (0, unified_creation_types_1.getNextStep)('kyverno-generation', this.config);
694
676
  session.data.kyvernoGenerationSkipped = true;
695
677
  session.data.kyvernoSkipReason = kyvernoStatus.reason || 'Kyverno not available for policy generation';
696
678
  // Generate policy ID since we skipped the normal generation step
697
679
  session.data.policyId = (0, crypto_1.randomUUID)();
698
680
  // Save session and proceed to review
699
681
  if (args) {
700
- this.saveSession(session, args);
682
+ this.sessionManager.replaceSession(session.sessionId, session.data);
701
683
  }
702
684
  return this.generateReviewStep(session);
703
685
  }
@@ -712,7 +694,7 @@ The policy intent has been stored in the database. The Kyverno policy was not ap
712
694
  // Use capabilities collection from session data if provided (for testing with pre-populated data)
713
695
  const resourceSchemas = await this.retrieveRelevantSchemas(data.description || '', finalTriggers, data.capabilitiesCollection);
714
696
  // Prepare session directory for YAML saving
715
- const sessionDir = (0, session_utils_1.getAndValidateSessionDirectory)(args, true);
697
+ const sessionDir = (0, session_utils_1.getAndValidateSessionDirectory)(true);
716
698
  const policySessionDir = path.join(sessionDir, 'policy-sessions');
717
699
  if (!fs.existsSync(policySessionDir)) {
718
700
  fs.mkdirSync(policySessionDir, { recursive: true });
@@ -768,10 +750,10 @@ The policy intent has been stored in the database. The Kyverno policy was not ap
768
750
  });
769
751
  }
770
752
  // Skip display step and go directly to review
771
- session.currentStep = (0, unified_creation_types_1.getNextStep)('kyverno-generation', this.config);
753
+ session.data.currentStep = (0, unified_creation_types_1.getNextStep)('kyverno-generation', this.config);
772
754
  // Save session immediately after generating Kyverno policy AND updating the step
773
755
  if (args) {
774
- this.saveSession(session, args);
756
+ this.sessionManager.replaceSession(session.sessionId, session.data);
775
757
  }
776
758
  return this.getNextWorkflowStep(session, args);
777
759
  }
@@ -930,28 +912,5 @@ ${schemaData.schema}
930
912
  })
931
913
  .join('\n');
932
914
  }
933
- /**
934
- * Save session to file
935
- */
936
- saveSession(session, args) {
937
- try {
938
- const sessionDir = (0, session_utils_1.getAndValidateSessionDirectory)(args, true);
939
- const entitySessionsDir = path.join(sessionDir, `${this.config.entityType}-sessions`);
940
- if (!fs.existsSync(entitySessionsDir)) {
941
- fs.mkdirSync(entitySessionsDir, { recursive: true });
942
- }
943
- const sessionFile = path.join(entitySessionsDir, `${session.sessionId}.json`);
944
- fs.writeFileSync(sessionFile, JSON.stringify(session, null, 2));
945
- }
946
- catch (error) {
947
- throw new Error(`Failed to save ${this.config.displayName.toLowerCase()} session: ${error}`);
948
- }
949
- }
950
- /**
951
- * Generate unique session ID
952
- */
953
- generateSessionId() {
954
- return `${this.config.entityType}-${Date.now()}-${(0, crypto_1.randomUUID)().substring(0, 8)}`;
955
- }
956
915
  }
957
916
  exports.UnifiedCreationSessionManager = UnifiedCreationSessionManager;
@@ -11,32 +11,41 @@ export interface WorkflowConfig {
11
11
  steps: WorkflowStep[];
12
12
  displayName: string;
13
13
  }
14
- export interface UnifiedCreationSession {
15
- sessionId: string;
14
+ /**
15
+ * Session data structure for unified creation workflow
16
+ * Now fits GenericSession<UnifiedCreationSessionData> pattern
17
+ */
18
+ export interface UnifiedCreationSessionData {
16
19
  entityType: EntityType;
17
20
  currentStep: WorkflowStep;
21
+ description?: string;
22
+ initialTriggers?: string[];
23
+ expandedTriggers?: string[];
24
+ suggestedResources?: string[];
25
+ rationale?: string;
26
+ createdBy?: string;
27
+ source?: string;
28
+ policyId?: string;
29
+ generatedKyvernoPolicy?: string;
30
+ kyvernoGenerationError?: string;
31
+ kyvernoGenerationSkipped?: boolean;
32
+ kyvernoSkipReason?: string;
33
+ deploymentChoice?: string;
34
+ namespaceScope?: {
35
+ type: 'all' | 'include' | 'exclude';
36
+ namespaces?: string[];
37
+ };
38
+ capabilitiesCollection?: string;
39
+ }
40
+ /**
41
+ * Legacy type alias for backwards compatibility during refactoring
42
+ * TODO: Remove once all code is updated to use GenericSession<UnifiedCreationSessionData>
43
+ */
44
+ export interface UnifiedCreationSession {
45
+ sessionId: string;
18
46
  createdAt: string;
19
47
  updatedAt: string;
20
- data: {
21
- description?: string;
22
- initialTriggers?: string[];
23
- expandedTriggers?: string[];
24
- suggestedResources?: string[];
25
- rationale?: string;
26
- createdBy?: string;
27
- source?: string;
28
- policyId?: string;
29
- generatedKyvernoPolicy?: string;
30
- kyvernoGenerationError?: string;
31
- kyvernoGenerationSkipped?: boolean;
32
- kyvernoSkipReason?: string;
33
- deploymentChoice?: string;
34
- namespaceScope?: {
35
- type: 'all' | 'include' | 'exclude';
36
- namespaces?: string[];
37
- };
38
- capabilitiesCollection?: string;
39
- };
48
+ data: UnifiedCreationSessionData;
40
49
  }
41
50
  export interface UnifiedWorkflowStepResponse {
42
51
  sessionId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"unified-creation-types.d.ts","sourceRoot":"","sources":["../../src/core/unified-creation-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,YAAY,GACpB,aAAa,GACb,UAAU,GACV,mBAAmB,GACnB,WAAW,GACX,WAAW,GACX,YAAY,GACZ,iBAAiB,GACjB,oBAAoB,GACpB,QAAQ,GACR,oBAAoB,GACpB,UAAU,CAAC;AAEf,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE9C,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,W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AED,wBAAgB,eAAe,CAAC,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,GAAG,YAAY,GAAG,IAAI,CAGtG"}
@@ -295,9 +295,8 @@ async function runEvaluation(evaluatorType, datasetsDir, modelMetadata) {
295
295
  const reportContent = generateMarkdownReport(results, stats, evaluatorType, finalAssessment);
296
296
  const jsonResults = generateJsonReport(results, stats, evaluatorType, modelMetadata, finalAssessment);
297
297
  // Save reports to files
298
- const dateStamp = new Date().toISOString().split('T')[0];
299
- const markdownPath = `./eval/analysis/individual/${evaluatorType}-evaluation-${dateStamp}.md`;
300
- const jsonPath = `./eval/analysis/individual/${evaluatorType}-results-${dateStamp}.json`;
298
+ const markdownPath = `./eval/analysis/individual/${evaluatorType}-evaluation.md`;
299
+ const jsonPath = `./eval/analysis/individual/${evaluatorType}-results.json`;
301
300
  const reportDir = './eval/analysis/individual';
302
301
  // Ensure report directory exists
303
302
  const fs = await Promise.resolve().then(() => __importStar(require('fs')));
@@ -328,6 +327,16 @@ async function main() {
328
327
  catch (error) {
329
328
  console.warn('⚠️ Could not clean debug files:', error instanceof Error ? error.message : String(error));
330
329
  }
330
+ // Clean old evaluation result files from eval/results
331
+ console.log('🧹 Cleaning old evaluation result files...');
332
+ try {
333
+ await execAsync('rm -f ./eval/results/*_comparative_evaluation_*.jsonl 2>/dev/null || true');
334
+ await execAsync('mkdir -p ./eval/results');
335
+ console.log('✅ Old evaluation results cleaned\n');
336
+ }
337
+ catch (error) {
338
+ console.warn('⚠️ Could not clean old evaluation results:', error instanceof Error ? error.message : String(error));
339
+ }
331
340
  // Check model metadata freshness before starting any evaluation work
332
341
  const modelMetadata = loadModelMetadata();
333
342
  const datasetsDir = './eval/datasets';
@@ -7,6 +7,7 @@
7
7
  import { EvaluationScore } from './base.js';
8
8
  import { VercelProvider } from '../../core/providers/vercel-provider';
9
9
  import { DatasetAnalyzer, ComparisonScenario } from '../dataset-analyzer.js';
10
+ import { type EvaluationMetadata } from '../metadata-loader.js';
10
11
  export interface ComparativeEvaluationResult {
11
12
  scenario_summary: string;
12
13
  models_compared: string[];
@@ -49,6 +50,7 @@ export declare abstract class BaseComparativeEvaluator {
49
50
  protected evaluatorModel: VercelProvider;
50
51
  protected datasetAnalyzer: DatasetAnalyzer;
51
52
  protected promptTemplate: string;
53
+ protected metadata: EvaluationMetadata;
52
54
  constructor(datasetDir?: string);
53
55
  /**
54
56
  * Initialize the evaluator - must be called by subclass constructor
@@ -1 +1 @@
1
- {"version":3,"file":"base-comparative.d.ts","sourceRoot":"","sources":["../../../src/evaluation/evaluators/base-comparative.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAKtE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE7E,MAAM,WAAW,2BAA2B;IAC1C,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE;QACnC,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IACH,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CA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