/** * Standard Operating Procedure (SOP) Type Definitions * * Types for defining, storing, and matching SOPs that guide * agent behavior with standardized procedures. * * @module types/sop.types */ /** * Roles that can have associated SOPs */ export type SOPRole = 'orchestrator' | 'pm' | 'tpm' | 'pgm' | 'developer' | 'frontend-developer' | 'backend-developer' | 'qa' | 'tester' | 'designer' | 'devops'; /** * Categories of SOPs */ export type SOPCategory = 'workflow' | 'quality' | 'communication' | 'escalation' | 'tools' | 'debugging' | 'testing' | 'git' | 'security'; /** * Condition operator for SOP activation */ export type SOPConditionOperator = 'equals' | 'contains' | 'matches'; /** * Condition type for SOP activation */ export type SOPConditionType = 'task-type' | 'file-pattern' | 'project-type' | 'custom'; /** * Condition for SOP activation */ export interface SOPCondition { /** Type of condition */ type: SOPConditionType; /** Value to check against */ value: string; /** Comparison operator */ operator: SOPConditionOperator; } /** * Example demonstrating correct SOP usage */ export interface SOPExample { /** Example title */ title: string; /** Scenario description */ scenario: string; /** How to correctly handle this scenario */ correctApproach: string; /** How NOT to handle this scenario */ incorrectApproach?: string; } /** * Complete SOP definition */ export interface SOP { /** Unique SOP identifier */ id: string; /** Version number (increments on updates) */ version: number; /** ISO timestamp of creation */ createdAt: string; /** ISO timestamp of last update */ updatedAt: string; /** Creator: 'system' or agentId */ createdBy: string; /** Role this SOP applies to, or 'all' for universal */ role: SOPRole | 'all'; /** Category of the SOP */ category: SOPCategory; /** Priority (higher = more important) */ priority: number; /** Short title */ title: string; /** Brief description */ description: string; /** Full SOP content in Markdown */ content: string; /** Keywords that trigger this SOP */ triggers: string[]; /** Optional conditions for activation */ conditions?: SOPCondition[]; /** Categorization tags */ tags: string[]; /** IDs of related SOPs */ relatedSOPs?: string[]; /** Usage examples */ examples?: SOPExample[]; } /** * Entry in the SOP index for fast lookup */ export interface SOPIndexEntry { /** SOP identifier */ id: string; /** Relative path to the SOP file */ path: string; /** Role this SOP applies to */ role: SOPRole | 'all'; /** Category of the SOP */ category: SOPCategory; /** Priority (higher = more important) */ priority: number; /** Keywords that trigger this SOP */ triggers: string[]; /** Short title */ title: string; /** Whether this is a system SOP (true) or custom (false) */ isSystem: boolean; } /** * Complete SOP index */ export interface SOPIndex { /** Index format version */ version: string; /** ISO timestamp of last update */ lastUpdated: string; /** All indexed SOPs */ sops: SOPIndexEntry[]; } /** * Parameters for finding relevant SOPs */ export interface SOPMatchParams { /** Agent role */ role: string; /** Current task context */ taskContext: string; /** Type of task being performed */ taskType?: string; /** File patterns involved */ filePatterns?: string[]; /** Maximum number of SOPs to return */ limit?: number; /** * Team whose installed/custom SOP library should also be surfaced. When set, * SOPs under `~/.crewly/teams//sops/` (written by the wiki `+ SOP` * editor / `update-sop` skill) are merged into the result — closing the * write-to-team-library / read-from-global-store mismatch. */ teamId?: string; } /** * Interface for SOP matching logic */ export interface ISOPMatcher { /** * Find SOPs relevant to the given context * * @param params - Match parameters * @returns Array of matching SOPs, sorted by relevance */ findRelevant(params: SOPMatchParams): Promise; /** * Score how relevant an SOP is to the given context * * @param sop - SOP index entry to score * @param context - Context string * @returns Relevance score (0-1) */ scoreRelevance(sop: SOPIndexEntry, context: string): number; } /** * SOP file frontmatter (YAML header) */ export interface SOPFrontmatter { id: string; version: number; createdAt: string; updatedAt: string; createdBy: string; role: SOPRole | 'all'; category: SOPCategory; priority: number; title: string; description: string; triggers: string[]; conditions?: SOPCondition[]; tags: string[]; relatedSOPs?: string[]; /** * Rule metadata (#877). The concrete failure this rule prevents — or * "none recorded …" for a rule that was never tied to one. */ prevents?: string; /** The model / harness where that failure was seen (#877) */ seenOn?: string; /** YYYY-MM-DD: re-test the rule by this date (switch off, compare, keep or delete) (#877) */ reviewBy?: string; /** Where the failure is documented: an issue or PR link (#877) */ source?: string; } /** * Result of parsing an SOP file */ export interface ParsedSOP { /** Parsed frontmatter */ frontmatter: SOPFrontmatter; /** Markdown content (without frontmatter) */ content: string; /** Parsed examples (if present) */ examples?: SOPExample[]; } /** * SOP constants */ export declare const SOP_CONSTANTS: { /** Directory names */ readonly PATHS: { readonly SOP_DIR: "sops"; readonly SYSTEM_SOP_DIR: "system"; readonly CUSTOM_SOP_DIR: "custom"; readonly INDEX_FILE: "index.json"; }; /** Limits */ readonly LIMITS: { readonly MAX_SOPS_IN_PROMPT: 5; readonly MAX_SOP_CONTENT_LENGTH: 2000; readonly MAX_TRIGGERS_PER_SOP: 20; readonly MAX_CONDITIONS_PER_SOP: 10; readonly MAX_EXAMPLES_PER_SOP: 5; }; /** Matching configuration */ readonly MATCHING: { readonly MIN_TRIGGER_MATCH_SCORE: 0.3; readonly DEFAULT_PRIORITY: 5; readonly ROLE_MATCH_BOOST: 0.3; readonly CATEGORY_MATCH_BOOST: 0.2; }; /** Index version */ readonly INDEX_VERSION: "1.0"; }; /** * Default SOP categories organized by role */ export declare const DEFAULT_SOP_CATEGORIES: Record; /** * All valid SOP roles */ export declare const ALL_SOP_ROLES: SOPRole[]; /** * All valid SOP categories */ export declare const ALL_SOP_CATEGORIES: SOPCategory[]; //# sourceMappingURL=sop.types.d.ts.map