Skip to content

Commit aa7b5e8

Browse files
committed
docs: add comprehensive JSDoc to AGENT_NAMES and REQUIRED_KEYWORDS constants
Signed-off-by: leocavalcante <leo@cavalcante.dev>
1 parent 068513a commit aa7b5e8

2 files changed

Lines changed: 108 additions & 16 deletions

File tree

src/paths.d.mts

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,69 @@ export declare const OPENCODE_VERSION: string
3030

3131
/**
3232
* List of expected agent names (without .md extension).
33-
* This is the single source of truth for agent filenames.
34-
* Frozen to prevent accidental mutation.
33+
*
34+
* This is the single source of truth for agent filenames used during
35+
* installation and uninstallation. Each name maps directly to a `.md`
36+
* file in the `agents/` directory.
37+
*
38+
* **Agent roles:**
39+
* - `opencoder` - Main orchestrator that coordinates the Plan-Build-Commit loop
40+
* - `opencoder-planner` - Analysis subagent that examines codebases and creates prioritized task lists
41+
* - `opencoder-builder` - Execution subagent that implements individual tasks and verifies changes
42+
*
43+
* The array is frozen via `Object.freeze()` to prevent accidental mutation,
44+
* ensuring consistency across the codebase.
45+
*
46+
* @example
47+
* import { AGENT_NAMES } from "./paths.mjs"
48+
*
49+
* // Iterate over agent names to process files
50+
* for (const name of AGENT_NAMES) {
51+
* const filename = `${name}.md`
52+
* console.log(`Processing ${filename}`)
53+
* }
54+
*
55+
* @example
56+
* // Check if a name is a valid agent
57+
* const isValidAgent = AGENT_NAMES.includes("opencoder") // true
58+
* const isInvalid = AGENT_NAMES.includes("unknown") // false
3559
*/
3660
export declare const AGENT_NAMES: readonly ["opencoder", "opencoder-planner", "opencoder-builder"]
3761

3862
/** Minimum character count for valid agent files */
3963
export declare const MIN_CONTENT_LENGTH: number
4064

4165
/**
42-
* Keywords that should appear in valid agent files (case-insensitive).
66+
* Keywords that must appear in valid agent files for content validation.
67+
*
68+
* Used by {@link validateAgentContent} to verify that a file actually contains
69+
* agent-related content rather than arbitrary text. The validation is
70+
* case-insensitive, so "Agent", "TASK", or "task" all match.
71+
*
72+
* **Keyword purposes:**
73+
* - `"agent"` - Identifies the file as defining or describing an agent persona
74+
* - `"task"` - Indicates the file contains task execution logic or instructions
75+
*
76+
* At least one of these keywords must be present for validation to pass.
77+
* This acts as a sanity check to catch corrupted or incorrectly-named files.
4378
*
44-
* These specific keywords were chosen because they indicate the file contains
45-
* agent-related content:
46-
* - "agent": Identifies the file as defining or describing an agent
47-
* - "task": Indicates the file contains task execution logic or instructions
79+
* @example
80+
* import { REQUIRED_KEYWORDS } from "./paths.mjs"
81+
*
82+
* // Manual keyword check (validateAgentContent does this internally)
83+
* const content = "# My Agent\nThis agent handles tasks..."
84+
* const lowerContent = content.toLowerCase()
85+
* const hasKeyword = REQUIRED_KEYWORDS.some(kw => lowerContent.includes(kw))
86+
* console.log(hasKeyword) // true (contains "agent" and "tasks")
87+
*
88+
* @example
89+
* // Invalid content missing keywords
90+
* const badContent = "# Random File\nThis is just some notes."
91+
* const lowerBad = badContent.toLowerCase()
92+
* const isValid = REQUIRED_KEYWORDS.some(kw => lowerBad.includes(kw))
93+
* console.log(isValid) // false (no "agent" or "task")
4894
*
49-
* At least one of these keywords must be present for content validation to pass.
95+
* @see {@link validateAgentContent} - The function that uses these keywords
5096
*/
5197
export declare const REQUIRED_KEYWORDS: readonly ["agent", "task"]
5298

