Commit Graph

14 Commits

Author SHA1 Message Date
Claude 1bef40ba2d test: Tighten misleading test names and pin packageManager guard
Address two review threads on PR #1518 that flagged tests whose titles
overstated what was being verified.

- fileProcess: the longBase64 string is one continuous line, so the
  truncateBase64 → removeEmptyLines ordering was never actually under
  test (truncateBase64Content's regex does not span newlines). Rename
  to describe the combined behavior the test really pins.
- skillTechStack: rename the per-directory case to reflect that root
  and subpackage land in separate buckets keyed by getDirPath, and
  add a second case with two package.json entries at the same path
  to genuinely exercise the parsed.packageManager && !result.packageManager
  guard at skillTechStack.ts:541.
2026-04-26 13:24:32 +00:00
Kazuki Yamada 402e4906d7 test: Pin v1.14.0 regression-prone invariants
Targeted regression tests for the high-risk areas identified in the
v1.13.1..main audit, focusing on silent-correctness bugs and parallel
error handling — places that wouldn't surface in CI but would in the
field.

- core/metrics/calculateMetrics: pin numeric equivalence between the
  fast path (Σ file tokens + wrapper tokens) and the slow path (full
  output tokenization). Cover wrapper-extraction fallback, split-output
  fallback, and worker pool cleanup when fileMetrics rejects.

- core/file/fileProcess: pin transform ordering invariants —
  removeComments → removeEmptyLines (blank lines from comment removal
  must be cleaned up; preserved when removeEmptyLines is off);
  truncateBase64 → removeEmptyLines (multi-line base64 squashed first);
  trim → showLineNumbers (no leading/trailing blanks numbered).
  Plus worker/lightweight path parity for inputs that don't need
  worker processing.

- core/packager: pin metrics worker pool cleanup on parallel branch
  failures (validateFileSafety, produceOutput, calculateMetrics, warmup
  rejection). Verify prefetchSortData failure is isolated and does not
  block sortOutputFiles.

- core/skill/skillTechStack: cover untested fix-commit invariants —
  root entry sorts first in monorepo output; configFiles deduplicated
  within a directory; first-seen packageManager wins per directory.
2026-04-26 19:43:53 +09:00
Kazuki Yamada 7649725a21 refactor(skill): Rename tech-stack.md to tech-stacks.md with ## Tech Stack: <path> format
Aligns with files.md pattern (## File: <path>). Each package is now
a ## section under a single # Tech Stacks heading, with ### subsections
for Languages, Frameworks, Dependencies, etc.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 00:20:49 +09:00
Kazuki Yamada 2a7139c89f refactor(skill): Use '.' instead of '(root)' for root directory label
More natural as a path value and consistent with filesystem conventions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 23:58:35 +09:00
Kazuki Yamada b2191509ca refactor(skill): Group tech stack detection by package directory
Instead of merging all dependency files into a single flat list,
detectTechStack now returns a TechStackInfo[] grouped by package
directory. Each directory containing a dependency file produces its
own entry with path, languages, frameworks, dependencies, etc.

generateTechStackMd renders each package as a separate section with
`path: (root)` or `path: packages/xxx`, separated by `---`. This
gives AI consumers clearer per-package context and makes line-based
retrieval easier.

Removes deduplicateDependencies as dependencies are now scoped
per-package and don't need cross-package deduplication. configFiles
stores filenames only (not full paths) since the package path
provides the directory context.

Closes #1182

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 23:48:44 +09:00
Kazuki Yamada 005eb791eb fix(skill): Address PR review feedback for tech stack detection
- Use first-wins for packageManager to match other dedup strategies
- Deduplicate dependencies by name:version to preserve version skew
- Normalize Node.js version v prefix before runtime version dedup
- Fix stale comment referencing root-level-only detection

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 00:32:02 +09:00
Kazuki Yamada c4b096f996 fix(skill): Add deduplication for runtime versions in tech stack detection
Deduplicate runtimeVersions by runtime:version pair to prevent
duplicate entries when multiple version files exist across
subdirectories in monorepos.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 00:09:46 +09:00
Kazuki Yamada 87949970da fix(skill): Detect tech stack from dependency files in subdirectories
Previously, detectTechStack() only checked root-level dependency files,
causing tech-stack.md to be empty for monorepo setups using --include
to target a specific package.

Now all dependency files in processedFiles are checked regardless of
directory depth. Since processedFiles is already filtered by
--include/--ignore, this naturally scopes detection to the user's
target. Also adds dependency deduplication for cases where multiple
package.json files define the same package, and stores config file
full paths to distinguish files across subdirectories.

Closes #1182

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 00:01:05 +09:00
Kazuki Yamada cd2b7de4b9 test(skill,mcp): improve test coverage for writeSkillOutput and fileSystemReadFileTool
Add comprehensive tests to increase code coverage from 89.81% to 90.28%:

writeSkillOutput.ts (63.88% → 100%):
- Add test for techStack file writing
- Add tests for EPERM/EACCES error handling
- Add test for generic error handling
- Add test for non-Error object handling

fileSystemReadFileTool.ts (62.5% → 100%):
- Add test for directory path error
- Add test for successful file reading
- Add test for security check failure
- Add test for general errors during file reading
- Add test for non-Error object handling
2025-12-14 22:10:56 +09:00
Kazuki Yamada 925d94adf9 refactor(skill): Address PR review feedback
- Fix extractRepoName to handle trailing slashes, query strings, and
  fragments in URLs (e.g., https://github.com/user/repo/ now works)
- Extract toTitleCase helper function to reduce code duplication
- Use projectName instead of sourceUrl for link text in SKILL.md footer
  (displays as "from [Vite](https://...)" instead of full URL twice)
- Add tests for URL edge cases (trailing slash, query, fragment)
2025-12-12 21:49:14 +09:00
Kazuki Yamada 43c2bd81da feat(skill): Improve skill generation for remote repositories
- Fix project name generation to use repository name from URL instead of
  temp directory name (e.g., "Vite" instead of "Repomix HPkbgH")
- Add source URL to SKILL.md footer for remote repositories only
  (local repos don't include URL to avoid exposing personal paths)
- Copy only .claude/skills/ directory to prevent conflicts with
  repository's own .claude config (commands, agents, etc.)

Example SKILL.md footer:
- Remote: "This skill was generated by Repomix from [https://github.com/...]"
- Local: "This skill was generated by Repomix"
2025-12-12 20:54:01 +09:00
Kazuki Yamada 6a397a01ac test(skill): Add tests for skill generation functionality
Add comprehensive tests for:
- packSkill.ts: generateSkillReferences, generateSkillMdFromReferences, packSkill
- skillPrompts.ts: getSkillBaseDir, promptSkillLocation
- generateSkillTool.ts: MCP tool registration, input validation, error handling
2025-12-11 23:30:25 +09:00
Kazuki Yamada d6d82b6392 fix(security): Add path traversal protection for skill generation
- Add validation in validateSkillName to reject path separators (/, \),
  null bytes, and dot-only names (., .., ...)
- Add absolute path validation in MCP generateSkillTool
- Add directory existence check before skill generation in MCP tool
- Add existing skill directory check to prevent silent overwrites
- Add security tests for path traversal prevention
2025-12-11 23:20:51 +09:00
Kazuki Yamada 0fa885cb79 refactor(skill): Move skill-related code to core/skill/ directory
Reorganize skill generation code for better domain separation:
- Move files from core/output/skill/ to core/skill/ (5 files)
- Move writeSkillOutput.ts from core/packager/ to core/skill/
- Create packSkill.ts to encapsulate skill generation logic
- Simplify packager.ts by delegating skill generation to packSkill()
- Add re-exports in outputGenerate.ts for backward compatibility

This change improves code organization by:
- Separating skill domain from output domain
- Reducing packager.ts complexity
- Centralizing all skill-related code in one location
2025-12-11 00:12:34 +09:00