/**
 * Example entity scaffolding for new workspaces
 *
 * Creates a connected set of example entities during `studiograph init`
 * to demonstrate the knowledge graph pattern — an organization, project,
 * people, meeting, decision, process, and standard all wikilinked together.
 *
 * Layout: {repo}/{entity-id}.md (flat at repo root). The whole demo folder
 * (`meridian-rebrand`) is the example; users rename or delete it after init.
 * Mirrors what the agent's create_entity tool produces today, so the demo
 * content matches the layout users see going forward.
 */
import { join } from 'path';
import { writeFileSync } from 'fs';
import { MarkdownService } from '../services/markdown.js';
function buildEntities(now) {
    const shared = {
        created_by: 'studiograph',
        updated_by: 'studiograph',
        created_at: now,
        updated_at: now,
        tags: ['example'],
    };
    return [
        {
            repo: 'meridian-rebrand',
            entityType: 'organization',
            entityId: 'meridian-health',
            frontmatter: {
                entity_type: 'organization',
                entity_id: 'meridian-health',
                ...shared,
                name: 'Meridian Health',
                category: 'client',
                status: 'active',
                industry: 'Healthcare',
                contacts: ['[[sarah-chen]]'],
                projects: ['[[meridian-rebrand]]'],
            },
            content: `# Meridian Health

Regional healthcare network with 12 hospitals across the Midwest. Engaged us for a comprehensive brand refresh following their merger with Lakeside Medical Group.

## Relationship History

- **2025-Q4** — Initial outreach via referral from [[sarah-chen]]
- **2026-Q1** — Discovery workshops and brand audit
- **2026-Q1** — Kicked off [[meridian-rebrand]]

## Key Contacts

- [[sarah-chen]] — VP of Marketing, primary stakeholder
`,
        },
        {
            repo: 'meridian-rebrand',
            entityType: 'person',
            entityId: 'sarah-chen',
            frontmatter: {
                entity_type: 'person',
                entity_id: 'sarah-chen',
                ...shared,
                name: 'Sarah Chen',
                role: 'VP of Marketing',
                category: 'client',
                status: 'current',
                employer: '[[meridian-health]]',
                projects: ['[[meridian-rebrand]]'],
            },
            content: `# Sarah Chen

VP of Marketing at [[meridian-health]]. Primary stakeholder for the [[meridian-rebrand]] engagement.

## Notes

- Prefers async communication (email/Slack over calls)
- Strong opinions on accessibility — ensure all deliverables meet WCAG 2.1 AA
- Previously led rebrand at Cedar Health (2023)
`,
        },
        {
            repo: 'meridian-rebrand',
            entityType: 'person',
            entityId: 'alex-rivera',
            frontmatter: {
                entity_type: 'person',
                entity_id: 'alex-rivera',
                ...shared,
                name: 'Alex Rivera',
                role: 'Design Director',
                category: 'employee',
                status: 'current',
                projects: ['[[meridian-rebrand]]'],
            },
            content: `# Alex Rivera

Design Director and internal lead on the [[meridian-rebrand]] project.

## Notes

- Specializes in healthcare and institutional branding
- Facilitated the [[2026-02-10-kickoff]] discovery workshop
- Advocates for the [[discovery-workshop]] process on all brand engagements
`,
        },
        // Project entities (meridian-rebrand repo)
        {
            repo: 'meridian-rebrand',
            entityType: 'project',
            entityId: 'meridian-rebrand',
            frontmatter: {
                entity_type: 'project',
                entity_id: 'meridian-rebrand',
                ...shared,
                name: 'Meridian Health Brand Refresh',
                category: 'client',
                client: '[[meridian-health]]',
                status: 'in-progress',
                start_date: '2026-02-10',
                team: ['[[alex-rivera]]', '[[sarah-chen]]'],
            },
            content: `# Meridian Health Brand Refresh

Comprehensive brand identity refresh for [[meridian-health]] following their merger with Lakeside Medical Group.

## Objectives

1. Unified visual identity across all 12 hospital locations
2. Updated brand guidelines and asset library
3. Digital-first brand system (web, app, social)

## Approach

Following our [[discovery-workshop]] process and [[brand-deliverables-checklist]] standard.

## Key Decisions

- [[dec-2026-001]] — Adopt evolutionary brand refresh (not revolutionary)

## Timeline

- **Feb 2026** — Discovery & audit (see [[2026-02-10-kickoff]])
- **Mar 2026** — Concept development
- **Apr 2026** — Refinement & testing
- **May 2026** — Final delivery & rollout planning
`,
        },
        {
            repo: 'meridian-rebrand',
            entityType: 'event',
            entityId: '2026-02-10-kickoff',
            frontmatter: {
                entity_type: 'event',
                entity_id: '2026-02-10-kickoff',
                ...shared,
                name: 'Meridian Rebrand Kickoff',
                category: 'meeting',
                date: '2026-02-10',
                attendees: ['[[alex-rivera]]', '[[sarah-chen]]'],
                related_projects: ['[[meridian-rebrand]]'],
            },
            content: `# Meridian Rebrand Kickoff

Kickoff meeting for the [[meridian-rebrand]] project with [[alex-rivera]] and [[sarah-chen]]. Followed our [[discovery-workshop]] process.

## Discussion Notes

- Meridian team emphasized the importance of retaining trust signals from both legacy brands
- Patient research shows strong emotional attachment to the Lakeside "caring hands" motif
- Board has approved budget for full rollout by Q3 2026

## Decisions Made

- [[dec-2026-001]] — Agreed to pursue an evolutionary refresh

## Action Items

- [ ] Share brand audit deck with Meridian team
- [ ] Schedule stakeholder interviews (week of Feb 17)
- [ ] Draft creative brief by Feb 14
`,
        },
        {
            repo: 'meridian-rebrand',
            entityType: 'note',
            entityId: 'dec-2026-001',
            frontmatter: {
                entity_type: 'note',
                entity_id: 'dec-2026-001',
                ...shared,
                name: 'Decision: adopt evolutionary brand refresh',
                date: '2026-02-10',
                tags: ['example', 'decision'],
            },
            content: `# Decision: Adopt Evolutionary Brand Refresh

## Context

Following the merger of [[meridian-health]] and Lakeside Medical Group, the combined organization needs a unified brand identity.

## Decision

Evolutionary refresh — retain the Meridian Health name and modernize the visual identity. Decision-makers: [[alex-rivera]], [[sarah-chen]].

## Rationale

- 78% brand recognition for "Meridian" in core markets
- Revolutionary rebrand estimated at 2x the budget and timeline
- Lakeside heritage can be honored through visual motifs

## Consequences

- **Positive:** Preserves brand equity, faster rollout, lower risk
- **Negative:** Some Lakeside staff may feel underrepresented
`,
        },
        {
            repo: 'meridian-rebrand',
            entityType: 'service',
            entityId: 'discovery-workshop',
            frontmatter: {
                entity_type: 'service',
                entity_id: 'discovery-workshop',
                ...shared,
                name: 'Brand Discovery Workshop',
                status: 'offered',
            },
            content: `# Brand Discovery Workshop

A repeatable service for running brand discovery workshops with clients. Used on the [[meridian-rebrand]] project during the [[2026-02-10-kickoff]].

## Steps

1. **Pre-work** — Send brand perception survey to client stakeholders (5-7 business days before)
2. **Brand audit** — Review existing brand assets, competitors, and market positioning
3. **Stakeholder interviews** — 30-minute 1:1s with key decision makers
4. **Workshop session** (half day)
   - Brand values card sort exercise
   - Visual preference mapping (mood boards)
   - Audience persona review
   - Competitive positioning matrix
5. **Synthesis** — Consolidate findings into a discovery brief within 48 hours
6. **Readout** — Present discovery findings and recommended direction to client

## Tips

- Always include both client-side and internal team members
- Record the session (with permission) for reference
- Use the [[brand-deliverables-checklist]] to ensure all outputs are planned
`,
        },
        {
            repo: 'meridian-rebrand',
            entityType: 'document',
            entityId: 'brand-deliverables-checklist',
            frontmatter: {
                entity_type: 'document',
                entity_id: 'brand-deliverables-checklist',
                ...shared,
                name: 'Brand Deliverables Checklist',
                category: 'guideline',
                status: 'final',
            },
            content: `# Brand Deliverables Checklist

Standard checklist of deliverables for brand projects. Referenced by the [[meridian-rebrand]] project.

## Core Identity

- [ ] Logo (primary, secondary, icon)
- [ ] Color palette (primary, secondary, extended)
- [ ] Typography system (headings, body, UI)
- [ ] Photography/illustration style guide

## Brand Guidelines

- [ ] Brand guidelines document (PDF + digital)
- [ ] Voice and tone guide
- [ ] Logo usage and clear space rules
- [ ] Accessibility compliance notes (WCAG 2.1 AA)

## Application Templates

- [ ] Business cards and stationery
- [ ] Email signatures
- [ ] Presentation template
- [ ] Social media templates

## Digital Assets

- [ ] Asset library (organized by format and use case)
- [ ] Icon set
- [ ] Web/app component style tokens
`,
        },
    ];
}
function buildOnboardingGuide(teamName) {
    return `# Welcome to ${teamName}

This workspace is powered by **Studiograph** — a knowledge graph for creative teams.

## How It Works

Every piece of knowledge is an **entity** — a Markdown file with structured metadata. Entries live alongside each other in the folder you choose; the entity *type* (project, meeting, decision, …) lives in the file's frontmatter, not in its path.

\`\`\`
meridian-rebrand/              ← Folder
  meridian-health.md           ← organization
  sarah-chen.md                ← person
  alex-rivera.md               ← person
  meridian-rebrand.md          ← project
  2026-02-10-kickoff.md        ← meeting
  dec-2026-001.md              ← decision
  discovery-workshop.md        ← process
  brand-deliverables-checklist.md  ← guideline
\`\`\`

Entities link to each other with \`[[wikilinks]]\`, creating a navigable knowledge graph.

## Entity Types

| Type | Purpose | Example |
|------|---------|---------|
| \`organization\` | Clients, vendors, partners | Meridian Health |
| \`person\` | Contacts & team members | Sarah Chen, Alex Rivera |
| \`project\` | Engagements & initiatives | Brand refresh |
| \`meeting\` | Meeting notes & action items | Kickoff meeting |
| \`decision\` | Structured decision records | Evolutionary refresh |
| \`process\` | Repeatable methods & workflows | Discovery workshop |
| \`guideline\` | Team guidelines & checklists | Brand deliverables checklist |
| \`document\` | Proposals, contracts, briefs | — |
| \`note\` | Freeform thinking & research | — |
| \`task\` | Trackable work items | — |
| \`case-study\` | Project retrospectives | — |

## Try Asking the Agent

\`\`\`bash
studiograph start
\`\`\`

Once connected, try these questions:

- "What projects have we done for Meridian Health?"
- "Who is the primary contact for the rebrand?"
- "How do we run a discovery workshop?"
- "What decisions have been made on the rebrand?"
- "What are the standard deliverables for a brand project?"

## Common Commands

\`\`\`bash
studiograph start              # Start an interactive AI session
studiograph search "query"     # Search across all folders
studiograph serve              # Launch web UI
\`\`\`

## Make It Yours

The example entities are tagged with \`example\` for easy identification.

1. Rename "meridian-rebrand" to your project name
2. Edit the example entities or replace them with real ones
3. Create new folders for other projects or knowledge areas

Or start fresh:

\`\`\`bash
studiograph folder remove meridian-rebrand --delete-files
studiograph folder add <your-folder>
\`\`\`
`;
}
export async function scaffoldExampleEntities(workspace, teamName) {
    const workspacePath = workspace.getWorkspacePath();
    const md = new MarkdownService();
    const now = new Date().toISOString();
    const entities = buildEntities(now);
    for (const entity of entities) {
        const filePath = join(workspacePath, entity.repo, `${entity.entityId}.md`);
        md.writeFile(filePath, {
            frontmatter: entity.frontmatter,
            content: entity.content,
            wikilinks: [],
        });
    }
    // Write STUDIOGRAPH.md to workspace root
    const guidePath = join(workspacePath, 'STUDIOGRAPH.md');
    writeFileSync(guidePath, buildOnboardingGuide(teamName), 'utf-8');
}
//# sourceMappingURL=scaffolding.js.map