src/paths.mjs

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,69 @@ export const OPENCODE_VERSION = "0.1.0"
3636

3737
/**
3838
* List of expected agent names (without .md extension).
39-
* This is the single source of truth for agent filenames.
40-
* Frozen to prevent accidental mutation.
39+
*
40+
* This is the single source of truth for agent filenames used during
41+
* installation and uninstallation. Each name maps directly to a `.md`
42+
* file in the `agents/` directory.
43+
*
44+
* **Agent roles:**
45+
* - `opencoder` - Main orchestrator that coordinates the Plan-Build-Commit loop
46+
* - `opencoder-planner` - Analysis subagent that examines codebases and creates prioritized task lists
47+
* - `opencoder-builder` - Execution subagent that implements individual tasks and verifies changes
48+
*
49+
* The array is frozen via `Object.freeze()` to prevent accidental mutation,
50+
* ensuring consistency across the codebase.
51+
*
52+
* @example
53+
* import { AGENT_NAMES } from "./paths.mjs"
54+
*
55+
* // Iterate over agent names to process files
56+
* for (const name of AGENT_NAMES) {
57+
* const filename = `${name}.md`
58+
* console.log(`Processing ${filename}`)
59+
* }
60+
*
61+
* @example
62+
* // Check if a name is a valid agent
63+
* const isValidAgent = AGENT_NAMES.includes("opencoder") // true
64+
* const isInvalid = AGENT_NAMES.includes("unknown") // false
4165
*/
4266
export const AGENT_NAMES = Object.freeze(["opencoder", "opencoder-planner", "opencoder-builder"])
4367

4468
/** Minimum character count for valid agent files */
4569
export const MIN_CONTENT_LENGTH = 100
4670

4771
/**
48-
* Keywords that should appear in valid agent files (case-insensitive).
72+
* Keywords that must appear in valid agent files for content validation.
73+
*
74+
* Used by {@link validateAgentContent} to verify that a file actually contains
75+
* agent-related content rather than arbitrary text. The validation is
76+
* case-insensitive, so "Agent", "TASK", or "task" all match.
77+
*
78+
* **Keyword purposes:**
79+
* - `"agent"` - Identifies the file as defining or describing an agent persona
80+
* - `"task"` - Indicates the file contains task execution logic or instructions
81+
*
82+
* At least one of these keywords must be present for validation to pass.
83+
* This acts as a sanity check to catch corrupted or incorrectly-named files.
4984
*
50-
* These specific keywords were chosen because they indicate the file contains
51-
* agent-related content:
52-
* - "agent": Identifies the file as defining or describing an agent
53-
* - "task": Indicates the file contains task execution logic or instructions
85+
* @example
86+
* import { REQUIRED_KEYWORDS } from "./paths.mjs"
87+
*
88+
* // Manual keyword check (validateAgentContent does this internally)
89+
* const content = "# My Agent\nThis agent handles tasks..."
90+
* const lowerContent = content.toLowerCase()
91+
* const hasKeyword = REQUIRED_KEYWORDS.some(kw => lowerContent.includes(kw))
92+
* console.log(hasKeyword) // true (contains "agent" and "tasks")
93+
*
94+
* @example
95+
* // Invalid content missing keywords
96+
* const badContent = "# Random File\nThis is just some notes."
97+
* const lowerBad = badContent.toLowerCase()
98+
* const isValid = REQUIRED_KEYWORDS.some(kw => lowerBad.includes(kw))
99+
* console.log(isValid) // false (no "agent" or "task")
54100
*
55-
* At least one of these keywords must be present for content validation to pass.
101+
* @see {@link validateAgentContent} - The function that uses these keywords
56102
*/
57103
export const REQUIRED_KEYWORDS = ["agent", "task"]
58104

0 commit comments

Comments
 (0)