oh-my-codex-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/skills/agent-kb/HOW_TO_USE.md +428 -0
- package/.agent/skills/agent-kb/README.md +46 -0
- package/.agent/skills/agent-kb/SKILL.md +128 -0
- package/.agent/skills/agent-kb/references/intelligent-analysis-explained.md +333 -0
- package/.agent/skills/agent-kb/references/query-optimization.md +225 -0
- package/.agent/skills/aireview/SKILL.md +704 -0
- package/.agent/skills/analyze/SKILL.md +81 -0
- package/.agent/skills/architect-planner/HOW_TO_USE.md +238 -0
- package/.agent/skills/architect-planner/README.md +41 -0
- package/.agent/skills/architect-planner/SKILL.md +539 -0
- package/.agent/skills/auto-mbti/SKILL.md +291 -0
- package/.agent/skills/autopilot/SKILL.md +222 -0
- package/.agent/skills/backend-patterns/SKILL.md +602 -0
- package/.agent/skills/bdd-generator/README.md +78 -0
- package/.agent/skills/bdd-generator/SKILL.md +436 -0
- package/.agent/skills/brainstorming/HOW_TO_USE.md +289 -0
- package/.agent/skills/brainstorming/README.md +41 -0
- package/.agent/skills/brainstorming/SKILL.md +165 -0
- package/.agent/skills/build-fix/SKILL.md +190 -0
- package/.agent/skills/cancel/SKILL.md +658 -0
- package/.agent/skills/checkpoint/SKILL.md +94 -0
- package/.agent/skills/code-review/SKILL.md +273 -0
- package/.agent/skills/coding-standards/SKILL.md +535 -0
- package/.agent/skills/conductor/SKILL.md +128 -0
- package/.agent/skills/conductor/commands/conductor/implement.toml +358 -0
- package/.agent/skills/conductor/commands/conductor/newTrack.toml +142 -0
- package/.agent/skills/conductor/commands/conductor/revert.toml +123 -0
- package/.agent/skills/conductor/commands/conductor/setup.toml +429 -0
- package/.agent/skills/conductor/commands/conductor/status.toml +57 -0
- package/.agent/skills/conductor/scripts/install.sh +89 -0
- package/.agent/skills/conductor/templates/code_styleguides/csharp.md +115 -0
- package/.agent/skills/conductor/templates/code_styleguides/dart.md +238 -0
- package/.agent/skills/conductor/templates/code_styleguides/general.md +23 -0
- package/.agent/skills/conductor/templates/code_styleguides/go.md +48 -0
- package/.agent/skills/conductor/templates/code_styleguides/html-css.md +49 -0
- package/.agent/skills/conductor/templates/code_styleguides/javascript.md +51 -0
- package/.agent/skills/conductor/templates/code_styleguides/python.md +37 -0
- package/.agent/skills/conductor/templates/code_styleguides/typescript.md +43 -0
- package/.agent/skills/conductor/templates/rules/README.md +23 -0
- package/.agent/skills/conductor/templates/rules/agents.md +49 -0
- package/.agent/skills/conductor/templates/rules/coding-style.md +70 -0
- package/.agent/skills/conductor/templates/rules/dev.md +20 -0
- package/.agent/skills/conductor/templates/rules/git-workflow.md +45 -0
- package/.agent/skills/conductor/templates/rules/hooks.md +6 -0
- package/.agent/skills/conductor/templates/rules/patterns.md +55 -0
- package/.agent/skills/conductor/templates/rules/performance.md +47 -0
- package/.agent/skills/conductor/templates/rules/research.md +26 -0
- package/.agent/skills/conductor/templates/rules/review.md +22 -0
- package/.agent/skills/conductor/templates/rules/security.md +36 -0
- package/.agent/skills/conductor/templates/rules/testing.md +30 -0
- package/.agent/skills/conductor/templates/workflow.md +333 -0
- package/.agent/skills/consensus/HOW_TO_USE.md +191 -0
- package/.agent/skills/consensus/README.md +41 -0
- package/.agent/skills/consensus/SKILL.md +317 -0
- package/.agent/skills/content-research-writer/SKILL.md +537 -0
- package/.agent/skills/debug-analysis/SKILL.md +331 -0
- package/.agent/skills/deepinit/SKILL.md +347 -0
- package/.agent/skills/deepsearch/SKILL.md +56 -0
- package/.agent/skills/doctor/SKILL.md +158 -0
- package/.agent/skills/drawio/EXAMPLES.md +382 -0
- package/.agent/skills/drawio/QUICK_START.md +237 -0
- package/.agent/skills/drawio/README.md +315 -0
- package/.agent/skills/drawio/SETUP_GUIDE.md +254 -0
- package/.agent/skills/drawio/SKILL.md +1176 -0
- package/.agent/skills/e2e/SKILL.md +396 -0
- package/.agent/skills/ecomode/SKILL.md +160 -0
- package/.agent/skills/electron-driver/SKILL.md +144 -0
- package/.agent/skills/electron-driver/scripts/driver-template.js +71 -0
- package/.agent/skills/eval/SKILL.md +140 -0
- package/.agent/skills/eval-harness/SKILL.md +242 -0
- package/.agent/skills/evolve/SKILL.md +213 -0
- package/.agent/skills/frontend-design/SKILL.md +42 -0
- package/.agent/skills/frontend-patterns/SKILL.md +646 -0
- package/.agent/skills/frontend-ui-ux/SKILL.md +70 -0
- package/.agent/skills/git-master/SKILL.md +75 -0
- package/.agent/skills/help/SKILL.md +89 -0
- package/.agent/skills/iterative-retrieval/SKILL.md +217 -0
- package/.agent/skills/local-skills-setup/SKILL.md +483 -0
- package/.agent/skills/log-analyzer/SKILL.md +187 -0
- package/.agent/skills/mcp-setup/SKILL.md +226 -0
- package/.agent/skills/multi-model-research/HOW_TO_USE.md +614 -0
- package/.agent/skills/multi-model-research/README.md +233 -0
- package/.agent/skills/multi-model-research/SKILL.md +541 -0
- package/.agent/skills/multi-model-research/references/troubleshooting.md +415 -0
- package/.agent/skills/note/SKILL.md +80 -0
- package/.agent/skills/omc-setup/SKILL.md +219 -0
- package/.agent/skills/orchestrate/SKILL.md +620 -0
- package/.agent/skills/patent-workflow/IMPLEMENTATION_SUMMARY.md +500 -0
- package/.agent/skills/patent-workflow/README.md +455 -0
- package/.agent/skills/patent-workflow/SKILL.md +1036 -0
- package/.agent/skills/patent-workflow/tools/irr_checker.py +260 -0
- package/.agent/skills/patent-workflow/tools/sample_terminology.json +49 -0
- package/.agent/skills/patent-workflow/tools/term_checker.py +355 -0
- package/.agent/skills/pattern-recognition/SKILL.md +792 -0
- package/.agent/skills/pipeline/SKILL.md +448 -0
- package/.agent/skills/plan/SKILL.md +309 -0
- package/.agent/skills/planning-methodology/SKILL.md +370 -0
- package/.agent/skills/planning-with-files/SKILL.md +210 -0
- package/.agent/skills/planning-with-files/examples.md +202 -0
- package/.agent/skills/planning-with-files/reference.md +218 -0
- package/.agent/skills/planning-with-files/scripts/check-complete.ps1 +42 -0
- package/.agent/skills/planning-with-files/scripts/check-complete.sh +44 -0
- package/.agent/skills/planning-with-files/scripts/init-session.ps1 +120 -0
- package/.agent/skills/planning-with-files/scripts/init-session.sh +120 -0
- package/.agent/skills/planning-with-files/scripts/session-catchup.py +208 -0
- package/.agent/skills/planning-with-files/templates/findings.md +95 -0
- package/.agent/skills/planning-with-files/templates/progress.md +114 -0
- package/.agent/skills/planning-with-files/templates/task_plan.md +132 -0
- package/.agent/skills/project-analyze/CLAUDE.md +18 -0
- package/.agent/skills/project-analyze/HOW_TO_USE.md +145 -0
- package/.agent/skills/project-analyze/README.md +42 -0
- package/.agent/skills/project-analyze/SKILL.md +289 -0
- package/.agent/skills/project-analyze/SKILL.md.backup +287 -0
- package/.agent/skills/project-analyze/SKILL.md.backup_20260105_093646 +287 -0
- package/.agent/skills/project-analyze/assets/analysis-report-template.md +433 -0
- package/.agent/skills/project-analyze/references/analysis-patterns.md +422 -0
- package/.agent/skills/project-analyze/references/projectmind-explained.md +535 -0
- package/.agent/skills/project-session-manager/SKILL.md +428 -0
- package/.agent/skills/project-session-manager/lib/config.sh +86 -0
- package/.agent/skills/project-session-manager/lib/parse.sh +121 -0
- package/.agent/skills/project-session-manager/lib/session.sh +132 -0
- package/.agent/skills/project-session-manager/lib/tmux.sh +103 -0
- package/.agent/skills/project-session-manager/lib/worktree.sh +171 -0
- package/.agent/skills/project-session-manager/psm.sh +629 -0
- package/.agent/skills/project-session-manager/templates/feature.md +56 -0
- package/.agent/skills/project-session-manager/templates/issue-fix.md +57 -0
- package/.agent/skills/project-session-manager/templates/pr-review.md +65 -0
- package/.agent/skills/project-session-manager/templates/projects.json +19 -0
- package/.agent/skills/quality-check/HOW_TO_USE.md +171 -0
- package/.agent/skills/quality-check/README.md +50 -0
- package/.agent/skills/quality-check/SKILL.md +240 -0
- package/.agent/skills/quality-check/SKILL.md.backup +238 -0
- package/.agent/skills/quality-check/SKILL.md.backup_20260105_093646 +238 -0
- package/.agent/skills/quality-check/assets/quality-report-template.md +437 -0
- package/.agent/skills/quality-check/references/refactoring-patterns.md +550 -0
- package/.agent/skills/quality-check/references/scoring-criteria.md +454 -0
- package/.agent/skills/quality-validation/SKILL.md +519 -0
- package/.agent/skills/quality-validation/SKILL.md.backup +573 -0
- package/.agent/skills/quality-validation/SKILL.md.backup_20260105_093646 +573 -0
- package/.agent/skills/ralph/SKILL.md +236 -0
- package/.agent/skills/ralph-init/SKILL.md +78 -0
- package/.agent/skills/ralplan/SKILL.md +58 -0
- package/.agent/skills/refactor-clean/SKILL.md +49 -0
- package/.agent/skills/release/SKILL.md +84 -0
- package/.agent/skills/research/SKILL.md +526 -0
- package/.agent/skills/research-methodology/SKILL.md +268 -0
- package/.agent/skills/review/SKILL.md +53 -0
- package/.agent/skills/security-review/SKILL.md +509 -0
- package/.agent/skills/security-review/cloud-infrastructure-security.md +361 -0
- package/.agent/skills/setup-pm/SKILL.md +102 -0
- package/.agent/skills/skill/SKILL.md +424 -0
- package/.agent/skills/skill-create/SKILL.md +209 -0
- package/.agent/skills/skill-debugger/HOW_TO_USE.md +244 -0
- package/.agent/skills/skill-debugger/README.md +44 -0
- package/.agent/skills/skill-debugger/SKILL.md +326 -0
- package/.agent/skills/skill-debugger/diagnostic_checklist.md +115 -0
- package/.agent/skills/skill-development/SKILL.md +661 -0
- package/.agent/skills/skill-development/references/skill-creator-original.md +209 -0
- package/.agent/skills/skill-doc-generator/README.md +37 -0
- package/.agent/skills/skill-doc-generator/SKILL.md +331 -0
- package/.agent/skills/skill-quality-analyzer/HOW_TO_USE.md +243 -0
- package/.agent/skills/skill-quality-analyzer/README.md +61 -0
- package/.agent/skills/skill-quality-analyzer/SKILL.md +247 -0
- package/.agent/skills/skill-quality-analyzer/analyzer.py +209 -0
- package/.agent/skills/skill-quality-analyzer/expected_output.json +81 -0
- package/.agent/skills/skill-quality-analyzer/sample_input.json +9 -0
- package/.agent/skills/skill-tester/README.md +46 -0
- package/.agent/skills/skill-tester/SKILL.md +345 -0
- package/.agent/skills/start-dev/SKILL.md +701 -0
- package/.agent/skills/swarm/SKILL.md +691 -0
- package/.agent/skills/task-kb-lookup/SKILL.md +211 -0
- package/.agent/skills/task-kb-record/SKILL.md +417 -0
- package/.agent/skills/tdd/SKILL.md +446 -0
- package/.agent/skills/tdd-generator/DEMO.md +516 -0
- package/.agent/skills/tdd-generator/README.md +89 -0
- package/.agent/skills/tdd-generator/SKILL.md +278 -0
- package/.agent/skills/tdd-workflow/SKILL.md +424 -0
- package/.agent/skills/test-coverage/SKILL.md +48 -0
- package/.agent/skills/thinkdeep/HOW_TO_USE.md +183 -0
- package/.agent/skills/thinkdeep/README.md +41 -0
- package/.agent/skills/thinkdeep/SKILL.md +343 -0
- package/.agent/skills/ui-ux-pro-max/SKILL.md +228 -0
- package/.agent/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/.agent/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/.agent/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/.agent/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/.agent/skills/ui-ux-pro-max/data/prompts.csv +24 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.agent/skills/ui-ux-pro-max/data/styles.csv +59 -0
- package/.agent/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/.agent/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.agent/skills/ui-ux-pro-max/scripts/core.py +236 -0
- package/.agent/skills/ui-ux-pro-max/scripts/search.py +61 -0
- package/.agent/skills/ultrapilot/SKILL.md +647 -0
- package/.agent/skills/ultraqa/SKILL.md +152 -0
- package/.agent/skills/ultrawork/SKILL.md +123 -0
- package/.agent/skills/update-codemaps/SKILL.md +38 -0
- package/.agent/skills/update-docs/SKILL.md +52 -0
- package/.agent/skills/verification-loop/SKILL.md +140 -0
- package/.agent/skills/verify/SKILL.md +80 -0
- package/.agent/skills/writer-memory/SKILL.md +459 -0
- package/.agent/skills/writer-memory/lib/character-tracker.ts +338 -0
- package/.agent/skills/writer-memory/lib/memory-manager.ts +804 -0
- package/.agent/skills/writer-memory/lib/relationship-graph.ts +400 -0
- package/.agent/skills/writer-memory/lib/scene-organizer.ts +544 -0
- package/.agent/skills/writer-memory/lib/synopsis-builder.ts +339 -0
- package/.agent/skills/writer-memory/templates/synopsis-template.md +46 -0
- package/.governance/skill-lint.allowlist +4 -0
- package/.governance/skill-llm.allowlist +4 -0
- package/AGENTS.md +59 -0
- package/LICENSE +21 -0
- package/README.md +169 -0
- package/README.zh.md +145 -0
- package/bin/omcodex.js +8 -0
- package/commands/conductor/implement.toml +358 -0
- package/commands/conductor/newTrack.toml +142 -0
- package/commands/conductor/revert.toml +123 -0
- package/commands/conductor/setup.toml +429 -0
- package/commands/conductor/status.toml +57 -0
- package/docs/ALIGNMENT.md +40 -0
- package/docs/CODEX.md +133 -0
- package/docs/NOTIFY.md +81 -0
- package/docs/SKILL_GOVERNANCE.md +72 -0
- package/docs/SKILL_GOVERNANCE_FRAMEWORK.md +182 -0
- package/docs/SKILL_GOVERNANCE_FRAMEWORK.zh.md +170 -0
- package/package.json +50 -0
- package/prompts/architect.md +105 -0
- package/prompts/executor.md +134 -0
- package/prompts/planner.md +113 -0
- package/scripts/check-skill-governance.sh +84 -0
- package/scripts/check-skill-llm-governance.js +302 -0
- package/scripts/eval-skills.js +217 -0
- package/scripts/generate-catalog-docs.js +95 -0
- package/scripts/generate-codex-mcp-config.sh +22 -0
- package/scripts/install-codex-force.sh +5 -0
- package/scripts/install-codex-incremental.sh +5 -0
- package/scripts/install-codex.sh +79 -0
- package/scripts/notify-dispatch.js +15 -0
- package/scripts/setup-package-manager.js +137 -0
- package/src/catalog/generated/public-catalog.json +547 -0
- package/src/catalog/manifest.json +542 -0
- package/src/catalog/reader.js +43 -0
- package/src/catalog/schema.js +79 -0
- package/src/cli/doctor.js +62 -0
- package/src/cli/index.js +85 -0
- package/src/cli/notify.js +127 -0
- package/src/cli/route.js +43 -0
- package/src/cli/setup.js +155 -0
- package/src/cli/team.js +125 -0
- package/src/config/generator.js +119 -0
- package/src/mcp/memory-server.js +241 -0
- package/src/mcp/state-server.js +112 -0
- package/src/mcp/trace-server.js +168 -0
- package/src/notify/dispatch.js +74 -0
- package/src/notify/extensibility/dispatcher.js +113 -0
- package/src/notify/extensibility/events.js +15 -0
- package/src/notify/extensibility/loader.js +54 -0
- package/src/router/skill-router.js +90 -0
- package/src/team/auto-advance.js +72 -0
- package/src/team/orchestrator.js +82 -0
- package/src/team/state-store.js +33 -0
- package/src/utils/paths.js +33 -0
- package/templates/AGENTS.md +15 -0
- package/templates/catalog-manifest.json +542 -0
- package/templates/code_styleguides/csharp.md +115 -0
- package/templates/code_styleguides/dart.md +238 -0
- package/templates/code_styleguides/general.md +23 -0
- package/templates/code_styleguides/go.md +48 -0
- package/templates/code_styleguides/html-css.md +49 -0
- package/templates/code_styleguides/javascript.md +51 -0
- package/templates/code_styleguides/python.md +37 -0
- package/templates/code_styleguides/typescript.md +43 -0
- package/templates/rules/README.md +23 -0
- package/templates/rules/agents.md +49 -0
- package/templates/rules/coding-style.md +70 -0
- package/templates/rules/dev.md +20 -0
- package/templates/rules/git-workflow.md +45 -0
- package/templates/rules/notify.md +6 -0
- package/templates/rules/patterns.md +55 -0
- package/templates/rules/performance.md +47 -0
- package/templates/rules/research.md +26 -0
- package/templates/rules/review.md +22 -0
- package/templates/rules/security.md +36 -0
- package/templates/rules/testing.md +30 -0
- package/templates/workflow.md +333 -0
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
# ProjectMind Technical Architecture
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
ProjectMind is a knowledge graph-based intelligent project analysis system that provides 40-second project understanding through automated dependency analysis and architectural pattern recognition.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## System Architecture
|
|
10
|
+
|
|
11
|
+
### Three-Layer Design
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Layer 1: File Discovery & Parsing
|
|
15
|
+
↓
|
|
16
|
+
Layer 2: Knowledge Graph Construction
|
|
17
|
+
↓
|
|
18
|
+
Layer 3: Pattern Recognition & Analysis
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Layer 1: File Discovery & Parsing
|
|
22
|
+
|
|
23
|
+
**Purpose**: Efficiently discover and parse project files
|
|
24
|
+
|
|
25
|
+
**Components**:
|
|
26
|
+
|
|
27
|
+
1. **File Scanner**
|
|
28
|
+
- Fast directory traversal (ignore `node_modules`, `.git`, etc.)
|
|
29
|
+
- File type detection (extension-based + content-based)
|
|
30
|
+
- Configurable ignore patterns
|
|
31
|
+
|
|
32
|
+
2. **Parsers**
|
|
33
|
+
- **JSON Parser**: `package.json`, `tsconfig.json`, etc.
|
|
34
|
+
- **YAML Parser**: `.gitlab-ci.yml`, `docker-compose.yml`, etc.
|
|
35
|
+
- **Code Parser**: JavaScript/TypeScript AST analysis
|
|
36
|
+
- **Markdown Parser**: README, docs structure
|
|
37
|
+
|
|
38
|
+
**Performance Optimizations**:
|
|
39
|
+
- Parallel file reading (Worker threads)
|
|
40
|
+
- Streaming for large files
|
|
41
|
+
- Caching frequently accessed files
|
|
42
|
+
- Skip binary files
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### Layer 2: Knowledge Graph Construction
|
|
47
|
+
|
|
48
|
+
**Purpose**: Build interconnected knowledge graph of project structure
|
|
49
|
+
|
|
50
|
+
**Graph Schema**:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
interface ProjectNode {
|
|
54
|
+
id: string;
|
|
55
|
+
type: NodeType;
|
|
56
|
+
properties: Record<string, any>;
|
|
57
|
+
relationships: Relationship[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
type NodeType =
|
|
61
|
+
| 'Project'
|
|
62
|
+
| 'Package'
|
|
63
|
+
| 'Module'
|
|
64
|
+
| 'File'
|
|
65
|
+
| 'Function'
|
|
66
|
+
| 'Class'
|
|
67
|
+
| 'Dependency'
|
|
68
|
+
| 'Config';
|
|
69
|
+
|
|
70
|
+
interface Relationship {
|
|
71
|
+
type: RelationType;
|
|
72
|
+
from: string; // Node ID
|
|
73
|
+
to: string; // Node ID
|
|
74
|
+
properties?: Record<string, any>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
type RelationType =
|
|
78
|
+
| 'IMPORTS'
|
|
79
|
+
| 'EXPORTS'
|
|
80
|
+
| 'DEPENDS_ON'
|
|
81
|
+
| 'CONTAINS'
|
|
82
|
+
| 'CONFIGURES'
|
|
83
|
+
| 'CALLS'
|
|
84
|
+
| 'EXTENDS'
|
|
85
|
+
| 'IMPLEMENTS';
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Graph Construction Process**:
|
|
89
|
+
|
|
90
|
+
1. **Create Root Node**
|
|
91
|
+
```typescript
|
|
92
|
+
const projectNode: ProjectNode = {
|
|
93
|
+
id: 'project:root',
|
|
94
|
+
type: 'Project',
|
|
95
|
+
properties: {
|
|
96
|
+
name: packageJson.name,
|
|
97
|
+
version: packageJson.version,
|
|
98
|
+
type: detectProjectType(),
|
|
99
|
+
},
|
|
100
|
+
relationships: []
|
|
101
|
+
};
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
2. **Build Dependency Graph**
|
|
105
|
+
```typescript
|
|
106
|
+
// External dependencies
|
|
107
|
+
for (const [dep, version] of Object.entries(packageJson.dependencies)) {
|
|
108
|
+
const depNode = createDependencyNode(dep, version);
|
|
109
|
+
graph.add(depNode);
|
|
110
|
+
graph.addRelationship('project:root', depNode.id, 'DEPENDS_ON');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Internal module dependencies
|
|
114
|
+
for (const file of sourceFiles) {
|
|
115
|
+
const imports = parseImports(file);
|
|
116
|
+
for (const imp of imports) {
|
|
117
|
+
if (isInternalModule(imp)) {
|
|
118
|
+
graph.addRelationship(file.id, resolveModule(imp).id, 'IMPORTS');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
3. **Extract Component Hierarchy**
|
|
125
|
+
```typescript
|
|
126
|
+
// Identify layers (UI, Business Logic, Data Access)
|
|
127
|
+
const layerPatterns = {
|
|
128
|
+
ui: /^(components|pages|views)\//,
|
|
129
|
+
logic: /^(services|models|lib)\//,
|
|
130
|
+
data: /^(repositories|dao|database)\//
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
for (const file of sourceFiles) {
|
|
134
|
+
const layer = detectLayer(file.path, layerPatterns);
|
|
135
|
+
file.properties.layer = layer;
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Graph Storage**:
|
|
140
|
+
- In-memory graph for fast queries
|
|
141
|
+
- Optional persistence (SQLite for large projects)
|
|
142
|
+
- Efficient serialization for caching
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
### Layer 3: Pattern Recognition & Analysis
|
|
147
|
+
|
|
148
|
+
**Purpose**: Recognize architectural patterns and provide insights
|
|
149
|
+
|
|
150
|
+
**Pattern Recognition Algorithms**:
|
|
151
|
+
|
|
152
|
+
1. **Architecture Pattern Detection**
|
|
153
|
+
```typescript
|
|
154
|
+
function detectArchitecturePattern(graph: ProjectGraph): Pattern {
|
|
155
|
+
const indicators = {
|
|
156
|
+
mvc: hasMVCStructure(graph),
|
|
157
|
+
microservices: hasMicroservicesStructure(graph),
|
|
158
|
+
layered: hasLayeredArchitecture(graph),
|
|
159
|
+
eventDriven: hasEventBusPatterns(graph),
|
|
160
|
+
monorepo: hasMonorepoStructure(graph)
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
return findBestMatch(indicators);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function hasMVCStructure(graph: ProjectGraph): boolean {
|
|
167
|
+
const dirs = graph.getDirectories();
|
|
168
|
+
return dirs.includes('controllers') &&
|
|
169
|
+
dirs.includes('models') &&
|
|
170
|
+
(dirs.includes('views') || dirs.includes('templates'));
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
2. **Complexity Analysis**
|
|
175
|
+
```typescript
|
|
176
|
+
function analyzeComplexity(graph: ProjectGraph): ComplexityMetrics {
|
|
177
|
+
return {
|
|
178
|
+
fileCount: graph.nodes.filter(n => n.type === 'File').length,
|
|
179
|
+
avgFileSize: calculateAverageFileSize(graph),
|
|
180
|
+
maxNestingDepth: findMaxNestingDepth(graph),
|
|
181
|
+
cyclomaticComplexity: calculateCyclomaticComplexity(graph),
|
|
182
|
+
dependencyDepth: calculateDependencyDepth(graph)
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
3. **Hotspot Detection**
|
|
188
|
+
```typescript
|
|
189
|
+
function findHotspots(graph: ProjectGraph, gitHistory: GitLog[]): Hotspot[] {
|
|
190
|
+
// Files changed most frequently
|
|
191
|
+
const changeFrequency = calculateChangeFrequency(gitHistory);
|
|
192
|
+
|
|
193
|
+
// Files with most dependencies
|
|
194
|
+
const dependencyCount = graph.nodes.map(node => ({
|
|
195
|
+
file: node,
|
|
196
|
+
deps: graph.getRelationships(node.id, 'DEPENDS_ON').length
|
|
197
|
+
}));
|
|
198
|
+
|
|
199
|
+
// Combine metrics
|
|
200
|
+
return combineMetrics(changeFrequency, dependencyCount);
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
4. **Technical Debt Identification**
|
|
205
|
+
```typescript
|
|
206
|
+
function identifyTechnicalDebt(graph: ProjectGraph): TechnicalDebt[] {
|
|
207
|
+
const debt: TechnicalDebt[] = [];
|
|
208
|
+
|
|
209
|
+
// Outdated dependencies
|
|
210
|
+
debt.push(...findOutdatedDependencies(graph));
|
|
211
|
+
|
|
212
|
+
// Circular dependencies
|
|
213
|
+
debt.push(...findCircularDependencies(graph));
|
|
214
|
+
|
|
215
|
+
// Dead code
|
|
216
|
+
debt.push(...findDeadCode(graph));
|
|
217
|
+
|
|
218
|
+
// Code duplication
|
|
219
|
+
debt.push(...findDuplicatedCode(graph));
|
|
220
|
+
|
|
221
|
+
return debt.sort((a, b) => b.severity - a.severity);
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Key Algorithms
|
|
228
|
+
|
|
229
|
+
### 1. Dependency Resolution
|
|
230
|
+
|
|
231
|
+
**Challenge**: Resolve relative imports to absolute module paths
|
|
232
|
+
|
|
233
|
+
**Algorithm**:
|
|
234
|
+
```typescript
|
|
235
|
+
function resolveImport(
|
|
236
|
+
importPath: string,
|
|
237
|
+
fromFile: string,
|
|
238
|
+
tsConfig: TSConfig
|
|
239
|
+
): string {
|
|
240
|
+
// Check if it's a path alias (e.g., '@/components/Button')
|
|
241
|
+
if (tsConfig.paths) {
|
|
242
|
+
for (const [alias, targets] of Object.entries(tsConfig.paths)) {
|
|
243
|
+
if (importPath.startsWith(alias)) {
|
|
244
|
+
return resolveAlias(importPath, alias, targets);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Resolve relative path
|
|
250
|
+
if (importPath.startsWith('.')) {
|
|
251
|
+
return path.resolve(path.dirname(fromFile), importPath);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// External module
|
|
255
|
+
return importPath;
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**Performance**: O(1) with path alias cache
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
### 2. Circular Dependency Detection
|
|
264
|
+
|
|
265
|
+
**Challenge**: Detect cycles in module dependency graph
|
|
266
|
+
|
|
267
|
+
**Algorithm**: Depth-First Search with cycle detection
|
|
268
|
+
```typescript
|
|
269
|
+
function findCircularDependencies(graph: ProjectGraph): Cycle[] {
|
|
270
|
+
const cycles: Cycle[] = [];
|
|
271
|
+
const visited = new Set<string>();
|
|
272
|
+
const recursionStack = new Set<string>();
|
|
273
|
+
|
|
274
|
+
function dfs(nodeId: string, path: string[] = []): void {
|
|
275
|
+
if (recursionStack.has(nodeId)) {
|
|
276
|
+
// Found cycle
|
|
277
|
+
const cycleStart = path.indexOf(nodeId);
|
|
278
|
+
cycles.push(path.slice(cycleStart));
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (visited.has(nodeId)) return;
|
|
283
|
+
|
|
284
|
+
visited.add(nodeId);
|
|
285
|
+
recursionStack.add(nodeId);
|
|
286
|
+
path.push(nodeId);
|
|
287
|
+
|
|
288
|
+
const deps = graph.getRelationships(nodeId, 'IMPORTS');
|
|
289
|
+
for (const dep of deps) {
|
|
290
|
+
dfs(dep.to, [...path]);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
recursionStack.delete(nodeId);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
for (const node of graph.nodes) {
|
|
297
|
+
if (!visited.has(node.id)) {
|
|
298
|
+
dfs(node.id);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return cycles;
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**Performance**: O(V + E) where V = nodes, E = edges
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
### 3. Layer Detection
|
|
311
|
+
|
|
312
|
+
**Challenge**: Automatically detect architectural layers
|
|
313
|
+
|
|
314
|
+
**Algorithm**: Pattern matching + heuristics
|
|
315
|
+
```typescript
|
|
316
|
+
function detectLayers(graph: ProjectGraph): LayerMap {
|
|
317
|
+
const layers: LayerMap = {
|
|
318
|
+
presentation: [],
|
|
319
|
+
business: [],
|
|
320
|
+
data: [],
|
|
321
|
+
infrastructure: []
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
for (const node of graph.nodes.filter(n => n.type === 'File')) {
|
|
325
|
+
const layer = classifyByPath(node.properties.path) ||
|
|
326
|
+
classifyByDependencies(node, graph) ||
|
|
327
|
+
classifyByNamingConvention(node);
|
|
328
|
+
|
|
329
|
+
layers[layer].push(node);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return layers;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function classifyByPath(filePath: string): Layer | null {
|
|
336
|
+
const patterns = {
|
|
337
|
+
presentation: /\/(components|pages|views|ui)\//,
|
|
338
|
+
business: /\/(services|models|domain|logic)\//,
|
|
339
|
+
data: /\/(repositories|dao|models|entities)\//,
|
|
340
|
+
infrastructure: /\/(config|utils|helpers|lib)\//
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
for (const [layer, pattern] of Object.entries(patterns)) {
|
|
344
|
+
if (pattern.test(filePath)) return layer as Layer;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## Performance Characteristics
|
|
354
|
+
|
|
355
|
+
### Analysis Speed
|
|
356
|
+
|
|
357
|
+
| Project Size | File Count | Analysis Time | Memory Usage |
|
|
358
|
+
|--------------|------------|---------------|--------------|
|
|
359
|
+
| Small | < 100 files | < 5s | < 50MB |
|
|
360
|
+
| Medium | 100-1000 files | 5-20s | 50-200MB |
|
|
361
|
+
| Large | 1000-10000 files | 20-60s | 200-500MB |
|
|
362
|
+
| Very Large | > 10000 files | 60-120s | 500MB-1GB |
|
|
363
|
+
|
|
364
|
+
**Optimization Techniques**:
|
|
365
|
+
- Parallel file processing (Worker threads)
|
|
366
|
+
- Incremental analysis (cache previous results)
|
|
367
|
+
- Smart file filtering (skip `node_modules`, etc.)
|
|
368
|
+
- Lazy evaluation (compute metrics on demand)
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
### Memory Optimization
|
|
373
|
+
|
|
374
|
+
1. **Streaming Large Files**
|
|
375
|
+
```typescript
|
|
376
|
+
async function parselargeFile(filePath: string): Promise<AST> {
|
|
377
|
+
const stream = fs.createReadStream(filePath);
|
|
378
|
+
return await parseStream(stream); // Don't load entire file
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
2. **Lazy Graph Construction**
|
|
383
|
+
```typescript
|
|
384
|
+
class LazyProjectGraph {
|
|
385
|
+
private nodeCache = new Map<string, ProjectNode>();
|
|
386
|
+
|
|
387
|
+
getNode(id: string): ProjectNode {
|
|
388
|
+
if (!this.nodeCache.has(id)) {
|
|
389
|
+
this.nodeCache.set(id, this.loadNode(id)); // Load on demand
|
|
390
|
+
}
|
|
391
|
+
return this.nodeCache.get(id)!;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
3. **Garbage Collection Optimization**
|
|
397
|
+
```typescript
|
|
398
|
+
// Clear cache after analysis
|
|
399
|
+
function analyzeAndCleanup(projectPath: string): Analysis {
|
|
400
|
+
const graph = buildGraph(projectPath);
|
|
401
|
+
const analysis = runAnalysis(graph);
|
|
402
|
+
|
|
403
|
+
graph.clear(); // Free memory
|
|
404
|
+
global.gc(); // Hint to GC
|
|
405
|
+
|
|
406
|
+
return analysis;
|
|
407
|
+
}
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
---
|
|
411
|
+
|
|
412
|
+
## Caching Strategy
|
|
413
|
+
|
|
414
|
+
### Three-Level Cache
|
|
415
|
+
|
|
416
|
+
1. **Level 1: In-Memory Cache** (Session lifetime)
|
|
417
|
+
- Parsed ASTs
|
|
418
|
+
- Dependency maps
|
|
419
|
+
- Current analysis results
|
|
420
|
+
|
|
421
|
+
2. **Level 2: Disk Cache** (Project lifetime)
|
|
422
|
+
- File metadata (mtimes, sizes)
|
|
423
|
+
- Dependency graph serialization
|
|
424
|
+
- Previous analysis results
|
|
425
|
+
|
|
426
|
+
3. **Level 3: Global Cache** (Cross-project)
|
|
427
|
+
- npm package metadata
|
|
428
|
+
- Common pattern definitions
|
|
429
|
+
- Shared configurations
|
|
430
|
+
|
|
431
|
+
### Cache Invalidation
|
|
432
|
+
|
|
433
|
+
```typescript
|
|
434
|
+
function shouldInvalidateCache(file: FileInfo, cache: CacheEntry): boolean {
|
|
435
|
+
// File modified
|
|
436
|
+
if (file.mtime > cache.mtime) return true;
|
|
437
|
+
|
|
438
|
+
// Dependencies changed
|
|
439
|
+
if (cache.dependencies.some(dep => hasChanged(dep))) return true;
|
|
440
|
+
|
|
441
|
+
// Analysis version changed
|
|
442
|
+
if (cache.version !== CURRENT_VERSION) return true;
|
|
443
|
+
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
## API Usage Examples
|
|
451
|
+
|
|
452
|
+
### Basic Analysis
|
|
453
|
+
|
|
454
|
+
```typescript
|
|
455
|
+
import { analyzeProject } from 'project-mind';
|
|
456
|
+
|
|
457
|
+
const analysis = await analyzeProject('/path/to/project');
|
|
458
|
+
|
|
459
|
+
console.log(analysis.summary);
|
|
460
|
+
// {
|
|
461
|
+
// type: 'React SPA',
|
|
462
|
+
// fileCount: 450,
|
|
463
|
+
// complexity: 'Medium',
|
|
464
|
+
// technicalDebt: 'Low'
|
|
465
|
+
// }
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Dependency Graph
|
|
469
|
+
|
|
470
|
+
```typescript
|
|
471
|
+
const graph = await buildDependencyGraph('/path/to/project');
|
|
472
|
+
|
|
473
|
+
// Find all files that depend on a module
|
|
474
|
+
const dependents = graph.getDependents('src/utils/api.ts');
|
|
475
|
+
|
|
476
|
+
// Find circular dependencies
|
|
477
|
+
const cycles = graph.findCycles();
|
|
478
|
+
|
|
479
|
+
// Export graph for visualization
|
|
480
|
+
const graphData = graph.exportForVisualization();
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### Pattern Detection
|
|
484
|
+
|
|
485
|
+
```typescript
|
|
486
|
+
const patterns = await detectPatterns('/path/to/project');
|
|
487
|
+
|
|
488
|
+
console.log(patterns.architecture);
|
|
489
|
+
// 'MVC with Service Layer'
|
|
490
|
+
|
|
491
|
+
console.log(patterns.designPatterns);
|
|
492
|
+
// ['Singleton', 'Factory', 'Observer']
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
---
|
|
496
|
+
|
|
497
|
+
## Integration Points
|
|
498
|
+
|
|
499
|
+
### VS Code Extension
|
|
500
|
+
|
|
501
|
+
```typescript
|
|
502
|
+
// Provide IntelliSense based on project graph
|
|
503
|
+
vscode.languages.registerCompletionItemProvider('typescript', {
|
|
504
|
+
provideCompletionItems(document, position) {
|
|
505
|
+
const graph = getProjectGraph(document.uri);
|
|
506
|
+
const availableModules = graph.getAvailableImports(document.uri);
|
|
507
|
+
return availableModules.map(toCompletionItem);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
### CI/CD Pipeline
|
|
513
|
+
|
|
514
|
+
```yaml
|
|
515
|
+
# GitHub Actions
|
|
516
|
+
- name: Analyze Project
|
|
517
|
+
run: project-mind analyze --json > analysis.json
|
|
518
|
+
|
|
519
|
+
- name: Check Technical Debt
|
|
520
|
+
run: |
|
|
521
|
+
if [ $(jq '.technicalDebt.score' analysis.json) -gt 50 ]; then
|
|
522
|
+
echo "Technical debt too high!"
|
|
523
|
+
exit 1
|
|
524
|
+
fi
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
## Future Enhancements
|
|
530
|
+
|
|
531
|
+
1. **Real-time Analysis**: Watch mode for incremental updates
|
|
532
|
+
2. **ML-Based Patterns**: Learn project-specific patterns
|
|
533
|
+
3. **Cross-Project Insights**: Compare with similar projects
|
|
534
|
+
4. **Refactoring Suggestions**: Automated code improvements
|
|
535
|
+
5. **Dependency Upgrade Path**: Safe upgrade recommendations
|