const fs = require('fs');
let content = fs.readFileSync('/home/node/.openclaw/workspace/projects/dev-intel-v2/sysdoc.js', 'utf8');

const oldStr = `const sysArchContent = \`# System Architecture
\${archProse}
## Summary Statistics
- **Subsystems:** \${subs.subsystems.length}
- **Helm Charts:** \${helmCharts.length}
- **Total Contracts:** \${contractsResult.contracts.length}
- **Cross-Cutting Concerns:** \${subs.crossCutting.join(', ') || 'none'}

## Subsystems`;

const newStr = `const sysArchContent = \`# System Architecture
\${archProse}
## Summary Statistics
- **Subsystems:** \${subs.subsystems.length}
- **Helm Charts:** \${helmCharts.length}
- **Total Contracts:** \${contractsResult.contracts.length}
- **Cross-Cutting Concerns:** \${subs.crossCutting.join(', ') || 'none'}

## Platform Architecture Patterns

### Layered Architecture
The system is organized into the following logical layers (top to bottom):
\${patterns.layers.map(l => \`- **\${l.layer}** (\${l.repos.join(', ')})\`).join('\\n')}

### Deployment Topology (Hub & Spoke)
ArgoCD ApplicationSets define the following ownership model:
**Hub (Infrastructure/Control Plane):**
\${patterns.appsets.filter(a => a.location === 'hub').map(a => \`- \\\`\${a.name}\\\` manages \\\`\${a.repoName}\\\`\`).join('\\n')}
**Spoke (Applications/Runtime):**
\${patterns.appsets.filter(a => a.location === 'spoke').map(a => \`- \\\`\${a.name}\\\` manages \\\`\${a.repoName}\\\`\`).join('\\n')}

### Cloud Regions Supported
- **AWS:** \${patterns.regions.aws.join(', ')}
- **GCP:** \${patterns.regions.gcp.join(', ')}
- **Azure:** \${patterns.regions.azure.join(', ')}

### Network CIDR Allocations
| CIDR Block | Context | File |
|---|---|---|
\${patterns.cidrs.slice(0, 15).map(c => \`| \\\`\${c.cidr}\\\` | \${c.refs[0].context} | \\\`\${c.refs[0].file}\\\` |\`).join('\\n')}

### Naming Conventions
The following resource naming patterns are enforced:
\${patterns.naming.slice(0, 15).map(n => \`- \\\`\${n.pattern}\\\` (via \\\`\${n.file}\\\`)\`).join('\\n')}

### Tech Stack & Dependencies
**Core Images:**
\${patterns.techStack.containerImages.slice(0, 20).map(i => \`- \\\`\${i}\\\`\`).join('\\n')}

## Subsystems`;

content = content.replace(oldStr, newStr);
fs.writeFileSync('/home/node/.openclaw/workspace/projects/dev-intel-v2/sysdoc.js', content);
