skene 0.3.0__py3-none-any.whl

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.
Files changed (81) hide show
  1. skene/__init__.py +84 -0
  2. skene/analyzers/__init__.py +18 -0
  3. skene/analyzers/docs.py +179 -0
  4. skene/analyzers/growth_features.py +71 -0
  5. skene/analyzers/manifest.py +197 -0
  6. skene/analyzers/prompts.py +351 -0
  7. skene/analyzers/tech_stack.py +92 -0
  8. skene/cli/__init__.py +19 -0
  9. skene/cli/analysis_helpers.py +571 -0
  10. skene/cli/auth.py +123 -0
  11. skene/cli/chat.py +344 -0
  12. skene/cli/config_manager.py +350 -0
  13. skene/cli/features.py +79 -0
  14. skene/cli/main.py +2045 -0
  15. skene/cli/output_writers.py +68 -0
  16. skene/cli/prompt_builder.py +339 -0
  17. skene/cli/sample_report.py +276 -0
  18. skene/codebase/__init__.py +13 -0
  19. skene/codebase/explorer.py +479 -0
  20. skene/codebase/filters.py +42 -0
  21. skene/codebase/tree.py +111 -0
  22. skene/config.py +300 -0
  23. skene/docs/__init__.py +14 -0
  24. skene/docs/generator.py +227 -0
  25. skene/docs/pseo/__init__.py +11 -0
  26. skene/docs/pseo/builder.py +217 -0
  27. skene/docs/templates/analysis.md.j2 +86 -0
  28. skene/docs/templates/growth_template.md.j2 +50 -0
  29. skene/docs/templates/plg_lifecycle_template.md.j2 +65 -0
  30. skene/docs/templates/product_docs.md.j2 +83 -0
  31. skene/docs/templates/seo_page.md.j2 +56 -0
  32. skene/feature_registry.py +443 -0
  33. skene/growth_loops/push.py +252 -0
  34. skene/growth_loops/schema_sql.py +121 -0
  35. skene/growth_loops/storage.py +697 -0
  36. skene/growth_loops/upstream.py +174 -0
  37. skene/llm/__init__.py +13 -0
  38. skene/llm/base.py +61 -0
  39. skene/llm/debug.py +116 -0
  40. skene/llm/factory.py +89 -0
  41. skene/llm/providers/__init__.py +7 -0
  42. skene/llm/providers/anthropic.py +225 -0
  43. skene/llm/providers/gemini.py +286 -0
  44. skene/llm/providers/generic.py +64 -0
  45. skene/llm/providers/lmstudio.py +64 -0
  46. skene/llm/providers/ollama.py +68 -0
  47. skene/llm/providers/openai.py +216 -0
  48. skene/llm/providers/openai_compat.py +125 -0
  49. skene/manifest/__init__.py +30 -0
  50. skene/manifest/schema.py +310 -0
  51. skene/mcp/__init__.py +25 -0
  52. skene/mcp/__main__.py +6 -0
  53. skene/mcp/cache.py +345 -0
  54. skene/mcp/registry.py +466 -0
  55. skene/mcp/server.py +92 -0
  56. skene/mcp/tools.py +1030 -0
  57. skene/objectives/__init__.py +9 -0
  58. skene/objectives/generator.py +224 -0
  59. skene/planner/__init__.py +23 -0
  60. skene/planner/decline.py +70 -0
  61. skene/planner/planner.py +477 -0
  62. skene/planner/schema.py +127 -0
  63. skene/strategies/__init__.py +24 -0
  64. skene/strategies/base.py +115 -0
  65. skene/strategies/context.py +135 -0
  66. skene/strategies/multi_step.py +166 -0
  67. skene/strategies/steps/__init__.py +23 -0
  68. skene/strategies/steps/analyze.py +248 -0
  69. skene/strategies/steps/base.py +53 -0
  70. skene/strategies/steps/generate.py +325 -0
  71. skene/strategies/steps/read_files.py +114 -0
  72. skene/strategies/steps/select_files.py +229 -0
  73. skene/templates/__init__.py +13 -0
  74. skene/templates/growth_template.py +256 -0
  75. skene/validators/__init__.py +23 -0
  76. skene/validators/loop_validator.py +991 -0
  77. skene-0.3.0.dist-info/METADATA +130 -0
  78. skene-0.3.0.dist-info/RECORD +81 -0
  79. skene-0.3.0.dist-info/WHEEL +4 -0
  80. skene-0.3.0.dist-info/entry_points.txt +5 -0
  81. skene-0.3.0.dist-info/licenses/LICENSE +21 -0
