Repository navigation
feat(riviere-cli): add extract command for component extraction - #88
Conversation
Implements `riviere extract --config <path>` command that: - Loads and validates extraction config from YAML - Runs component extraction using riviere-extract-ts - Outputs draft components as JSON to stdout - Provides clear error messages for missing or invalid configs Co-Authored-By: Claude Opus 4.5 <[email protected]>
…riviere-extract-co
|
Warning Rate limit exceeded@NTCoding has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 38 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (134)
📝 WalkthroughWalkthroughAdds a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as riviere extract
participant FS as File System
participant Parser as YAML/Schema Validator
participant Globber as Glob Resolver
participant TSMorph as ts-morph Project
participant Extractor as extractComponents
participant Out as STDOUT (JSON)
User->>CLI: riviere extract --config config.yaml
CLI->>FS: stat config.yaml
alt not found
CLI->>Out: emit error { code: CONFIG_NOT_FOUND, ... }
else found
CLI->>FS: read config.yaml
CLI->>Parser: parse & validate YAML
alt parse/validation error
CLI->>Out: emit error { code: VALIDATION_ERROR, details }
else valid
CLI->>Globber: resolve module globs (relative to config dir)
Globber->>FS: match file paths
Globber->>CLI: matched paths
CLI->>TSMorph: create Project & add files
CLI->>Extractor: extractComponents(project, paths, config)
Extractor->>CLI: components[]
CLI->>Out: emit success { success: true, data: components }
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Deploying living-architecture with
|
| Latest commit: |
2c9255f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f3d12ef6.living-architecture.pages.dev |
| Branch Preview URL: | https://issue-44-m4-d4-1-add-riviere.living-architecture.pages.dev |
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||||||
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Fix all issues with AI agents
In @packages/riviere-cli/package.json:
- Around line 29-36: The package.json is missing an "engines" declaration to
require Node.js 20+, causing installs on older Node versions to succeed despite
dependencies (commander and glob) needing Node 20; add an "engines" field in
package.json with "node": ">=20" so package managers and CI enforce the minimum
Node version, ensuring compatibility with the listed dependencies.
In @packages/riviere-cli/src/cli.ts:
- Line 23: The docs generator is excluding the top-level "extract" command
because generate-docs.ts only keeps commands whose fullName startsWith('riviere
builder') or startsWith('riviere query'), so ensure the filter includes the
extract command (whose command is wired via createExtractCommand / registered as
'extract') by adding startsWith('riviere extract') or by changing the filter
logic to include non-subcommands; also address missing workflow prompt
references by creating the referenced docs/workflow/step-1 .. step-6 files or
removing/updating the learnings entries to point to existing workflow docs so
generated documentation no longer references nonexistent files.
In @packages/riviere-cli/src/commands/extract/extract.spec.ts:
- Around line 1-47: The type guard is too permissive and parseExtractionOutput
assumes the JSON is on consoleOutput[0]; tighten isExtractionOutput to validate
each DraftComponent (at least check that data[0] has type, name, domain and
location.file and location.line) and update parseExtractionOutput to locate and
JSON.parse the first line that looks like JSON (not just index 0) before passing
it to isExtractionOutput; reference the DraftComponent and ExtractionOutput
shapes, the isExtractionOutput function, and parseExtractionOutput when making
these checks and the scanning change.
In @packages/riviere-cli/src/commands/extract/extract.ts:
- Around line 67-74: Add a distinct ParseError variant to the CliErrorCode enum
and use it when parseResult indicates a YAML syntax/parsing failure: update the
enum (CliErrorCode) to include ParseError, detect parse vs schema errors in the
parsing flow (the parseResult object returned where parseResult.success is
false), and call formatError(CliErrorCode.ParseError, ...) for malformed YAML
while retaining formatError(CliErrorCode.ValidationError, ...) for schema
validation failures so logs and error consumers can distinguish the two cases.
- Around line 89-94: After resolving config (config) and computing
sourceFilePaths from config.modules, add a validation that sourceFilePaths is
not empty: if sourceFilePaths.length === 0, fail fast with a clear, actionable
error message that indicates no files matched the provided glob patterns from
config.modules and include the resolved config path (configDir) or the offending
module pattern(s) so the user can correct the extraction config; perform this
check immediately after the existing sourceFilePaths assignment and throw or
return an error/exit with a non-zero status to stop silent zero-component
output.
- Around line 55-62: The action handler currently logs config/missing-file
errors (e.g., the existsSync check using options.config and formatError with
CliErrorCode.ConfigNotFound) and returns, which leaves the process exit code as
zero; replace those early returns with throwing an Error (or calling
process.exit(1)) so the CLI fails in CI. Concretely, in the block that logs the
config-not-found error and in the other error-paths (the blocks around the
checks at lines ~68-73 and ~78-86), either throw a descriptive Error (including
the same formatted message) or invoke process.exit(1) immediately after logging;
ensure you update all referenced spots (options.config check, the other
validation branches) so every error path results in a non-zero exit/failure
signal.
- Around line 96-99: The current loop creates a Project and calls
Project.addSourceFileAtPath for each path; replace this with a single call to
Project.addSourceFilesAtPaths(sourceFilePaths) to add files in batch (use the
same Project constructor), remove any unnecessary tsconfig loading since default
compiler options suffice for AST extraction, and delete the for-loop that
iterates over sourceFilePaths while keeping the Project instantiation and
subsequent usage intact.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (7)
.claude/settings.jsonpackages/riviere-cli/package.jsonpackages/riviere-cli/src/cli.tspackages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.tspackages/riviere-cli/src/error-codes.tspackages/riviere-cli/tsconfig.lib.json
💤 Files with no reviewable changes (1)
- .claude/settings.json
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx,js,jsx}: When writing, editing, refactoring, or reviewing code, always followdocs/conventions/software-design.md
Look for standard implementation patterns defined indocs/conventions/standard-patterns.md
Avoid anti-patterns defined in@docs/conventions/anti-patterns.md
100% test coverage is mandatory and enforced
Use domain terminology fromdocs/architecture/domain-terminology/contextive/definitions.glossary.yml. Do not invent new terms or use technical jargon when domain terminology exists
Never commit secrets, API keys, or credentials. Use environment variables for sensitive configuration. Do not log sensitive data (passwords, tokens, PII). Validate and sanitize all external input
Files:
packages/riviere-cli/src/error-codes.tspackages/riviere-cli/src/commands/extract/extract.tspackages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/cli.ts
**/*.{ts,tsx,js,jsx,json,css,scss}
📄 CodeRabbit inference engine (CLAUDE.md)
All UI and UX design must conform to global brand guidelines:
/docs/brand/(logo, colors, typography, icons)
Files:
packages/riviere-cli/src/error-codes.tspackages/riviere-cli/package.jsonpackages/riviere-cli/src/commands/extract/extract.tspackages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/tsconfig.lib.jsonpackages/riviere-cli/src/cli.ts
packages/**
📄 CodeRabbit inference engine (CLAUDE.md)
Create new shared libraries as publishable packages in the
packages/directory usingpnpm nx g @nx/js:library packages/[pkg-name] --publishable --importPath=@living-architecture/[pkg-name]
Files:
packages/riviere-cli/src/error-codes.tspackages/riviere-cli/package.jsonpackages/riviere-cli/src/commands/extract/extract.tspackages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/tsconfig.lib.jsonpackages/riviere-cli/src/cli.ts
**/*.json
📄 CodeRabbit inference engine (CLAUDE.md)
After generating a new project, update the project's package.json with correct name:
@living-architecture/[project-name]
Files:
packages/riviere-cli/package.jsonpackages/riviere-cli/tsconfig.lib.json
**/*.spec.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Follow
docs/conventions/testing.mdfor all test files
Files:
packages/riviere-cli/src/commands/extract/extract.spec.ts
🧠 Learnings (24)
📓 Common learnings
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.test.{ts,tsx} : Implement integration tests for end-to-end extraction from TypeScript code to JSON output
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/architecture/overview.md:0-0
Timestamp: 2026-01-08T22:20:13.250Z
Learning: Applies to docs/architecture/**/*extract*.ts : Use `living-architecture/riviere-extract-ts` TypeScript extractor with ts-morph for AST parsing when implementing TypeScript extraction for architecture schema components
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/architecture/overview.md:0-0
Timestamp: 2026-01-08T22:20:13.250Z
Learning: Applies to docs/architecture/**/*extract*.{json,ts} : Define extraction configuration using the JSON Schema from `living-architecture/riviere-extract-config` DSL
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Implement extraction logic as pure functions with no side effects
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-conventions/CLAUDE.md:0-0
Timestamp: 2026-01-08T07:05:01.766Z
Learning: Import and use the default extraction config from `living-architecture/riviere-extract-conventions/default-config` in extraction tooling to detect all 6 component types
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/architecture/overview.md:0-0
Timestamp: 2026-01-08T22:20:13.250Z
Learning: Applies to docs/architecture/**/*extract*.ts : Use the Rivière Builder Node.js library to programmatically construct the schema graph when implementing custom extraction code
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-config/CLAUDE.md:0-0
Timestamp: 2026-01-06T23:01:34.751Z
Learning: Applies to packages/riviere-extract-config/**/*.ts : Extraction config schema is the source of truth for valid structures. TypeScript types must mirror the schema definition to maintain consistency
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Reject invalid extraction configs at load time, not during extraction phase
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Use glob pattern matching for module-based organization of extraction rules
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-cli/CLAUDE.md:0-0
Timestamp: 2026-01-02T11:58:27.018Z
Learning: When modifying CLI commands in the riviere-cli tool, update the corresponding workflow prompts in docs/workflow/ directory (step-1 through step-6) to keep the extraction workflow in sync
📚 Learning: 2026-01-06T23:01:34.751Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-config/CLAUDE.md:0-0
Timestamp: 2026-01-06T23:01:34.751Z
Learning: Applies to packages/riviere-extract-config/**/*.ts : Extraction config schema is the source of truth for valid structures. TypeScript types must mirror the schema definition to maintain consistency
Applied to files:
packages/riviere-cli/src/error-codes.tspackages/riviere-cli/package.jsonpackages/riviere-cli/src/commands/extract/extract.tspackages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/tsconfig.lib.json
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Use ts-morph for TypeScript AST parsing instead of other parsers
Applied to files:
packages/riviere-cli/package.jsonpackages/riviere-cli/src/commands/extract/extract.tspackages/riviere-cli/tsconfig.lib.jsonpackages/riviere-cli/src/cli.ts
📚 Learning: 2026-01-08T19:36:17.306Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/conventions/codebase-structure.md:0-0
Timestamp: 2026-01-08T19:36:17.306Z
Learning: Applies to docs/conventions/packages/*/package.json : When importing from another project, add explicit workspace dependencies to package.json using the format "living-architecture/[pkg-name]": "workspace:*" and run pnpm install.
Applied to files:
packages/riviere-cli/package.json
📚 Learning: 2026-01-08T19:36:17.306Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/conventions/codebase-structure.md:0-0
Timestamp: 2026-01-08T19:36:17.306Z
Learning: Applies to docs/conventions/apps/*/package.json : When importing from another project, add explicit workspace dependencies to package.json using the format "living-architecture/[pkg-name]": "workspace:*" and run pnpm install.
Applied to files:
packages/riviere-cli/package.json
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Implement extraction logic as pure functions with no side effects
Applied to files:
packages/riviere-cli/package.jsonpackages/riviere-cli/src/commands/extract/extract.tspackages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/tsconfig.lib.jsonpackages/riviere-cli/src/cli.ts
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Use glob pattern matching for module-based organization of extraction rules
Applied to files:
packages/riviere-cli/package.jsonpackages/riviere-cli/src/commands/extract/extract.tspackages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/tsconfig.lib.jsonpackages/riviere-cli/src/cli.ts
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.test.{ts,tsx} : Implement integration tests for end-to-end extraction from TypeScript code to JSON output
Applied to files:
packages/riviere-cli/package.jsonpackages/riviere-cli/src/commands/extract/extract.tspackages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/tsconfig.lib.jsonpackages/riviere-cli/src/cli.ts
📚 Learning: 2026-01-08T22:20:13.250Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/architecture/overview.md:0-0
Timestamp: 2026-01-08T22:20:13.250Z
Learning: Applies to docs/architecture/**/*extract*.ts : Use `living-architecture/riviere-extract-ts` TypeScript extractor with ts-morph for AST parsing when implementing TypeScript extraction for architecture schema components
Applied to files:
packages/riviere-cli/package.jsonpackages/riviere-cli/src/commands/extract/extract.tspackages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/tsconfig.lib.jsonpackages/riviere-cli/src/cli.ts
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.test.{ts,tsx} : Use ts-morph's in-memory file system (`useInMemoryFileSystem: true`) for fast isolated tests
Applied to files:
packages/riviere-cli/package.jsonpackages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/tsconfig.lib.json
📚 Learning: 2026-01-02T11:58:27.018Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-cli/CLAUDE.md:0-0
Timestamp: 2026-01-02T11:58:27.018Z
Learning: When modifying CLI commands in the riviere-cli tool, update the corresponding workflow prompts in docs/workflow/ directory (step-1 through step-6) to keep the extraction workflow in sync
Applied to files:
packages/riviere-cli/package.jsonpackages/riviere-cli/src/cli.ts
📚 Learning: 2026-01-08T22:20:13.250Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/architecture/overview.md:0-0
Timestamp: 2026-01-08T22:20:13.250Z
Learning: Applies to docs/architecture/**/*extract*.{json,ts} : Define extraction configuration using the JSON Schema from `living-architecture/riviere-extract-config` DSL
Applied to files:
packages/riviere-cli/package.jsonpackages/riviere-cli/src/commands/extract/extract.tspackages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/tsconfig.lib.jsonpackages/riviere-cli/src/cli.ts
📚 Learning: 2026-01-08T22:20:13.250Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/architecture/overview.md:0-0
Timestamp: 2026-01-08T22:20:13.250Z
Learning: Applies to docs/architecture/**/*extract*.ts : Use the Rivière Builder Node.js library to programmatically construct the schema graph when implementing custom extraction code
Applied to files:
packages/riviere-cli/package.jsonpackages/riviere-cli/src/commands/extract/extract.tspackages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/tsconfig.lib.jsonpackages/riviere-cli/src/cli.ts
📚 Learning: 2026-01-08T22:20:13.250Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/architecture/overview.md:0-0
Timestamp: 2026-01-08T22:20:13.250Z
Learning: Applies to docs/architecture/**/*.{ts,tsx} : Apply decorators from `living-architecture/riviere-extract-conventions` to mark all classes as architectural components
Applied to files:
packages/riviere-cli/package.jsonpackages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-08T07:05:01.766Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-conventions/CLAUDE.md:0-0
Timestamp: 2026-01-08T07:05:01.766Z
Learning: Import and use the default extraction config from `living-architecture/riviere-extract-conventions/default-config` in extraction tooling to detect all 6 component types
Applied to files:
packages/riviere-cli/src/commands/extract/extract.tspackages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/cli.ts
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Reject invalid extraction configs at load time, not during extraction phase
Applied to files:
packages/riviere-cli/src/commands/extract/extract.tspackages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/tsconfig.lib.jsonpackages/riviere-cli/src/cli.ts
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: All extraction rules should come from validated ExtractionConfig provided by riviere-extract-config
Applied to files:
packages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.test.{ts,tsx} : Implement unit tests for each predicate type in isolation with positive and negative cases
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.ts
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/vitest.config.mts : Enforce 100% code coverage using Vitest with v8 coverage and thresholds configured in vitest.config.mts
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.ts
📚 Learning: 2026-01-08T06:46:00.609Z
Learnt from: NTCoding
Repo: NTCoding/living-architecture PR: 66
File: packages/riviere-extract-conventions/src/eslint/require-component-decorator.spec.ts:19-21
Timestamp: 2026-01-08T06:46:00.609Z
Learning: In test files using typescript-eslint/rule-tester's RuleTester.run(), ensure there is an explicit it() block with at least one expect() assertion (e.g., expect(rule).toBeDefined()) to satisfy sonarjs/no-empty-test-file and sonarjs/assertions-in-tests lint rules, which don’t recognize RuleTester's internal test blocks. Apply this pattern to all spec.ts test files to maintain consistency and pass lint checks.
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.ts
📚 Learning: 2026-01-08T19:36:17.306Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/conventions/codebase-structure.md:0-0
Timestamp: 2026-01-08T19:36:17.306Z
Learning: Applies to docs/conventions/packages/*/tsconfig.lib.json : The tsconfig.lib.json file must extend tsconfig.base.json, set outDir to ./dist, rootDir to ./src, and include only src/**/*.ts while excluding src/**/*.test.ts files.
Applied to files:
packages/riviere-cli/tsconfig.lib.json
📚 Learning: 2026-01-08T19:36:17.306Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/conventions/codebase-structure.md:0-0
Timestamp: 2026-01-08T19:36:17.306Z
Learning: Applies to docs/conventions/apps/*/tsconfig.lib.json : The tsconfig.lib.json file must extend tsconfig.base.json, set outDir to ./dist, rootDir to ./src, and include only src/**/*.ts while excluding src/**/*.test.ts files.
Applied to files:
packages/riviere-cli/tsconfig.lib.json
📚 Learning: 2026-01-08T12:57:19.167Z
Learnt from: NTCoding
Repo: NTCoding/living-architecture PR: 67
File: packages/riviere-extract-ts/tsconfig.spec.json:5-22
Timestamp: 2026-01-08T12:57:19.167Z
Learning: In tsconfig.spec.json files, use expanded types array ["vitest/globals", "vitest/importMeta", "vite/client", "node", "vitest"] for complete test type coverage. Include patterns should cover .test and .spec files, config files (vitest.config.ts/mts, vite.config.ts/mts), multiple extensions (.ts, .tsx, .js, .jsx), and .d.ts files to ensure proper TypeScript coverage across the testing environment.
Applied to files:
packages/riviere-cli/tsconfig.lib.json
📚 Learning: 2026-01-02T11:58:27.018Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-cli/CLAUDE.md:0-0
Timestamp: 2026-01-02T11:58:27.018Z
Learning: After modifying CLI commands, run `nx generate-docs riviere-cli` to regenerate CLI reference documentation
Applied to files:
packages/riviere-cli/src/cli.ts
🧬 Code graph analysis (2)
packages/riviere-cli/src/commands/extract/extract.spec.ts (2)
packages/riviere-cli/src/cli.ts (1)
createProgram(44-78)packages/riviere-cli/src/command-test-fixtures.ts (4)
TestContext(55-59)createTestContext(61-67)setupCommandTest(69-83)parseErrorOutput(27-37)
packages/riviere-cli/src/cli.ts (1)
packages/riviere-cli/src/commands/extract/extract.ts (1)
createExtractCommand(50-105)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: browser-tests (chromium)
- GitHub Check: main
- GitHub Check: browser-tests (firefox)
- GitHub Check: browser-tests (webkit)
- GitHub Check: Cloudflare Pages
🔇 Additional comments (11)
packages/riviere-cli/src/error-codes.ts (1)
14-14: Good addition; keeps CLI error taxonomy explicit.
CONFIG_NOT_FOUNDis a clear, actionable code for the missing config scenario.packages/riviere-cli/tsconfig.lib.json (1)
14-25: Project references look consistent with repo tsconfig conventions—please confirm intended build graph.
The updatedreferencesalign with the new extract feature’s package dependencies; just ensure these projects are meant to participate intsc -bfor the CLI package (not only in tests). Based on learnings, tsconfig.lib.json structure looks correct.packages/riviere-cli/src/commands/extract/extract.spec.ts (3)
49-56: Command registration test is solid.
Directly asserts the command exists at the top level (matches the desired UX).
58-99: Error-path coverage is good; consider also asserting CI-friendly exit behavior (if required).
You validate missing file and invalid config inputs well. If CI usage expects non-zero exit codes on failure, add an assertion aroundprocess.exitCode(or assert the command rejects/throws)—right now errors are “successful runs” from the process perspective.
101-150: Success-path test is good; make the YAML config minimal to reduce brittleness.
The{ notUsed: true }fields risk turning into schema-invalid values if the extraction config schema becomes stricter; prefer omitting unused component types (or using the schema’s official “disable” mechanism, if any).Proposed diff
await writeFile( configPath, ` modules: - name: orders path: "**/src/**/*.ts" - api: { notUsed: true } useCase: find: classes where: hasJSDoc: tag: useCase - domainOp: { notUsed: true } - event: { notUsed: true } - eventHandler: { notUsed: true } - ui: { notUsed: true } `, )⛔ Skipped due to learnings
Learnt from: CR Repo: NTCoding/living-architecture PR: 0 File: packages/riviere-extract-config/CLAUDE.md:0-0 Timestamp: 2026-01-06T23:01:34.751Z Learning: Extraction config schemas must define all six required component types per module: api, useCase, domainOp, event, eventHandler, and ui. Unused component types must be explicitly marked with `notUsed: true` rather than omittedLearnt from: CR Repo: NTCoding/living-architecture PR: 0 File: docs/architecture/overview.md:0-0 Timestamp: 2026-01-08T22:20:13.250Z Learning: Applies to docs/architecture/**/*extract*.{json,ts} : Define extraction configuration using the JSON Schema from `living-architecture/riviere-extract-config` DSLLearnt from: CR Repo: NTCoding/living-architecture PR: 0 File: docs/workflow/code-review.md:0-0 Timestamp: 2026-01-07T08:54:48.071Z Learning: Applies to docs/workflow/**/*.{ts,tsx,js,jsx} : Review usage of `/* v8 ignore next -- preserve */` coverage skip directives. This is only acceptable for unreachable code needed to satisfy the compiler. Most cases should be solved by extracting code or writing tests to mock behavior.Learnt from: CR Repo: NTCoding/living-architecture PR: 0 File: packages/riviere-extract-config/CLAUDE.md:0-0 Timestamp: 2026-01-06T23:01:34.751Z Learning: Applies to packages/riviere-extract-config/**/*.ts : Extraction config schema is the source of truth for valid structures. TypeScript types must mirror the schema definition to maintain consistencyLearnt from: CR Repo: NTCoding/living-architecture PR: 0 File: CLAUDE.md:0-0 Timestamp: 2026-01-09T18:58:21.008Z Learning: Applies to **/*.config.ts : Add vitest.config.ts if tests are needed with 100% coverage as the defaultLearnt from: CR Repo: NTCoding/living-architecture PR: 0 File: packages/riviere-extract-ts/CLAUDE.md:0-0 Timestamp: 2026-01-08T17:19:17.148Z Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Reject invalid extraction configs at load time, not during extraction phaseLearnt from: CR Repo: NTCoding/living-architecture PR: 0 File: docs/workflow/code-review.md:0-0 Timestamp: 2026-01-07T08:54:48.071Z Learning: Applies to docs/workflow/**/*.{ts,tsx,js,jsx,!(**/*.test.ts,**/*.test.tsx,**/*.test.js,**/*.spec.ts,**/*.spec.tsx,**/*.spec.js)} : Organize code by usage (vertical slice organization), not by type. Avoid folders/files named: types/, models/, validators/, assertions/, schemas/, interfaces/, or files like types.ts, models.ts, validators.ts. Group items by what uses them together, not by category.Learnt from: CR Repo: NTCoding/living-architecture PR: 0 File: docs/architecture/overview.md:0-0 Timestamp: 2026-01-08T22:20:13.250Z Learning: Applies to docs/architecture/**/*extract*.ts : Use `living-architecture/riviere-extract-ts` TypeScript extractor with ts-morph for AST parsing when implementing TypeScript extraction for architecture schema componentsLearnt from: CR Repo: NTCoding/living-architecture PR: 0 File: docs/conventions/software-design.md:0-0 Timestamp: 2026-01-08T23:16:02.639Z Learning: Applies to docs/conventions/**/*.{ts,tsx} : Parse, don't validate. Use Zod schemas at system boundaries to parse external data once. Don't scatter `isX(unknown): x is T` type guards throughout the codebase.Learnt from: CR Repo: NTCoding/living-architecture PR: 0 File: docs/conventions/software-design.md:0-0 Timestamp: 2026-01-08T23:16:02.639Z Learning: Applies to docs/conventions/**/*.{ts,tsx} : Make illegal states unrepresentable. Use discriminated unions, not optional fields. If a state combination shouldn't exist, make the type system forbid it.Learnt from: CR Repo: NTCoding/living-architecture PR: 0 File: packages/riviere-extract-ts/CLAUDE.md:0-0 Timestamp: 2026-01-08T17:19:17.148Z Learning: Applies to packages/riviere-extract-ts/**/*.test.{ts,tsx} : Implement integration tests for end-to-end extraction from TypeScript code to JSON outputLearnt from: CR Repo: NTCoding/living-architecture PR: 0 File: packages/riviere-extract-ts/CLAUDE.md:0-0 Timestamp: 2026-01-08T17:19:17.148Z Learning: Applies to packages/riviere-extract-ts/**/*.test.{ts,tsx} : Implement unit tests for each predicate type in isolation with positive and negative casesLearnt from: CR Repo: NTCoding/living-architecture PR: 0 File: packages/riviere-extract-ts/CLAUDE.md:0-0 Timestamp: 2026-01-08T17:19:17.148Z Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Implement extraction logic as pure functions with no side effectsLearnt from: NTCoding Repo: NTCoding/living-architecture PR: 66 File: packages/riviere-extract-conventions/src/eslint/require-component-decorator.spec.ts:19-21 Timestamp: 2026-01-08T06:46:05.503Z Learning: In test files using typescript-eslint/rule-tester's RuleTester.run(), include an explicit it() block with an expect() assertion (e.g., expect(rule).toBeDefined()) to satisfy sonarjs/no-empty-test-file and sonarjs/assertions-in-tests lint rules, which don't recognize RuleTester's internal test blocks.Learnt from: CR Repo: NTCoding/living-architecture PR: 0 File: packages/riviere-extract-ts/CLAUDE.md:0-0 Timestamp: 2026-01-08T17:19:17.148Z Learning: Applies to packages/riviere-extract-ts/**/*.test.{ts,tsx} : Use ts-morph's in-memory file system (`useInMemoryFileSystem: true`) for fast isolated testsLearnt from: CR Repo: NTCoding/living-architecture PR: 0 File: docs/conventions/testing.md:0-0 Timestamp: 2026-01-04T17:04:31.759Z Learning: Applies to docs/conventions/**/*.spec.{ts,tsx,js,jsx} : Test edge cases for collections: empty collection, single element, duplicates, nested structures, circular references, large collections, sparse arrays, and mixed typesLearnt from: CR Repo: NTCoding/living-architecture PR: 0 File: docs/conventions/testing.md:0-0 Timestamp: 2026-01-04T17:04:31.759Z Learning: Applies to docs/conventions/**/*.spec.{ts,tsx,js,jsx} : Use Arrange-Act-Assert structure for tests: set up test data, execute behavior, then verify outcomespackages/riviere-cli/src/commands/extract/extract.ts (6)
1-20: LGTM: Imports are well-organized and comprehensive.All required dependencies are properly imported and align with the command's functionality for YAML parsing, glob resolution, TypeScript AST analysis, and extraction.
22-32: LGTM: Well-structured type definitions.The discriminated union pattern for
ParseResultenables type-safe error handling, and usingunknownfor unparsed data is the correct approach before validation.
34-48: LGTM: Robust error handling with defensive programming.The defensive guard for non-Error instances is appropriate, and the discriminated union return type enables type-safe error handling in the caller.
50-54: LGTM: Standard Commander.js command setup.The command structure with required options and typed action handler follows Commander.js best practices.
76-87: LGTM: Proper config validation following extraction config patterns.The two-step validation (type guard followed by detailed validation) correctly rejects invalid configs at load time before extraction, as per project conventions.
Based on learnings, this follows the pattern of rejecting invalid extraction configs at load time rather than during extraction.
101-104: Remove error handling concern for extractComponents—function is designed as pure with defensive returns.The
extractComponentscall doesn't require try-catch wrapping. It's a pure function using defensive early returns (empty arrays) rather than throwing exceptions. Config validation already happens upfront (lines 76–87) following the "fail fast" principle: invalid configs are rejected at load time, extraction errors degrade gracefully.Likely an incorrect or invalid review comment.
…e loading Addresses CodeRabbit feedback: - Fail fast with clear error when no files match extraction patterns - Use addSourceFilesAtPaths for batch file loading instead of loop Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In @packages/riviere-cli/src/commands/extract/extract.spec.ts:
- Around line 30-35: The type guard isExtractionOutput should also validate each
element of the data array conforms to the DraftComponent shape: update
isExtractionOutput to, after confirming value.data is an array, check
value.data.every(...) and inside ensure required DraftComponent properties
(e.g., id/name/type or whatever unique fields DraftComponent defines) exist and
have correct primitive types; keep the overall signature (value is
ExtractionOutput) and reference DraftComponent and ExtractionOutput so failures
surface earlier and more clearly in tests.
In @packages/riviere-cli/src/commands/extract/extract.ts:
- Around line 54-62: The CLI currently prints error JSON but still exits with
code 0; inside the .action handler for the extract command (the function taking
ExtractOptions) set process.exitCode = 1 immediately before each early return on
error — e.g., after the existsSync config-file check and similarly in the other
error branches referenced (the ones around the checks at lines 73, 86, and 106)
so every error path sets process.exitCode = 1 before returning; update those
branches where formatError/CliErrorCode JSON is logged to set process.exitCode =
1.
- Around line 109-114: Wrap the component extraction flow in a try-catch so
runtime exceptions from Project.addSourceFilesAtPaths or extractComponents
produce structured JSON error output instead of crashing; specifically, around
the block creating new Project(), calling
project.addSourceFilesAtPaths(sourceFilePaths), and calling
extractComponents(project, sourceFilePaths, config), catch any error and return
JSON via formatError (or formatSuccess counterpart) with an appropriate error
code (add ExtractionError to error-codes.ts or reuse ValidationError) and
include the caught error.message and stack for CI debugging; ensure the catch
uses process.exitCode or returns after printing the JSON so the CLI doesn’t
throw.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
packages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx,js,jsx}: When writing, editing, refactoring, or reviewing code, always followdocs/conventions/software-design.md
Look for standard implementation patterns defined indocs/conventions/standard-patterns.md
Avoid anti-patterns defined in@docs/conventions/anti-patterns.md
100% test coverage is mandatory and enforced
Use domain terminology fromdocs/architecture/domain-terminology/contextive/definitions.glossary.yml. Do not invent new terms or use technical jargon when domain terminology exists
Never commit secrets, API keys, or credentials. Use environment variables for sensitive configuration. Do not log sensitive data (passwords, tokens, PII). Validate and sanitize all external input
Files:
packages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.ts
**/*.spec.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Follow
docs/conventions/testing.mdfor all test files
Files:
packages/riviere-cli/src/commands/extract/extract.spec.ts
**/*.{ts,tsx,js,jsx,json,css,scss}
📄 CodeRabbit inference engine (CLAUDE.md)
All UI and UX design must conform to global brand guidelines:
/docs/brand/(logo, colors, typography, icons)
Files:
packages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.ts
packages/**
📄 CodeRabbit inference engine (CLAUDE.md)
Create new shared libraries as publishable packages in the
packages/directory usingpnpm nx g @nx/js:library packages/[pkg-name] --publishable --importPath=@living-architecture/[pkg-name]
Files:
packages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.ts
🧠 Learnings (25)
📓 Common learnings
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/architecture/overview.md:0-0
Timestamp: 2026-01-08T22:20:13.250Z
Learning: Applies to docs/architecture/**/*extract*.ts : Use `living-architecture/riviere-extract-ts` TypeScript extractor with ts-morph for AST parsing when implementing TypeScript extraction for architecture schema components
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/architecture/overview.md:0-0
Timestamp: 2026-01-08T22:20:13.250Z
Learning: Applies to docs/architecture/**/*extract*.{json,ts} : Define extraction configuration using the JSON Schema from `living-architecture/riviere-extract-config` DSL
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-conventions/CLAUDE.md:0-0
Timestamp: 2026-01-08T07:05:01.766Z
Learning: Import and use the default extraction config from `living-architecture/riviere-extract-conventions/default-config` in extraction tooling to detect all 6 component types
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.test.{ts,tsx} : Implement integration tests for end-to-end extraction from TypeScript code to JSON output
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Implement extraction logic as pure functions with no side effects
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/architecture/overview.md:0-0
Timestamp: 2026-01-08T22:20:13.250Z
Learning: Applies to docs/architecture/**/*extract*.ts : Use the Rivière Builder Node.js library to programmatically construct the schema graph when implementing custom extraction code
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-config/CLAUDE.md:0-0
Timestamp: 2026-01-06T23:01:34.751Z
Learning: Applies to packages/riviere-extract-config/**/*.ts : Extraction config schema is the source of truth for valid structures. TypeScript types must mirror the schema definition to maintain consistency
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Reject invalid extraction configs at load time, not during extraction phase
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Use glob pattern matching for module-based organization of extraction rules
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/architecture/overview.md:0-0
Timestamp: 2026-01-08T22:20:13.250Z
Learning: Applies to docs/architecture/**/*.{ts,tsx} : Apply decorators from `living-architecture/riviere-extract-conventions` to mark all classes as architectural components
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: All extraction rules should come from validated ExtractionConfig provided by riviere-extract-config
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-cli/CLAUDE.md:0-0
Timestamp: 2026-01-02T11:58:27.018Z
Learning: When modifying CLI commands in the riviere-cli tool, update the corresponding workflow prompts in docs/workflow/ directory (step-1 through step-6) to keep the extraction workflow in sync
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.test.{ts,tsx} : Implement integration tests for end-to-end extraction from TypeScript code to JSON output
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.test.{ts,tsx} : Implement unit tests for each predicate type in isolation with positive and negative cases
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.ts
📚 Learning: 2026-01-06T23:01:34.751Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-config/CLAUDE.md:0-0
Timestamp: 2026-01-06T23:01:34.751Z
Learning: Applies to packages/riviere-extract-config/**/*.ts : Extraction config schema is the source of truth for valid structures. TypeScript types must mirror the schema definition to maintain consistency
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-08T22:20:13.250Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/architecture/overview.md:0-0
Timestamp: 2026-01-08T22:20:13.250Z
Learning: Applies to docs/architecture/**/*extract*.{json,ts} : Define extraction configuration using the JSON Schema from `living-architecture/riviere-extract-config` DSL
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Implement extraction logic as pure functions with no side effects
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-08T22:20:13.250Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/architecture/overview.md:0-0
Timestamp: 2026-01-08T22:20:13.250Z
Learning: Applies to docs/architecture/**/*extract*.ts : Use `living-architecture/riviere-extract-ts` TypeScript extractor with ts-morph for AST parsing when implementing TypeScript extraction for architecture schema components
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Reject invalid extraction configs at load time, not during extraction phase
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.test.{ts,tsx} : Use ts-morph's in-memory file system (`useInMemoryFileSystem: true`) for fast isolated tests
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/vitest.config.mts : Enforce 100% code coverage using Vitest with v8 coverage and thresholds configured in vitest.config.mts
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.ts
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Use glob pattern matching for module-based organization of extraction rules
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-07T08:54:48.071Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/workflow/code-review.md:0-0
Timestamp: 2026-01-07T08:54:48.071Z
Learning: Applies to docs/workflow/**/*.{ts,tsx,js,jsx} : Review usage of `/* v8 ignore next -- preserve */` coverage skip directives. This is only acceptable for unreachable code needed to satisfy the compiler. Most cases should be solved by extracting code or writing tests to mock behavior.
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-06T08:11:15.403Z
Learnt from: NTCoding
Repo: NTCoding/living-architecture PR: 53
File: packages/riviere-extract-config/vitest.config.mts:20-20
Timestamp: 2026-01-06T08:11:15.403Z
Learning: In packages/riviere-extract-config/vitest.config.mts, the explicit tuple type assertion for the reporter configuration (`as ['text', ['lcov', { projectRoot: string }]]`) is necessary because vitest's CoverageReporter type requires the exact tuple shape; neither inference nor 'as const' produces a compatible type.
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.ts
📚 Learning: 2026-01-04T17:04:31.759Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/conventions/testing.md:0-0
Timestamp: 2026-01-04T17:04:31.759Z
Learning: Applies to docs/conventions/**/*.spec.{ts,tsx,js,jsx} : Assert specific values, not types. Use `expect(result).toEqual(['First.', ' Second.'])` instead of `expect(result).toBeDefined()`. Specific assertions catch specific bugs
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.ts
📚 Learning: 2026-01-04T17:04:31.759Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/conventions/testing.md:0-0
Timestamp: 2026-01-04T17:04:31.759Z
Learning: Applies to docs/conventions/**/*.spec.{ts,tsx,js,jsx} : Test domain-specific edge cases: email formats, URLs with protocols/ports, international phone formats, addresses with Unicode, currency rounding, and percentage boundaries
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.ts
📚 Learning: 2026-01-08T22:20:13.250Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/architecture/overview.md:0-0
Timestamp: 2026-01-08T22:20:13.250Z
Learning: Applies to docs/architecture/**/*extract*.ts : Use the Rivière Builder Node.js library to programmatically construct the schema graph when implementing custom extraction code
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-08T07:05:01.766Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-conventions/CLAUDE.md:0-0
Timestamp: 2026-01-08T07:05:01.766Z
Learning: Import and use the default extraction config from `living-architecture/riviere-extract-conventions/default-config` in extraction tooling to detect all 6 component types
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.tspackages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-08T06:46:00.609Z
Learnt from: NTCoding
Repo: NTCoding/living-architecture PR: 66
File: packages/riviere-extract-conventions/src/eslint/require-component-decorator.spec.ts:19-21
Timestamp: 2026-01-08T06:46:00.609Z
Learning: In test files using typescript-eslint/rule-tester's RuleTester.run(), ensure there is an explicit it() block with at least one expect() assertion (e.g., expect(rule).toBeDefined()) to satisfy sonarjs/no-empty-test-file and sonarjs/assertions-in-tests lint rules, which don’t recognize RuleTester's internal test blocks. Apply this pattern to all spec.ts test files to maintain consistency and pass lint checks.
Applied to files:
packages/riviere-cli/src/commands/extract/extract.spec.ts
📚 Learning: 2026-01-08T22:20:13.250Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/architecture/overview.md:0-0
Timestamp: 2026-01-08T22:20:13.250Z
Learning: Applies to docs/architecture/**/*.{ts,tsx} : Apply decorators from `living-architecture/riviere-extract-conventions` to mark all classes as architectural components
Applied to files:
packages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-06T23:01:34.751Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-config/CLAUDE.md:0-0
Timestamp: 2026-01-06T23:01:34.751Z
Learning: All validation of extraction config must occur at config load time, not during extraction. Invalid configs should fail fast with clear error messages that include paths and descriptive information
Applied to files:
packages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-08T23:16:02.639Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/conventions/software-design.md:0-0
Timestamp: 2026-01-08T23:16:02.639Z
Learning: Applies to docs/conventions/**/*.{ts,tsx,js,jsx} : Fail-Fast Error Handling: Validate and throw clear errors instead of using fallback chains. Error format: `Expected [X]. Got [Y]. Context: [debugging info]`
Applied to files:
packages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-08T23:16:02.639Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/conventions/software-design.md:0-0
Timestamp: 2026-01-08T23:16:02.639Z
Learning: Applies to docs/conventions/**/*.{ts,tsx,js,jsx} : Fail-fast over silent fallbacks. Never use fallback chains (`value ?? backup ?? 'unknown'`). If data should exist, validate and throw a clear error.
Applied to files:
packages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-07T08:54:48.071Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: docs/workflow/code-review.md:0-0
Timestamp: 2026-01-07T08:54:48.071Z
Learning: Applies to docs/workflow/**/*.{ts,tsx,js,jsx} : Avoid dangerous fallback values that hide bugs. Do not use `??` or `||` operators without clear reason for providing defaults. If a value is required, make it required rather than guessing at defaults. Exceptions: optional parameters with documented defaults, configuration with explicit optional semantics, and test data with placeholder values.
Applied to files:
packages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: Applies to packages/riviere-extract-ts/**/*.{ts,tsx} : Use ts-morph for TypeScript AST parsing instead of other parsers
Applied to files:
packages/riviere-cli/src/commands/extract/extract.ts
📚 Learning: 2026-01-08T17:19:17.148Z
Learnt from: CR
Repo: NTCoding/living-architecture PR: 0
File: packages/riviere-extract-ts/CLAUDE.md:0-0
Timestamp: 2026-01-08T17:19:17.148Z
Learning: All extraction rules should come from validated ExtractionConfig provided by riviere-extract-config
Applied to files:
packages/riviere-cli/src/commands/extract/extract.ts
🧬 Code graph analysis (1)
packages/riviere-cli/src/commands/extract/extract.spec.ts (2)
packages/riviere-cli/src/cli.ts (1)
createProgram(44-78)packages/riviere-cli/src/command-test-fixtures.ts (4)
TestContext(55-59)createTestContext(61-67)setupCommandTest(69-83)parseErrorOutput(27-37)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: browser-tests (firefox)
- GitHub Check: Analyze
- GitHub Check: browser-tests (webkit)
- GitHub Check: browser-tests (chromium)
- GitHub Check: main
- GitHub Check: Cloudflare Pages
🔇 Additional comments (5)
packages/riviere-cli/src/commands/extract/extract.ts (2)
34-48: LGTM!The
parseConfigFilefunction correctly implements fail-fast error handling with a discriminated union return type. The v8 ignore directive is appropriately documented as a defensive guard for an edge case.
92-107: LGTM!The glob resolution correctly handles patterns relative to the config directory, and the empty-match error provides actionable debugging context (patterns and config directory).
packages/riviere-cli/src/commands/extract/extract.spec.ts (3)
51-55: LGTM!The command registration test correctly verifies the extract command is registered at the top level. The optional chaining handles the edge case gracefully.
58-125: LGTM!Comprehensive error scenario coverage with specific assertions. Tests verify all acceptance criteria: missing config, invalid YAML, invalid schema, and no-matches cases. Each assertion checks specific values rather than just types, per testing conventions.
131-176: LGTM!Solid end-to-end integration test that exercises the full extraction flow from source file through JSON output. The test uses real file operations and validates the complete output structure.
Consider adding a test case for extraction failures (e.g., unreadable source file, malformed TypeScript) once the try-catch handling is added to the command implementation. This would ensure CI-facing error output remains structured even when extraction throws.
- Add process.exit(1) for all error paths to ensure non-zero exit codes in CI - Add engines field requiring Node.js 20+ - Update generate-docs.ts to include extract command in CLI documentation - Add ProcessExitError to test fixtures to properly test process.exit behavior - Update all extract command error tests to catch and verify ProcessExitError Addresses critical and major feedback from CodeRabbit review. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Enable vitest plugin rules: prefer-strict-equal, consistent-test-filename, require-to-throw-message, no-conditional-expect, no-conditional-in-test, prefer-called-with, prefer-to-have-length, max-expects (9), prefer-spy-on - Rename all .test.ts files to .spec.ts in eclair app (consistent-test-filename) - Replace toEqual with toStrictEqual across all test files (prefer-strict-equal) - Add error message patterns to toThrow() assertions (require-to-throw-message) - Create assertDefined<T>() and assertHTMLInputElement() helpers to replace conditional logic in tests (no-conditional-in-test, no-conditional-expect) - Add argument matchers (expect.anything(), expect.any()) for toHaveBeenCalledWith() - Use toMatchObject() for class instance comparisons where toStrictEqual fails - Disable no-unsafe-assignment in test files to allow expect.any() matchers Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
|



