@@ -63,8 +63,28 @@ const verbose = logger.verbose
6363 * Validates an agent file by reading and validating its content,
6464 * including version compatibility checking.
6565 *
66+ * Performs the following validations:
67+ * 1. Content structure validation (frontmatter, headers, keywords)
68+ * 2. Version compatibility checking against current OpenCode version
69+ *
6670 * @param {string } filePath - Path to the agent file to validate
6771 * @returns {{ valid: boolean, error?: string } } Validation result with optional error message
72+ *
73+ * @example
74+ * // Validate an agent file
75+ * const result = validateAgentFile('/path/to/agent.md')
76+ * if (!result.valid) {
77+ * console.error(`Validation failed: ${result.error}`)
78+ * }
79+ *
80+ * @example
81+ * // Use in a file copy loop
82+ * for (const file of agentFiles) {
83+ * const validation = validateAgentFile(join(sourceDir, file))
84+ * if (validation.valid) {
85+ * copyFileSync(join(sourceDir, file), join(targetDir, file))
86+ * }
87+ * }
6888 */
6989function validateAgentFile ( filePath ) {
7090 const content = readFileSync ( filePath , "utf-8" )
@@ -107,6 +127,13 @@ function validateAgentFile(filePath) {
107127 * - 0: All agents installed successfully, or partial success with some failures
108128 * - 1: Complete failure - source directory missing, no agent files found,
109129 * or all file copies failed
130+ *
131+ * @example
132+ * // Run as postinstall script
133+ * main().catch((err) => {
134+ * console.error("Unexpected error:", err.message)
135+ * process.exit(1)
136+ * })
110137 */
111138async function main ( ) {
112139 const prefix = DRY_RUN ? "[DRY-RUN] " : ""
0 commit comments