skene/__init__.py ADDED
@@ -0,0 +1,84 @@
1
+ """
2
+ skene: PLG analysis toolkit for codebases.
3
+
4
+ This library provides tools for analyzing codebases, detecting growth opportunities,
5
+ and generating documentation.
6
+ """
7
+
8
+ from skene.analyzers import (
9
+ GrowthFeaturesAnalyzer,
10
+ ManifestAnalyzer,
11
+ TechStackAnalyzer,
12
+ )
13
+ from skene.codebase import (
14
+ DEFAULT_EXCLUDE_FOLDERS,
15
+ CodebaseExplorer,
16
+ build_directory_tree,
17
+ )
18
+ from skene.config import Config, load_config
19
+ from skene.docs import DocsGenerator, PSEOBuilder
20
+ from skene.llm import LLMClient, create_llm_client
21
+ from skene.manifest import (
22
+ GrowthFeature,
23
+ GrowthManifest,
24
+ GrowthOpportunity,
25
+ TechStack,
26
+ )
27
+ from skene.planner import (
28
+ Planner,
29
+ )
30
+ from skene.strategies import (
31
+ AnalysisContext,
32
+ AnalysisMetadata,
33
+ AnalysisResult,
34
+ AnalysisStrategy,
35
+ MultiStepStrategy,
36
+ )
37
+ from skene.strategies.steps import (
38
+ AnalysisStep,
39
+ AnalyzeStep,
40
+ GenerateStep,
41
+ ReadFilesStep,
42
+ SelectFilesStep,
43
+ )
44
+
45
+ __version__ = "0.3.0"
46
+
47
+ __all__ = [
48
+ # Analyzers
49
+ "TechStackAnalyzer",
50
+ "GrowthFeaturesAnalyzer",
51
+ "ManifestAnalyzer",
52
+ # Manifest schemas
53
+ "TechStack",
54
+ "GrowthFeature",
55
+ "GrowthOpportunity",
56
+ "GrowthManifest",
57
+ # Codebase
58
+ "CodebaseExplorer",
59
+ "build_directory_tree",
60
+ "DEFAULT_EXCLUDE_FOLDERS",
61
+ # Config
62
+ "Config",
63
+ "load_config",
64
+ # LLM
65
+ "LLMClient",
66
+ "create_llm_client",
67
+ # Strategies
68
+ "AnalysisStrategy",
69
+ "AnalysisResult",
70
+ "AnalysisMetadata",
71
+ "AnalysisContext",
72
+ "MultiStepStrategy",
73
+ # Steps
74
+ "AnalysisStep",
75
+ "SelectFilesStep",
76
+ "ReadFilesStep",
77
+ "AnalyzeStep",
78
+ "GenerateStep",
79
+ # Documentation
80
+ "DocsGenerator",
81
+ "PSEOBuilder",
82
+ # Planner
83
+ "Planner",
84
+ ]
@@ -0,0 +1,18 @@
1
+ """
2
+ Analyzers for PLG (Product-Led Growth) analysis.
3
+
4
+ Each analyzer uses the MultiStepStrategy pattern to perform
5
+ a specific type of analysis on a codebase.
6
+ """
7
+
8
+ from skene.analyzers.docs import DocsAnalyzer
9
+ from skene.analyzers.growth_features import GrowthFeaturesAnalyzer
10
+ from skene.analyzers.manifest import ManifestAnalyzer
11
+ from skene.analyzers.tech_stack import TechStackAnalyzer
12
+
13
+ __all__ = [
14
+ "TechStackAnalyzer",
15
+ "GrowthFeaturesAnalyzer",
16
+ "ManifestAnalyzer",
17
+ "DocsAnalyzer",
18
+ ]
@@ -0,0 +1,179 @@
1
+ """
2
+ Documentation-focused analyzer using MultiStepStrategy.
3
+
4
+ Extends growth manifest analysis to include real product documentation
5
+ fields like product_overview and features.
6
+ """
7
+
8
+ from typing import Any
9
+
10
+ from skene.analyzers.prompts import (
11
+ FEATURES_PROMPT,
12
+ INDUSTRY_PROMPT,
13
+ PRODUCT_OVERVIEW_PROMPT,
14
+ TECH_STACK_PROMPT,
15
+ build_docs_manifest_prompt,
16
+ build_growth_features_prompt,
17
+ )
18
+ from skene.manifest import (
19
+ DocsManifest,
20
+ IndustryInfo,
21
+ ProductOverview,
22
+ TechStack,
23
+ )
24
+ from skene.strategies import MultiStepStrategy
25
+ from skene.strategies.steps import (
26
+ AnalyzeStep,
27
+ GenerateStep,
28
+ ReadFilesStep,
29
+ SelectFilesStep,
30
+ )
31
+
32
+
33
+ class DocsAnalyzer(MultiStepStrategy):
34
+ """
35
+ Documentation analyzer that produces a DocsManifest.
36
+
37
+ This analyzer extends the base growth manifest with documentation
38
+ fields by running in 5 phases:
39
+
40
+ 1. Tech stack detection (config files)
41
+ 2. Product overview extraction (README, docs)
42
+ 3. Industry classification (reuses docs from phase 2)
43
+ 4. Feature documentation + current growth features (source files)
44
+ 5. Final manifest generation
45
+
46
+ Example:
47
+ analyzer = DocsAnalyzer()
48
+ result = await analyzer.run(
49
+ codebase=CodebaseExplorer("/path/to/repo"),
50
+ llm=create_llm_client(),
51
+ request="Generate documentation for this project",
52
+ )
53
+ manifest = DocsManifest.model_validate(result.data.get("output"))
54
+ """
55
+
56
+ def __init__(self, existing_growth_loops: list[dict[str, Any]] | None = None):
57
+ """Initialize the docs analyzer with all analysis steps."""
58
+ self.existing_growth_loops = existing_growth_loops or []
59
+
60
+ # Format existing loops for prompt inclusion
61
+ from skene.growth_loops.storage import format_growth_loops_summary
62
+
63
+ loops_summary = format_growth_loops_summary(self.existing_growth_loops)
64
+
65
+ # Build prompts with existing loops context
66
+ growth_features_prompt = build_growth_features_prompt(loops_summary)
67
+ docs_manifest_prompt = build_docs_manifest_prompt(loops_summary)
68
+
69
+ super().__init__(
70
+ steps=[
71
+ # Phase 1: Tech Stack Detection
72
+ SelectFilesStep(
73
+ prompt="Select configuration files for tech stack detection. "
74
+ "Include package managers, framework configs, and dependency files.",
75
+ patterns=[
76
+ "package.json",
77
+ "requirements.txt",
78
+ "pyproject.toml",
79
+ "Cargo.toml",
80
+ "go.mod",
81
+ "Gemfile",
82
+ "*.config.js",
83
+ "*.config.ts",
84
+ "tsconfig.json",
85
+ "docker-compose.yml",
86
+ "Dockerfile",
87
+ ],
88
+ max_files=10,
89
+ output_key="config_files",
90
+ ),
91
+ ReadFilesStep(
92
+ source_key="config_files",
93
+ output_key="config_contents",
94
+ ),
95
+ AnalyzeStep(
96
+ prompt=TECH_STACK_PROMPT,
97
+ output_schema=TechStack,
98
+ output_key="tech_stack",
99
+ source_key="config_contents",
100
+ ),
101
+ # Phase 2: Product Overview Extraction
102
+ SelectFilesStep(
103
+ prompt="Select documentation files for product overview. "
104
+ "Look for README, docs, and package descriptions.",
105
+ patterns=[
106
+ "README.md",
107
+ "README*.md",
108
+ "readme.md",
109
+ "docs/*.md",
110
+ "docs/**/*.md",
111
+ "package.json",
112
+ "pyproject.toml",
113
+ "Cargo.toml",
114
+ ],
115
+ max_files=8,
116
+ output_key="overview_files",
117
+ ),
118
+ ReadFilesStep(
119
+ source_key="overview_files",
120
+ output_key="overview_contents",
121
+ ),
122
+ AnalyzeStep(
123
+ prompt=PRODUCT_OVERVIEW_PROMPT,
124
+ output_schema=ProductOverview,
125
+ output_key="product_overview",
126
+ source_key="overview_contents",
127
+ ),
128
+ # Phase 3: Industry Classification (reuses overview_contents)
129
+ AnalyzeStep(
130
+ prompt=INDUSTRY_PROMPT,
131
+ output_schema=IndustryInfo,
132
+ output_key="industry",
133
+ source_key="overview_contents",
134
+ ),
135
+ # Phase 4: Feature Documentation + Current Growth Features
136
+ SelectFilesStep(
137
+ prompt="Select source files with growth features. "
138
+ "Look for user management, invitations, sharing, payments, analytics.",
139
+ patterns=[
140
+ "**/*.py",
141
+ "**/*.ts",
142
+ "**/*.tsx",
143
+ "**/*.js",
144
+ "**/routes/**/*",
145
+ "**/api/**/*",
146
+ "**/features/**/*",
147
+ ],
148
+ max_files=30,
149
+ output_key="source_files",
150
+ ),
151
+ ReadFilesStep(
152
+ source_key="source_files",
153
+ output_key="source_contents",
154
+ ),
155
+ AnalyzeStep(
156
+ prompt=FEATURES_PROMPT,
157
+ output_key="features",
158
+ source_key="source_contents",
159
+ ),
160
+ AnalyzeStep(
161
+ prompt=growth_features_prompt,
162
+ output_key="current_growth_features",
163
+ source_key="source_contents",
164
+ ),
165
+ # Phase 5: Final Manifest Generation
166
+ GenerateStep(
167
+ prompt=docs_manifest_prompt,
168
+ output_schema=DocsManifest,
169
+ include_context_keys=[
170
+ "tech_stack",
171
+ "product_overview",
172
+ "industry",
173
+ "features",
174
+ "current_growth_features",
175
+ ],
176
+ output_key="output",
177
+ ),
178
+ ]
179
+ )
@@ -0,0 +1,71 @@
1
+ """
2
+ Growth features analyzer using MultiStepStrategy.
3
+
4
+ Identifies current features and areas of a codebase with growth potential.
5
+ """
6
+
7
+ from skene.analyzers.prompts import GROWTH_FEATURES_PROMPT
8
+ from skene.strategies import MultiStepStrategy
9
+ from skene.strategies.steps import (
10
+ AnalyzeStep,
11
+ ReadFilesStep,
12
+ SelectFilesStep,
13
+ )
14
+
15
+
16
+ class GrowthFeaturesAnalyzer(MultiStepStrategy):
17
+ """
18
+ Analyzer for identifying current growth features in a codebase.
19
+
20
+ Current growth features are features or areas that:
21
+ - Enable viral growth (sharing, invitations, referrals)
22
+ - Drive user engagement
23
+ - Facilitate onboarding
24
+ - Support monetization
25
+ - Enable data-driven decisions
26
+
27
+ Example:
28
+ analyzer = GrowthFeaturesAnalyzer()
29
+ result = await analyzer.run(
30
+ codebase=CodebaseExplorer("/path/to/repo"),
31
+ llm=create_llm_client(),
32
+ request="Find growth opportunities",
33
+ )
34
+ features = result.data.get("current_growth_features", [])
35
+ """
36
+
37
+ def __init__(self):
38
+ """Initialize the growth features analyzer with predefined steps."""
39
+ super().__init__(
40
+ steps=[
41
+ SelectFilesStep(
42
+ prompt="Select source files that might contain growth-related features. "
43
+ "Look for: user management, invitations, sharing, payments, "
44
+ "analytics, onboarding, notifications, and engagement features.",
45
+ patterns=[
46
+ "**/*.py",
47
+ "**/*.ts",
48
+ "**/*.tsx",
49
+ "**/*.js",
50
+ "**/*.jsx",
51
+ "**/routes/**/*",
52
+ "**/api/**/*",
53
+ "**/features/**/*",
54
+ "**/components/**/*",
55
+ "**/pages/**/*",
56
+ "**/app/**/*",
57
+ ],
58
+ max_files=30,
59
+ output_key="selected_files",
60
+ ),
61
+ ReadFilesStep(
62
+ source_key="selected_files",
63
+ output_key="file_contents",
64
+ ),
65
+ AnalyzeStep(
66
+ prompt=GROWTH_FEATURES_PROMPT,
67
+ output_key="current_growth_features",
68
+ source_key="file_contents",
69
+ ),
70
+ ]
71
+ )
@@ -0,0 +1,197 @@
1
+ """
2
+ Full manifest analyzer using MultiStepStrategy.
3
+
4
+ Combines tech stack and growth features analysis to produce
5
+ a complete GrowthManifest.
6
+ """
7
+
8
+ from typing import Any
9
+
10
+ from skene.analyzers.prompts import (
11
+ INDUSTRY_PROMPT,
12
+ REVENUE_LEAKAGE_PROMPT,
13
+ TECH_STACK_PROMPT,
14
+ build_growth_features_prompt,
15
+ build_manifest_prompt,
16
+ )
17
+ from skene.manifest import GrowthManifest, IndustryInfo, TechStack
18
+ from skene.strategies import MultiStepStrategy
19
+ from skene.strategies.steps import (
20
+ AnalyzeStep,
21
+ GenerateStep,
22
+ ReadFilesStep,
23
+ SelectFilesStep,
24
+ )
25
+
26
+
27
+ class ManifestAnalyzer(MultiStepStrategy):
28
+ """
29
+ Full-pipeline analyzer that produces a complete GrowthManifest.
30
+
31
+ This analyzer runs in four phases:
32
+ 1. Tech stack detection (config files)
33
+ 2. Current growth features identification (source files)
34
+ 3. Revenue leakage analysis (pricing/payment files)
35
+ 4. Industry classification (docs/README)
36
+ 5. Manifest generation (combining results + growth opportunities)
37
+
38
+ Example:
39
+ analyzer = ManifestAnalyzer()
40
+ result = await analyzer.run(
41
+ codebase=CodebaseExplorer("/path/to/repo"),
42
+ llm=create_llm_client(),
43
+ request="Generate a growth manifest for this project",
44
+ )
45
+ manifest = GrowthManifest.model_validate(result.data.get("output"))
46
+ """
47
+
48
+ def __init__(self, existing_growth_loops: list[dict[str, Any]] | None = None):
49
+ """Initialize the manifest analyzer with all analysis steps."""
50
+ self.existing_growth_loops = existing_growth_loops or []
51
+
52
+ # Format existing loops for prompt inclusion
53
+ from skene.growth_loops.storage import format_growth_loops_summary
54
+
55
+ loops_summary = format_growth_loops_summary(self.existing_growth_loops)
56
+
57
+ # Build prompts with existing loops context
58
+ growth_features_prompt = build_growth_features_prompt(loops_summary)
59
+ manifest_prompt = build_manifest_prompt(loops_summary)
60
+
61
+ super().__init__(
62
+ steps=[
63
+ # Phase 1: Detect tech stack
64
+ SelectFilesStep(
65
+ prompt="Select configuration files and representative source files for tech stack detection. "
66
+ "Include package managers, framework configs, dependency files, "
67
+ "and a few source files to identify the language.",
68
+ patterns=[
69
+ "package.json",
70
+ "requirements.txt",
71
+ "pyproject.toml",
72
+ "Cargo.toml",
73
+ "go.mod",
74
+ "Gemfile",
75
+ "*.config.js",
76
+ "*.config.ts",
77
+ "tsconfig.json",
78
+ "docker-compose.yml",
79
+ "Dockerfile",
80
+ # Include source files to help identify language
81
+ "**/*.py",
82
+ "**/*.js",
83
+ "**/*.ts",
84
+ "**/*.tsx",
85
+ "**/*.go",
86
+ "**/*.rs",
87
+ "**/*.rb",
88
+ ],
89
+ max_files=15,
90
+ output_key="config_files",
91
+ ),
92
+ ReadFilesStep(
93
+ source_key="config_files",
94
+ output_key="file_contents",
95
+ ),
96
+ AnalyzeStep(
97
+ prompt=TECH_STACK_PROMPT,
98
+ output_schema=TechStack,
99
+ output_key="tech_stack",
100
+ source_key="file_contents",
101
+ ),
102
+ # Phase 2: Find current growth features
103
+ # Note: file_contents will be overwritten, but tech_stack is preserved
104
+ SelectFilesStep(
105
+ prompt="Select source files with potential growth features. "
106
+ "Look for user management, invitations, sharing, payments, "
107
+ "analytics, onboarding, and engagement features.",
108
+ patterns=[
109
+ "**/*.py",
110
+ "**/*.ts",
111
+ "**/*.tsx",
112
+ "**/*.js",
113
+ "**/routes/**/*",
114
+ "**/api/**/*",
115
+ "**/features/**/*",
116
+ ],
117
+ max_files=30,
118
+ output_key="source_files",
119
+ ),
120
+ ReadFilesStep(
121
+ source_key="source_files",
122
+ output_key="file_contents",
123
+ ),
124
+ AnalyzeStep(
125
+ prompt=growth_features_prompt,
126
+ output_key="current_growth_features",
127
+ source_key="file_contents",
128
+ ),
129
+ # Phase 2.5: Analyze revenue leakage
130
+ SelectFilesStep(
131
+ prompt="Select files related to pricing, payments, subscriptions, billing, "
132
+ "usage limits, feature flags, tier management, and monetization. "
133
+ "Look for payment processing, subscription logic, free tier restrictions, "
134
+ "upgrade prompts, and pricing configurations.",
135
+ patterns=[
136
+ "**/pricing/**/*",
137
+ "**/payment/**/*",
138
+ "**/billing/**/*",
139
+ "**/subscription/**/*",
140
+ "**/plan/**/*",
141
+ "**/tier/**/*",
142
+ "**/usage/**/*",
143
+ "**/limit/**/*",
144
+ "**/upgrade/**/*",
145
+ "**/monetization/**/*",
146
+ "**/stripe/**/*",
147
+ "**/paypal/**/*",
148
+ ],
149
+ max_files=20,
150
+ output_key="revenue_files",
151
+ ),
152
+ ReadFilesStep(
153
+ source_key="revenue_files",
154
+ output_key="revenue_file_contents",
155
+ ),
156
+ AnalyzeStep(
157
+ prompt=REVENUE_LEAKAGE_PROMPT,
158
+ output_key="revenue_leakage",
159
+ source_key="revenue_file_contents",
160
+ ),
161
+ # Phase 3: Industry classification
162
+ SelectFilesStep(
163
+ prompt="Select documentation and package metadata files for industry classification. "
164
+ "Look for README, docs, and package descriptors that describe what the product does.",
165
+ patterns=[
166
+ "README.md",
167
+ "README*.md",
168
+ "readme.md",
169
+ "docs/*.md",
170
+ "docs/**/*.md",
171
+ "package.json",
172
+ "pyproject.toml",
173
+ "Cargo.toml",
174
+ "go.mod",
175
+ ],
176
+ max_files=10,
177
+ output_key="industry_files",
178
+ ),
179
+ ReadFilesStep(
180
+ source_key="industry_files",
181
+ output_key="industry_file_contents",
182
+ ),
183
+ AnalyzeStep(
184
+ prompt=INDUSTRY_PROMPT,
185
+ output_schema=IndustryInfo,
186
+ output_key="industry",
187
+ source_key="industry_file_contents",
188
+ ),
189
+ # Phase 4: Generate final manifest
190
+ GenerateStep(
191
+ prompt=manifest_prompt,
192
+ output_schema=GrowthManifest,
193
+ include_context_keys=["tech_stack", "current_growth_features", "revenue_leakage", "industry"],
194
+ output_key="output",
195
+ ),
196
+ ]
197
+ )