User description
Closes #44
Summary
Implements
riviere extract --config <path>CLI command that runs component extraction and outputs draft components JSON to stdout.Changes
riviere extractcommand with--configoptionTest Plan
Related
Closes #44
PR Type
Enhancement
Description
Add
riviere extractCLI command for component extractionImplement config validation with YAML parsing and schema checking
Output extracted components as JSON to stdout
Add comprehensive integration tests with 100% coverage
Add new dependencies: glob, ts-morph, yaml for extraction
Diagram Walkthrough
File Walkthrough
cli.ts
Register extract command in CLIpackages/riviere-cli/src/cli.ts
createExtractCommandfrom extract moduleextract.ts
Implement extract command with config validationpackages/riviere-cli/src/commands/extract/extract.ts
createExtractCommand()function with --config optionerror-codes.ts
Add ConfigNotFound error codepackages/riviere-cli/src/error-codes.ts
ConfigNotFounderror code to CliErrorCode enumextract.spec.ts
Add comprehensive extract command testspackages/riviere-cli/src/commands/extract/extract.spec.ts
package.json
Add extract command dependenciespackages/riviere-cli/package.json
@living-architecture/riviere-extract-configworkspace dependency@living-architecture/riviere-extract-tsworkspace dependencyglob^11.0.2 for file pattern matchingts-morph^24.0.0 for TypeScript AST manipulationyaml^2.7.0 for YAML parsingpnpm-lock.yaml
Update lock file with new dependenciespnpm-lock.yaml
[email protected]
path-scurry, eastasianwidth, [email protected], [email protected]
riviere-extract-ts
tsconfig.lib.json
Add TypeScript references for extract packagespackages/riviere-cli/tsconfig.lib.json
settings.json
Remove bash script permission.claude/settings.json
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.