UNPKG

cortexweaver

Version:

CortexWeaver is a command-line interface (CLI) tool that orchestrates a swarm of specialized AI agents, powered by Claude Code and Gemini CLI, to assist in software development. It transforms a high-level project plan (plan.md) into a series of coordinate

248 lines (237 loc) 7.84 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.SchemaTemplates = void 0; const fs = __importStar(require("fs")); const path = __importStar(require("path")); /** * SchemaTemplates handles JSON Schema and contract templates */ class SchemaTemplates { static async createJsonSchemaTemplates(schemasPath) { // Ensure the models directory exists const modelsPath = path.join(schemasPath, 'models'); if (!fs.existsSync(modelsPath)) { fs.mkdirSync(modelsPath, { recursive: true }); } const userSchemaPath = path.join(modelsPath, 'user.schema.json'); if (fs.existsSync(userSchemaPath)) { return; // Don't overwrite existing schema } const userSchemaContent = `{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://example.com/schemas/user.schema.json", "title": "User", "description": "User entity schema for CortexWeaver project", "type": "object", "required": [ "id", "email", "firstName", "lastName", "createdAt" ], "properties": { "id": { "type": "string", "format": "uuid", "description": "Unique identifier for the user" }, "email": { "type": "string", "format": "email", "description": "User's email address" }, "firstName": { "type": "string", "description": "User's first name", "minLength": 1, "maxLength": 50 }, "lastName": { "type": "string", "description": "User's last name", "minLength": 1, "maxLength": 50 }, "createdAt": { "type": "string", "format": "date-time", "description": "Timestamp when the user was created" } }, "additionalProperties": false }`; fs.writeFileSync(userSchemaPath, userSchemaContent); // Create additional schema templates await this.createAdditionalSchemaTemplates(schemasPath); } static async createAdditionalSchemaTemplates(schemasPath) { // Create property invariants template const propertiesPath = path.join(schemasPath, 'properties', 'invariants'); if (!fs.existsSync(propertiesPath)) { fs.mkdirSync(propertiesPath, { recursive: true }); } const authPropertiesPath = path.join(propertiesPath, 'auth.properties.ts'); if (!fs.existsSync(authPropertiesPath)) { const authPropertiesContent = `/** * Authentication Property-Based Test Invariants * These properties define the behavioral contracts for authentication */ export interface AuthProperties { // User registration properties userRegistrationIsIdempotent: boolean; emailMustBeUnique: boolean; passwordMustBeHashed: boolean; // Authentication properties validCredentialsReturnToken: boolean; invalidCredentialsRejectAccess: boolean; tokenExpirationIsRespected: boolean; // Security properties passwordsAreNeverLoggedOrReturned: boolean; tokensAreSecurelyGenerated: boolean; bruteForceAttacksAreThrottled: boolean; } /** * Property-based test generators for authentication */ export const authTestProperties = { // Generate valid user data validUserData: () => ({ email: generateValidEmail(), password: generateSecurePassword(), firstName: generateValidName(), lastName: generateValidName() }), // Generate invalid user data variations invalidUserData: () => ({ email: generateInvalidEmail(), password: generateWeakPassword(), firstName: '', lastName: '' }), // Test invariants invariants: { emailUniqueness: 'No two users can have the same email address', passwordSecurity: 'Passwords must be hashed with bcrypt and salt', tokenSecurity: 'JWT tokens must be signed and have expiration', accessControl: 'Invalid credentials must never grant access' } }; // Helper functions (to be implemented) function generateValidEmail(): string { // Implementation for generating valid test emails return 'test@example.com'; } function generateInvalidEmail(): string { // Implementation for generating invalid test emails return 'invalid-email'; } function generateSecurePassword(): string { // Implementation for generating secure test passwords return 'SecurePass123!'; } function generateWeakPassword(): string { // Implementation for generating weak test passwords return '123'; } function generateValidName(): string { // Implementation for generating valid test names return 'TestName'; }`; fs.writeFileSync(authPropertiesPath, authPropertiesContent); } // Create examples directory and templates const examplesPath = path.join(schemasPath, 'examples'); if (!fs.existsSync(examplesPath)) { fs.mkdirSync(examplesPath, { recursive: true }); } const userExamplesPath = path.join(examplesPath, 'user-examples.json'); if (!fs.existsSync(userExamplesPath)) { const userExamplesContent = `{ "validUsers": [ { "id": "123e4567-e89b-12d3-a456-426614174000", "email": "john.doe@example.com", "firstName": "John", "lastName": "Doe", "createdAt": "2024-01-01T12:00:00Z" }, { "id": "987fcdeb-51a2-43d1-b2c3-123456789abc", "email": "jane.smith@example.com", "firstName": "Jane", "lastName": "Smith", "createdAt": "2024-01-02T14:30:00Z" } ], "invalidUsers": [ { "description": "Missing required field 'id'", "data": { "email": "missing.id@example.com", "firstName": "Missing", "lastName": "ID", "createdAt": "2024-01-01T12:00:00Z" } }, { "description": "Invalid email format", "data": { "id": "123e4567-e89b-12d3-a456-426614174000", "email": "invalid-email", "firstName": "Invalid", "lastName": "Email", "createdAt": "2024-01-01T12:00:00Z" } }, { "description": "Name too long", "data": { "id": "123e4567-e89b-12d3-a456-426614174000", "email": "toolong@example.com", "firstName": "ThisNameIsTooLongAndExceedsTheFiftyCharacterLimit", "lastName": "LastName", "createdAt": "2024-01-01T12:00:00Z" } } ] }`; fs.writeFileSync(userExamplesPath, userExamplesContent); } } } exports.SchemaTemplates = SchemaTemplates; //# sourceMappingURL=schema-templates.js.map