Repository Scripts & Automation Tooling
Relevant source files
The following files were used as context for generating this wiki page:
- scripts/merge-strategy.ts
- scripts/analyze-duplicates.ts
- cleanup-remaining-docs.sh
- ARCHIVE/remaining-docs-consolidated-2026-02-13/TAMV-MCP-Cleanup.ps1
- ARCHIVE/remaining-docs-consolidated-2026-02-13/LOGROS-HOY.md
- ARCHIVE/remaining-docs-consolidated-2026-02-13/CLEANUP-COMPLETE-REPORT.md
- ARCHIVE/remaining-docs-consolidated-2026-02-13/CONSOLIDATION-SUMMARY.md
The Repository Scripts & Automation Tooling within the TAMV (Territorio Autónomo de Memoria Viva) project comprises a suite of TypeScript, Bash, and PowerShell utilities designed to manage project fragmentation, consolidate documentation, and enforce code quality. These tools were primarily developed to address severe documentation fragmentation, where 15+ duplicate files and 8,000+ redundant lines of content previously existed across various project versions.
The automation suite facilitates a multi-phase cleanup and consolidation effort, transitioning the project from a disorganized state with mixed Spanish/English content to a unified, English-standardized structure. This includes intelligent duplicate analysis, quality scoring for different project versions, and a programmatic merge strategy to establish a single source of truth for the system architecture and implementation guides.
Sources: ARCHIVE/remaining-docs-consolidated-2026-02-13/CLEANUP-COMPLETE-REPORT.md:5-25, ARCHIVE/remaining-docs-consolidated-2026-02-13/CONSOLIDATION-SUMMARY.md:5-20
Duplicate Analysis and Quality Scoring
The core of the repository management system is the analyze-duplicates.ts script. This tool performs recursive scanning of the filesystem to identify duplicate project folders and redundant documentation files. It calculates specific metrics such as file count, total size, and the last modification timestamp for each identified entity.
Scoring Methodology
To determine which project versions should be prioritized during consolidation, the system implements a weighted QualityScore algorithm:
| Criterion | Weight | Description |
|---|---|---|
| Completeness | 40% | Based on file count, presence of key directories (src, tests, docs), and config files (package.json). |
| Recency | 30% | Calculated using a linear decay model based on the last modification date. |
| Code Quality | 30% | Heuristic score based on test-to-code ratios and presence of TypeScript/ESLint configurations. |
Sources: scripts/analyze-duplicates.ts:16-30, scripts/analyze-duplicates.ts:546-560, ARCHIVE/remaining-docs-consolidated-2026-02-13/LOGROS-HOY.md:40-55
Functional Integration Identification
Beyond simple duplicate detection, the analyzer identifies "favorable files" ready for functional TAMV evolution. These are categorized based on their technical area into specific architectural layers:
- Protocols: L2 - Controlled Protocols (e.g.,
protocol.*.ts). - Memory: L1 - Memory & Registry (e.g.,
msr.*.ts). - Guardian: L3 - Guardianship & Monitoring (e.g.,
guardian.*.ts). - XR: L4 - XR/VR/3D/4D (e.g.,
dreamspaces.*.ts). - Domain Services: L5 - Identity, Auth, and Economy.
Sources: scripts/analyze-duplicates.ts:115-155, scripts/analyze-duplicates.ts:340-365
The diagram shows the logic flow from raw filesystem scanning to the generation of a ranked quality report and functional integration recommendations. Sources: scripts/analyze-duplicates.ts:390-440, scripts/analyze-duplicates.ts:115-155
Consolidation and Merge Strategy
The merge-strategy.ts script implements the programmatic consolidation of identified duplicates. It operates on a file-by-file basis, comparing resources across multiple project versions and selecting the highest-quality version based on the scoring derived from the analysis phase.
Conflict Resolution and Archiving
The merge strategy includes an intelligent conflict resolution mechanism. If two files exist at the same path in different versions, the one with the higher individual quality score is selected for the canonical root. Redundant files are not deleted but are moved to a specific archive directory (e.g., ARCHIVE/remaining-docs-consolidated-2026-02-13/) to preserve historical reference while cleaning the active workspace.
Sources: scripts/merge-strategy.ts:20-50, ARCHIVE/remaining-docs-consolidated-2026-02-13/LOGROS-HOY.md:65-80
Key Automation Components
| Script | Language | Primary Purpose |
|---|---|---|
analyze-duplicates.ts | TypeScript | Filesystem scanning, quality scoring, and report generation. |
merge-strategy.ts | TypeScript | Implementation of file-level merging and conflict resolution. |
cleanup-remaining-docs.sh | Bash | Orchestrates the archival of redundant .md and .ps1 files to the ARCHIVE/ folder. |
TAMV-MCP-Cleanup.ps1 | PowerShell | Specialized script for cleaning up MCP (Model Context Protocol) logs and temporary implementation files. |
Sources: cleanup-remaining-docs.sh:10-50, ARCHIVE/remaining-docs-consolidated-2026-02-13/TAMV-MCP-Cleanup.ps1:5-15, scripts/merge-strategy.ts:5-15
The sequence diagram illustrates the automated decision-making process for file retention during a merge operation. Sources: scripts/merge-strategy.ts:40-85, ARCHIVE/remaining-docs-consolidated-2026-02-13/LOGROS-HOY.md:65-80
Cleanup and Maintenance Utilities
Supplemental scripts provide targeted maintenance for specific documentation and legacy scripting issues.
Documentation Consolidation (Shell Scripting)
The cleanup-remaining-docs.sh script handles the bulk relocation of 35+ redundant documentation files. It maintains an explicit list of "Files to Archive" and "Files to Keep," ensuring that essential documents like TAMV-MASTER-DOCUMENTATION.md and README.md remain at the project root while moving transitory plans and reports (e.g., ROADMAP-7-DIAS.md, PLAN-EJECUCION-INMEDIATO.md) to archival storage.
Sources: cleanup-remaining-docs.sh:18-60
PowerShell MCP Cleanup
The TAMV-MCP-Cleanup.ps1 script targets transient files generated during implementation phases, specifically looking for .log files, temporary .json specs, and automated cleanup scripts themselves that have served their purpose. It provides a summary of space saved and files removed or archived.
Sources: ARCHIVE/remaining-docs-consolidated-2026-02-13/TAMV-MCP-Cleanup.ps1:10-30
Automation Summary
The automation effort resulted in significant repository improvements:
- Documentation reduction: 15 files to 4 active master files (73% reduction).
- Line count reduction: 8,000+ lines to ~1,700 (78% reduction).
- Standardization: 100% English language standardization across all documentation and scripts.
Sources: ARCHIVE/remaining-docs-consolidated-2026-02-13/CLEANUP-COMPLETE-REPORT.md:95-110
Conclusion
Repository Scripts & Automation Tooling serves as the primary mechanism for maintaining the architectural integrity of the TAMV project. By leveraging TypeScript-based analysis and cross-platform shell scripts, the project ensures that documentation remains a single source of truth, redundant codebases are archived systematically, and the overall maintenance burden is minimized. This automated approach transformed a fragmented collection of files into a professional, production-ready project structure.
Sources: ARCHIVE/remaining-docs-consolidated-2026-02-13/CLEANUP-COMPLETE-REPORT.md:165-180, ARCHIVE/remaining-docs-consolidated-2026-02-13/CONSOLIDATION-SUMMARY.md:120-135