You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: Use symlinks instead of copies for scripts/dev in init #107
The sequant init command currently copies templates/scripts/ to scripts/dev/. This means users don't receive template updates after initialization, leading to drift between the canonical templates and local scripts.
Problem
Discovered during testing of #103 (npm cache feature):
src/lib/fs.ts - new cross-platform symlink utility
Assumptions to Validate:
Windows symlinks require admin privileges (or developer mode enabled)
Fallback to copies is acceptable on Windows
AC-4: Documentation updated if needed
Verification Method: Manual Review
Test Scenario:
Given: Implementation is complete
When: Reviewing user-facing documentation
Then: Any relevant docs mention symlink behavior and fallback options
Integration Points:
README or CONTRIBUTING docs (if applicable)
Implementation Plan
Phase 1: Add Symlink Utilities to fs.ts
Add new utility functions to src/lib/fs.ts:
isSymlink(path) - Check if path is a symbolic link
createSymlink(target, path) - Create symlink with cross-platform handling
removeFileOrSymlink(path) - Remove file or symlink safely
Import symlink, lstat, unlink from fs/promises
Phase 2: Update templates.ts for Symlinks
Create new function symlinkDir(srcDir, destDir) in src/lib/templates.ts:
Similar to copyDir() but creates symlinks for files
Use relative paths for portability
Handle shell script permissions (symlinks inherit from target)
Update copyTemplates() to use symlinkDir() for scripts/dev/:
Keep copyDir() for .claude/skills/, .claude/hooks/, .claude/memory/ (these need template variable processing)
Use symlinkDir() only for scripts/dev/ (no variable processing needed in these scripts)
Phase 3: Handle Re-initialization
Add logic to detect and handle existing files:
Check if files in scripts/dev/ are symlinks or regular files
If regular files exist, prompt user for replacement or skip
Consider --force flag to replace without prompting
Phase 4: Windows Handling
Add Windows-specific handling in createSymlink():
Detect native Windows using isNativeWindows()
Try symlink first, catch permission error
Fall back to copy with warning message
Consider using junctions for directories (don't require admin)
Phase 5: Tests
Add unit tests to src/lib/fs.test.ts:
Test isSymlink(), createSymlink(), removeFileOrSymlink()
Mock Windows behavior for cross-platform tests
Add integration tests for symlink behavior:
Fresh init creates symlinks
Re-init handles existing files appropriately
Windows fallback works correctly
Open Questions
Relative vs Absolute Symlinks?
Recommendation: Use relative paths for portability across machines
Impact: Absolute paths break when project is moved; relative paths are more robust
Should --no-symlinks flag be added?
Recommendation: Yes, add --no-symlinks flag for users who prefer copies
Impact: Low; provides escape hatch for edge cases
What to do with .claude/ templates?
Recommendation: Keep as copies (they need variable substitution)
Impact: Only scripts/dev/ changes to symlinks; .claude/ unchanged
Conflict Risk Analysis
In-flight work detected: Issue #108 (feature/108-docs-add-script-locations-guidance-templates-vs-sc) Overlapping focus: Both issues relate to scripts/dev vs templates distinction
Current: (none) Recommended:enhancement, cli Reason: New feature for the init CLI command Quality Loop: Won't auto-enable (no complex/refactor labels needed)
-`sequant init` now creates symlinks for `scripts/dev/` pointing to `templates/scripts/` (#107)
- Templates automatically update when Sequant is upgraded
- Existing regular files preserved (use `--force` to replace)
- Windows falls back to copies if symlinks unavailable
- Use `--no-symlinks` flag to opt out of symlink behavior
After CHANGELOG update, re-run /qa 107 for READY_FOR_MERGE verdict
Activity
admarble commentedon Jan 21, 2026
📋 Spec Review: Implementation Plan
Acceptance Criteria with Verification
AC-1:
sequant initcreates symlinks inscripts/dev/pointing totemplates/scripts/Verification Method: Integration Test + Manual Test
Test Scenario:
scripts/dev/sequant initscripts/dev/new-feature.sh,scripts/dev/cleanup-worktree.sh, andscripts/dev/list-worktrees.share symlinks pointing to the templates directoryIntegration Points:
src/lib/templates.ts:copyTemplates()functionsrc/lib/fs.tsutilitiesAssumptions to Validate:
fs/promises.symlink()works across macOS and LinuxAC-2: Existing copies are replaced with symlinks on re-init (or warn user)
Verification Method: Integration Test + Manual Test
Test Scenario:
scripts/dev/*.shfiles (real files, not symlinks)sequant initagainIntegration Points:
src/commands/init.ts- re-initialization detectionsrc/lib/fs.ts- symlink detection utilitiesAssumptions to Validate:
lstat()AC-3: Cross-platform: works on macOS, Linux, and Windows (may need special handling)
Verification Method: Unit Test + Manual Test on each platform
Test Scenario:
sequant initIntegration Points:
src/lib/system.ts-isNativeWindows(),isWSL()utilitiessrc/lib/fs.ts- new cross-platform symlink utilityAssumptions to Validate:
AC-4: Documentation updated if needed
Verification Method: Manual Review
Test Scenario:
Integration Points:
Implementation Plan
Phase 1: Add Symlink Utilities to
fs.tsAdd new utility functions to
src/lib/fs.ts:isSymlink(path)- Check if path is a symbolic linkcreateSymlink(target, path)- Create symlink with cross-platform handlingremoveFileOrSymlink(path)- Remove file or symlink safelyImport
symlink,lstat,unlinkfromfs/promisesPhase 2: Update
templates.tsfor SymlinksCreate new function
symlinkDir(srcDir, destDir)insrc/lib/templates.ts:copyDir()but creates symlinks for filesUpdate
copyTemplates()to usesymlinkDir()forscripts/dev/:copyDir()for.claude/skills/,.claude/hooks/,.claude/memory/(these need template variable processing)symlinkDir()only forscripts/dev/(no variable processing needed in these scripts)Phase 3: Handle Re-initialization
scripts/dev/are symlinks or regular files--forceflag to replace without promptingPhase 4: Windows Handling
createSymlink():isNativeWindows()Phase 5: Tests
Add unit tests to
src/lib/fs.test.ts:isSymlink(),createSymlink(),removeFileOrSymlink()Add integration tests for symlink behavior:
Open Questions
Relative vs Absolute Symlinks?
Should
--no-symlinksflag be added?--no-symlinksflag for users who prefer copiesWhat to do with
.claude/templates?scripts/dev/changes to symlinks;.claude/unchangedConflict Risk Analysis
In-flight work detected: Issue #108 (feature/108-docs-add-script-locations-guidance-templates-vs-sc)
Overlapping focus: Both issues relate to scripts/dev vs templates distinction
Risk Level: Low
Recommended approach: Proceed with #107; #108 docs can reference final behavior
Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: Well-defined AC, moderate complexity, no UI changes. Standard exec → qa flow sufficient.
Label Review
Current: (none)
Recommended:
enhancement,cliReason: New feature for the init CLI command
Quality Loop: Won't auto-enable (no complex/refactor labels needed)
→
gh issue edit 107 --add-label enhancement --add-label cliEffort Breakdown
Total: ~5 implementation steps, moderate complexity
🤖 Generated by
/specworkflowfeat(#107): use symlinks instead of copies for scripts/dev in init
admarble commentedon Jan 21, 2026
🚀 Implementation Complete
AC Coverage
sequant initcreates symlinks inscripts/dev/templates/scripts/--forceFiles Changed
src/lib/fs.tsisSymlink,createSymlink,getSymlinkTarget,removeFileOrSymlinksrc/lib/templates.tssymlinkDir()function, updatedcopyTemplates()to use symlinks for scriptssrc/commands/init.ts--no-symlinksflag handling, symlink status reportingbin/cli.ts--no-symlinksoption to init commandsrc/lib/fs.test.tssrc/lib/templates.test.tssymlinkDirandprocessTemplatesrc/commands/init.test.tscopyTemplatesreturn typeTest Results
state-update-cli.test.ts(unrelated to this PR)npm run buildcompiles successfullyPR
Created: #152
🤖 Generated by
/execworkflowadmarble commentedon Jan 21, 2026
QA Review for Issue #107
AC Coverage
sequant initcreates symlinks inscripts/dev/pointing totemplates/scripts/symlinkDir()function creates relative symlinks;copyTemplates()uses it forscripts/dev/--forceisNativeWindows(); graceful fallback to copies on EPERM/EACCES--no-symlinksflag visible in--help; CHANGELOG entry missingCoverage: 3.5/4 AC items fully met
Quality Metrics
any)Code Review
Strengths:
fs.ts, directory symlink logic intemplates.ts, CLI integration ininit.tsrelative(dirname(dest), src))symlinkDir, 12 tests for symlink utilities--no-symlinksescape hatch for users who prefer copiesIssues:
Suggestions:
Test Quality Review
Issues Found:
Anti-Pattern Detection
Dependency Audit
N/A - No dependency changes (package.json not modified)
Code Patterns
Critical Issues: 0
Warnings: 0
Execution Evidence
npx tsx bin/cli.ts init --help--no-symlinksoptionnpm run buildnpm testEvidence status: Complete
Self-Evaluation
Verdict: AC_MET_BUT_NOT_A_PLUS
All acceptance criteria are met or exceeded:
Quality is high but CHANGELOG should be updated before merge.
Documentation
--no-symlinksis self-documentingNext Steps
[Unreleased]:/qa 107forREADY_FOR_MERGEverdict🤖 Generated by
/qaworkflowdocs: add CHANGELOG entry for symlinks feature (#107)
admarble commentedon Jan 21, 2026
QA Update: READY_FOR_MERGE ✅
CHANGELOG entry added in commit 4d54f4a. All AC items now fully met.
Post-Merge Verification (Recommended)
Unit test coverage is solid, but a quick manual smoke test is recommended after merge:
On Windows (if available):
npx sequant init -y # Should see "copied instead of symlinked" message (expected fallback)Verdict:
READY_FOR_MERGE🤖 Generated by
/qaworkflowadmarble commentedon Jan 21, 2026
QA Review for Issue #107
AC Coverage
sequant initcreates symlinks inscripts/dev/symlinkDir()creates relative symlinks for portability--force4d54f4aCoverage: 4/4 AC items fully met
Quality Metrics
any)Test Coverage Analysis
bin/cli.tssrc/commands/init.tsinit.test.tssrc/lib/fs.tsfs.test.tssrc/lib/templates.tstemplates.test.tsCoverage: 3/4 changed source files have corresponding tests
Critical paths without tests: None
Code Review
Strengths:
fs.ts, directory logic intemplates.ts, CLI ininit.tsrelative(dirname(dest), src)) for portability across machinessymlinkDir, 12 tests for symlink utilities--no-symlinksescape hatch for users who prefer copiesIssues:
Security Note: The security agent flagged theoretical path traversal concerns. These are false positives in this context because:
templates/scripts/within the packageTest Quality Review
Anti-Pattern Detection
Dependency Audit
N/A - No dependency changes
Code Patterns
No anti-patterns detected.
Critical Issues: 0
Warnings: 0
Execution Evidence
npx tsx bin/cli.ts init --help--no-symlinksoptionnpm run buildnpm testEvidence status: Complete
Self-Evaluation
Verdict: READY_FOR_MERGE
All acceptance criteria fully met:
Documentation
--no-symlinksflag self-documenting via--helpNext Steps
Generated by /qa
fix(#107): handle absolute paths in symlink calculation
admarble commentedon Jan 21, 2026
Post-Merge Bug Fix
A bug was discovered during post-merge testing: symlinks were broken due to incorrect path calculation.
Root Cause:
Fix: Added
isAbsolute()check before joining paths (commit8cbf2fa).Verified:
~/project)/tmp(macOS symlink to/private/tmpedge case)Issue fully resolved.