AgentSkillsCN

persona-detection

利用 LLM 与启发式回退算法,结合优先级链检测,精准识别项目角色与定位。

SKILL.md
--- frontmatter
name: "persona-detection"
description: "Intelligent project persona identification using priority chain detection with LLM and heuristic fallback"

Persona Detection Skill

Classification: Inheritable (VS Code heir) | Feature Knowledge Activation: persona, know your customer, project type detection, welcome screen, sidebar persona Inheritance: heir:vscode


Purpose

Detect the most appropriate user persona for a workspace to personalize the Alex experience — sidebar branding, skill suggestions, and working memory P5-P7 configuration.


Priority Chain (Highest to Lowest)

PrioritySourceSignalConfidence
1FocusActive Pomodoro session topic0.95
2GoalStated session objective from goals.json0.85
3PhaseCurrent ROADMAP phase keywords0.75
4Project GoalsLearning goals from user-profile.json0.70
5Profile CacheSaved projectPersona (< 7 days old)cached
6Profile + WorkspaceTech stack, expertise, file structure scoringvariable
7DefaultDeveloper fallback0.50

Detection stops at the first confident match. Lower priorities only run if higher ones return null.


Available Personas (as of v5.6.8)

developer, academic, researcher, technical-writer, architect, data-engineer, devops, content-creator, fiction-writer, game-developer, project-manager, security, student, job-seeker, presenter, power-user


Workspace Scoring (Priority 6 Heuristics)

Three pattern types with distinct matching logic:

Pattern TypeExampleMatch Method
Path (contains /)src/, .github/workflows/fs.pathExists() — directory must actually exist
Extension (starts with .).tex, .fountainendsWith() on workspace entries
FilenameDockerfile, package.jsonExact case-insensitive Set lookup

Critical rule: Never use bidirectional substring matching for workspace patterns. It causes false positives (e.g., .github/workflows/ matching any .github/ entry).


LLM Detection Path

When detectAndUpdateProjectPersona() is called (initialize/upgrade):

  1. Detect technologies from file structure
  2. Gather project context (directory tree, README, package.json, copilot-instructions.md)
  3. Send structured prompt to LLM (prefers GPT-4o > Claude Sonnet > any)
  4. Parse JSON response → match to existing persona or create dynamic one
  5. Save to user-profile.json as projectPersona
  6. Update P5-P7 working memory slots via updateWorkingMemorySlots()

P5-P7 Slot Assignment

Each persona maps to three working memory domain slots via PERSONA_SLOT_MAPPINGS:

PersonaP5 (Primary Support)P6 (Core Skill)P7 (Complementary)
developercode-reviewcode-reviewgit-workflow
academicresearch-project-scaffoldresearch-project-scaffoldcreative-writing
researcherresearch-project-scaffoldresearch-project-scaffoldapi-documentation
technical-writerapi-documentationapi-documentationmarkdown-mermaid
architectarchitecture-healtharchitecture-healthcode-review
data-engineermicrosoft-fabricmicrosoft-fabriccode-review
devopsinfrastructure-as-codeinfrastructure-as-codegit-workflow
content-creatorcreative-writingcreative-writinggamma-presentations
fiction-writercreative-writingcreative-writingscope-management
game-developergame-designgame-designcreative-writing
project-managerproject-managementproject-managementscope-management
securityincident-responseincident-responsecode-review
studentlearning-psychologylearning-psychologydeep-thinking
job-seekercreative-writingcreative-writingcode-review
presentergamma-presentationsgamma-presentationsslide-design
power-usergit-workflowgit-workflowscope-management

P6 comes from the persona's skill field. P5/P7 are defined in PERSONA_SLOT_MAPPINGS. Unknown personas default to code-review (P5) / scope-management (P7).

The welcome view displays all three slots in a "Focus" section with confidence % and detection source.


Adding New Personas

  1. Add to PERSONAS array in personaDetection.ts with: id, name, bannerNoun, hook, skill, icon, accentColor, keywords, techStack, projectPatterns
  2. Add P5/P7 mapping to PERSONA_SLOT_MAPPINGS in personaDetection.ts
  3. Add persona ID to the LLM prompt's personaId enum
  4. Add skill to getSkillDescription() map and skillNameMap in welcomeView.ts
  5. Ensure matching skill exists in .github/skills/

Known Pitfalls

IssueRoot CauseFix
Every Alex project shows DevOps.github/ matched via substringUse fs.pathExists() for path patterns (v5.6.8)
.github/ triggers power-userNoise signal in every projectRemoved from power-user patterns (v5.6.8)
Wrong persona cachedprojectPersona in user-profile.json stale7-day expiry + re-detect on upgrade

Synapses

  • [.github/skills/heir-curation/SKILL.md] (High, Integrates, Forward) - "Persona detection ships to heir via inheritance"
  • [.github/instructions/alex-core.instructions.md] (Medium, References, Forward) - "P5-P7 working memory slots updated by persona detection"
  • [.github/skills/release-process/SKILL.md] (Medium, Validates, Forward) - "Persona detection tested during pre-publish"