Skip to content

Code standards compliance#128

Draft
ericelliott wants to merge 15 commits intomainfrom
cursor/code-standards-compliance-0ecd
Draft

Code standards compliance#128
ericelliott wants to merge 15 commits intomainfrom
cursor/code-standards-compliance-0ecd

Conversation

@ericelliott
Copy link
Collaborator

This PR addresses and fixes several code quality and TDD compliance violations identified in the cursor/main-pr-decomposition-2aa2 branch.

Key Changes:

  • Error Handling Refactor: Eliminated duplicate error type definitions (CloneError, FileSystemError, ValidationError) by centralizing their export from lib/error-causes.js. lib/cli-core.js and lib/symlinks.js now import these types, ensuring a single source of truth and correct error-causes library usage.
  • TDD Improvements:
    • Consolidated verbose includes() assertions in agents-md.test.js into a single, more comprehensive array comparison for requiredDirectives.
    • Rewrote given descriptions in agents-md.test.js to accurately describe test situations rather than merely naming variables, improving test clarity and adherence to TDD principles.
  • Code Style: Corrected import ordering in cli-core.js for consistency.

These changes ensure the branch complies with ErrorConstraints and TDDConstraints, and the PR size remains within limits (+785 / -190 LoC).


Open in Web Open in Cursor 

…endering

Remove verbose if/else block in generateFileEntry — optional chaining
handles the absent-frontmatter case cleanly without a placeholder string.
Update the corresponding test expectation to match.
…ng directive

- Add test:e2e to requiredDirectives and directiveAppendSections so agents
  know to run E2E tests before committing
- Add Testing section to agentsMdContent template
- Add ensureClaudeMd: creates or updates CLAUDE.md with agent guidelines
- Add syncRootAgentFiles: keeps AGENTS.md and CLAUDE.md in sync with the
  current template (used by the pre-commit hook)
- Add type declarations (agents-md.d.ts) for all new public exports
- Update tests to cover new functions and the test:e2e directive
- Extract lib/symlinks.js: generic createSymlink({ name, targetBase, force })
  replacing the inline createCursorSymlink in cli-core.js; handles both
  .cursor and .claude (and any future editor symlink) uniformly
- Add --claude flag to the main command for Claude Code integration
- executeClone now accepts a claude option and creates the .claude symlink
  when requested, mirroring the existing cursor option
- executeClone calls ensureClaudeMd so CLAUDE.md is always written on install
- executeClone catch now returns the original Error instance rather than
  a plain object, letting bin/aidd.js pass it directly to handleCliErrors()
- --index handler now calls syncRootAgentFiles after index generation so
  AGENTS.md and CLAUDE.md stay current every time the pre-commit hook runs
- Update help text to document --claude and the combined --cursor --claude usage
- Add engines.node: >=18 to package.json for explicit Node version requirement
- Add tests: createSymlink error dispatch, .claude symlink via executeClone,
  error-result shape (instanceof Error), engines.node declaration
- Pre-commit hook now stages AGENTS.md and CLAUDE.md after running
  `npx aidd --index`, which calls syncRootAgentFiles internally
- This ensures the committed copies stay in sync whenever agentsMdContent
  is updated, exactly as ai/**/index.md files are regenerated on each commit
- Add Testing section to AGENTS.md instructing agents to run test:e2e
  before committing
- Add CLAUDE.md (mirrors AGENTS.md) for Claude Code agent guidelines
The fix(index-generator) commit removed the 'No description available'
placeholder for files without frontmatter. This commit reflects the
regenerated index.md files with that placeholder removed.
Per PR decomposition constraints:

Error types (ValidationError, FileSystemError, CloneError, handleCliErrors)
are now defined once in lib/cli-errors.js and imported wherever used —
cli-core.js, symlinks.js, and bin/aidd.js — instead of being duplicated
or re-exported through cli-core.js.

symlinks.js no longer contains a manual cause.code branch in the catch
block; the validation guard now runs before the try so it cannot be
accidentally caught and re-dispatched.

Tests use whole-object assertions instead of one property per assert:
- createSymlink error test collapses two tests into one { name, code } check
- executeClone error shape test collapses two tests into { isError, causeCode }
- syncRootAgentFiles / ensureClaudeMd tests combine action + content checks
- agentsMdContent e2e tests merged into one { hasCommand, hasExplanation }
…rtions

Per ErrorConstraints:

- lib/cli-errors.d.ts is now the single source of truth for error shapes.
  Defines CausedError (the common contract for all createError() output)
  and the error template objects (CloneError, FileSystemError,
  ValidationError) as plain spread templates, not separate types.
  handleCliErrors uses Record<string, (error: CausedError) => unknown>.

- lib/cli-core.d.ts removes ExecuteCloneError and imports CausedError for
  the error branch of ExecuteCloneResult.

- Tests no longer assert specific error type names or codes (cause.name,
  cause.code). They verify only that a CausedError was thrown (instanceof
  Error with a structured cause), which is all that matters for dispatch.
lib/error-causes.js and lib/error-causes.d.ts are the single module for
all error-causes library integration — CausedError type, error template
objects, and handleCliErrors. Update imports in cli-core.js, symlinks.js,
bin/aidd.js, and cli-core.d.ts.
error-causes.d.ts now declares exactly two things:
  - CausedError: the common shape of all createError() output
  - handleCliErrors: the dispatch factory

error-causes.js exports only handleCliErrors. The error template objects
(CloneError, FileSystemError, ValidationError) are defined as local
constants in cli-core.js and symlinks.js — they are symbolic literals,
not types, so local definition is appropriate and avoids exposing them
through the type system.
Test error messages directly instead of checking instanceof Error.
Let the type checker handle type assertions automatically.
- testingSection !== undefined → actual keywords array
- results.every(...) → results.map(action) compared to full array
- hasAgentsRef boolean → full appended content string
- given/should strings updated to describe functional requirements
  without referencing literal implementation details
…ication

ErrorConstraints: CloneError, FileSystemError, ValidationError were defined
in both cli-core.js and symlinks.js. Now defined once via errorCauses() in
error-causes.js and imported by both consumers.

TDDConstraints: consolidate four one-property-at-a-time assertions in
requiredDirectives test into a single whole-array assertion. Fix given
descriptions that named variables instead of describing situations.
@cursor
Copy link
Contributor

cursor bot commented Mar 6, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

…nchanged paths, complete symlink assertion

- bin/aidd.js: wrap syncRootAgentFiles in try/catch so filesystem errors
  produce a clean error message instead of an unhandled rejection; remove
  two unreachable return statements after process.exit()
- agents-md.js: wrap syncRootAgentFiles file ops in try/catch and throw
  AgentsFileError for consistency with all other file operations in the module
- agents-md.test.js: add two missing tests for ensureClaudeMd unchanged
  paths (full-template match and existing AGENTS.md reference)
- symlinks.test.js: extend force-replace assertion to verify symlink target
  points to ai/, matching the whole-object pattern used by other symlink tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants