opencode-usage-v2 0.2.5__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.
- opencode_usage/__init__.py +18 -0
- opencode_usage/__main__.py +5 -0
- opencode_usage/_opencode_cli.py +158 -0
- opencode_usage/auth.py +82 -0
- opencode_usage/cli.py +271 -0
- opencode_usage/db.py +712 -0
- opencode_usage/insights/__init__.py +19 -0
- opencode_usage/insights/analyze.py +384 -0
- opencode_usage/insights/cache.py +60 -0
- opencode_usage/insights/extract.py +600 -0
- opencode_usage/insights/orchestrator.py +159 -0
- opencode_usage/insights/prompts.py +306 -0
- opencode_usage/insights/report.py +574 -0
- opencode_usage/insights/types.py +75 -0
- opencode_usage/llm.py +93 -0
- opencode_usage/models.py +145 -0
- opencode_usage/render.py +240 -0
- opencode_usage_v2-0.2.5.dist-info/METADATA +217 -0
- opencode_usage_v2-0.2.5.dist-info/RECORD +22 -0
- opencode_usage_v2-0.2.5.dist-info/WHEEL +4 -0
- opencode_usage_v2-0.2.5.dist-info/entry_points.txt +3 -0
- opencode_usage_v2-0.2.5.dist-info/licenses/LICENSE +22 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"""Orchestrate the full insights pipeline: extract → analyze → report."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import sys
|
|
6
|
+
import warnings
|
|
7
|
+
from datetime import datetime, timedelta
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import TYPE_CHECKING, Any
|
|
10
|
+
|
|
11
|
+
from rich.console import Console
|
|
12
|
+
from rich.progress import Progress, SpinnerColumn, TextColumn
|
|
13
|
+
|
|
14
|
+
from .._opencode_cli import get_db_path
|
|
15
|
+
from .analyze import extract_facets, generate_at_a_glance, run_aggregate_analysis
|
|
16
|
+
from .cache import FacetCache
|
|
17
|
+
from .extract import aggregate_all, filter_sessions
|
|
18
|
+
from .report import generate_report
|
|
19
|
+
from .types import InsightsConfig
|
|
20
|
+
|
|
21
|
+
if TYPE_CHECKING:
|
|
22
|
+
import argparse
|
|
23
|
+
|
|
24
|
+
from .types import SessionFacet
|
|
25
|
+
|
|
26
|
+
console = Console()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def run_insights(args: argparse.Namespace) -> None:
|
|
30
|
+
"""Orchestrate the full insights pipeline: extract → analyze → report."""
|
|
31
|
+
# Build config from args
|
|
32
|
+
config = InsightsConfig(
|
|
33
|
+
model=args.model,
|
|
34
|
+
days=getattr(args, "days", None),
|
|
35
|
+
since=getattr(args, "since", None),
|
|
36
|
+
force=getattr(args, "force", False),
|
|
37
|
+
output_path=getattr(args, "output", "./opencode-insights.html"),
|
|
38
|
+
concurrency=getattr(args, "concurrency", None),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
db_path = getattr(args, "db", None) or _default_db_path()
|
|
42
|
+
|
|
43
|
+
# Resolve time range
|
|
44
|
+
since_dt = _resolve_since(config)
|
|
45
|
+
|
|
46
|
+
console.print("[cyan]▸ OpenCode Insights[/cyan]")
|
|
47
|
+
console.print(f" Model: [dim]{config.model}[/dim]")
|
|
48
|
+
console.print(f" Output: [dim]{config.output_path}[/dim]")
|
|
49
|
+
console.print()
|
|
50
|
+
|
|
51
|
+
# Phase 1: Extract data
|
|
52
|
+
with Progress(
|
|
53
|
+
SpinnerColumn(),
|
|
54
|
+
TextColumn("[progress.description]{task.description}"),
|
|
55
|
+
console=console,
|
|
56
|
+
) as progress:
|
|
57
|
+
task = progress.add_task("Extracting session data...", total=None)
|
|
58
|
+
try:
|
|
59
|
+
session_ids = filter_sessions(db_path, since=since_dt)
|
|
60
|
+
stats = aggregate_all(db_path, session_ids, since=since_dt)
|
|
61
|
+
except FileNotFoundError as e:
|
|
62
|
+
console.print(f"[red]Error:[/red] {e}")
|
|
63
|
+
sys.exit(1)
|
|
64
|
+
progress.update(task, description=f"Found {len(session_ids)} sessions")
|
|
65
|
+
|
|
66
|
+
console.print(f" Sessions: [green]{len(session_ids)}[/green]")
|
|
67
|
+
|
|
68
|
+
# Phase 2: LLM analysis
|
|
69
|
+
cache = FacetCache()
|
|
70
|
+
if config.force:
|
|
71
|
+
cache.clear()
|
|
72
|
+
|
|
73
|
+
facets: dict[str, SessionFacet] = {}
|
|
74
|
+
aggregate_results: dict[str, dict[str, Any]] = {}
|
|
75
|
+
at_a_glance: dict[str, Any] = {}
|
|
76
|
+
llm_available = True
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
with Progress(
|
|
80
|
+
SpinnerColumn(),
|
|
81
|
+
TextColumn("[progress.description]{task.description}"),
|
|
82
|
+
console=console,
|
|
83
|
+
) as progress:
|
|
84
|
+
task = progress.add_task(
|
|
85
|
+
f"Analyzing sessions (0/{len(session_ids)})...", total=len(session_ids)
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
def on_progress(current: int, total: int) -> None:
|
|
89
|
+
progress.update(
|
|
90
|
+
task,
|
|
91
|
+
completed=current,
|
|
92
|
+
description=f"Analyzing sessions ({current}/{total})...",
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
facets = extract_facets(
|
|
96
|
+
db_path, session_ids, config, cache=cache, on_progress=on_progress
|
|
97
|
+
)
|
|
98
|
+
progress.update(task, description="Running aggregate analysis...")
|
|
99
|
+
aggregate_results = run_aggregate_analysis(facets, stats, config)
|
|
100
|
+
progress.update(task, description="Generating summary...")
|
|
101
|
+
at_a_glance = generate_at_a_glance(aggregate_results, stats, config)
|
|
102
|
+
|
|
103
|
+
except FileNotFoundError:
|
|
104
|
+
llm_available = False
|
|
105
|
+
console.print(
|
|
106
|
+
"[yellow]Warning:[/yellow] opencode not found — generating data-only report "
|
|
107
|
+
"(install opencode for full analysis)"
|
|
108
|
+
)
|
|
109
|
+
except Exception as e:
|
|
110
|
+
llm_available = False
|
|
111
|
+
warnings.warn(f"LLM analysis failed: {e}", stacklevel=2)
|
|
112
|
+
console.print(f"[yellow]Warning:[/yellow] LLM analysis failed: {e}")
|
|
113
|
+
console.print("Generating data-only report.")
|
|
114
|
+
|
|
115
|
+
# Phase 3: Generate report
|
|
116
|
+
insights_data = {
|
|
117
|
+
"at_a_glance": at_a_glance,
|
|
118
|
+
"project_areas": aggregate_results.get("project_areas", {}),
|
|
119
|
+
"interaction_style": aggregate_results.get("interaction_style", {}),
|
|
120
|
+
"agent_performance": aggregate_results.get("agent_performance", {}),
|
|
121
|
+
"friction": aggregate_results.get("friction", {}),
|
|
122
|
+
"suggestions": aggregate_results.get("suggestions", {}),
|
|
123
|
+
"tool_health": aggregate_results.get("tool_health", {}),
|
|
124
|
+
"horizon": aggregate_results.get("horizon", {}),
|
|
125
|
+
"aggregated_stats": stats,
|
|
126
|
+
"delegation_stats": {
|
|
127
|
+
"root_sessions": stats.total_sessions,
|
|
128
|
+
"sub_sessions": sum(stats.top_agents[i][1] for i in range(len(stats.top_agents))),
|
|
129
|
+
"sub_types": dict(stats.top_agents),
|
|
130
|
+
"max_depth": 0,
|
|
131
|
+
"avg_depth": 0.0,
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
html = generate_report(insights_data)
|
|
136
|
+
|
|
137
|
+
output_path = Path(config.output_path)
|
|
138
|
+
output_path.write_text(html, encoding="utf-8")
|
|
139
|
+
|
|
140
|
+
console.print()
|
|
141
|
+
console.print(f"[green]✓[/green] Report saved to [bold]{output_path}[/bold]")
|
|
142
|
+
console.print(f" Sessions analyzed: [green]{len(facets)}[/green] / {len(session_ids)}")
|
|
143
|
+
if not llm_available:
|
|
144
|
+
console.print(" [dim]LLM sections: not available (data-only mode)[/dim]")
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _default_db_path() -> str:
|
|
148
|
+
"""Return the default OpenCode database path."""
|
|
149
|
+
return str(get_db_path())
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def _resolve_since(config: InsightsConfig) -> datetime | None:
|
|
153
|
+
"""Resolve the effective since datetime from config."""
|
|
154
|
+
if config.since is not None:
|
|
155
|
+
return config.since
|
|
156
|
+
if config.days is not None:
|
|
157
|
+
return datetime.now().astimezone() - timedelta(days=config.days)
|
|
158
|
+
# Default: last 30 days
|
|
159
|
+
return datetime.now().astimezone() - timedelta(days=30)
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"""Prompt builders for the OpenCode insights analysis pipeline."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
_JSON_SUFFIX = "RESPOND WITH ONLY A VALID JSON OBJECT. No markdown, no explanation, no code fences."
|
|
9
|
+
|
|
10
|
+
_GOAL_CATEGORIES = (
|
|
11
|
+
"debug_investigate",
|
|
12
|
+
"implement_feature",
|
|
13
|
+
"fix_bug",
|
|
14
|
+
"write_script_tool",
|
|
15
|
+
"refactor_code",
|
|
16
|
+
"configure_system",
|
|
17
|
+
"create_pr_commit",
|
|
18
|
+
"analyze_data",
|
|
19
|
+
"understand_codebase",
|
|
20
|
+
"write_tests",
|
|
21
|
+
"write_docs",
|
|
22
|
+
"deploy_infra",
|
|
23
|
+
"warmup_minimal",
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def build_facet_prompt(transcript: str, meta_summary: str) -> str:
|
|
28
|
+
"""Build prompt to extract structured facet data from a session transcript."""
|
|
29
|
+
categories_str = ", ".join(_GOAL_CATEGORIES)
|
|
30
|
+
return f"""\
|
|
31
|
+
You are analyzing an OpenCode session transcript. OpenCode is an AI-powered CLI \
|
|
32
|
+
tool where users interact with agents (build, explore, librarian, oracle) that use \
|
|
33
|
+
tools, skills, and project-specific AGENTS.md rules to complete tasks.
|
|
34
|
+
|
|
35
|
+
Given the transcript and session metadata below, extract structured information \
|
|
36
|
+
about this session.
|
|
37
|
+
|
|
38
|
+
## Session Metadata
|
|
39
|
+
{meta_summary}
|
|
40
|
+
|
|
41
|
+
## Session Transcript
|
|
42
|
+
{transcript}
|
|
43
|
+
|
|
44
|
+
## Instructions
|
|
45
|
+
|
|
46
|
+
Analyze the transcript and return a JSON object with these fields:
|
|
47
|
+
|
|
48
|
+
- "underlying_goal": string — what the user was trying to accomplish
|
|
49
|
+
- "goal_categories": object mapping each category to 0 or 1 indicating relevance. \
|
|
50
|
+
Categories: {categories_str}
|
|
51
|
+
- "outcome": one of "fully_achieved", "mostly_achieved", "partially_achieved", \
|
|
52
|
+
"not_achieved", "unclear"
|
|
53
|
+
- "satisfaction": object with keys "frustrated", "dissatisfied", "likely_satisfied", \
|
|
54
|
+
"satisfied", "happy" each mapped to 0 or 1 (exactly one should be 1)
|
|
55
|
+
- "helpfulness": one of "unhelpful", "slightly_helpful", "moderately_helpful", \
|
|
56
|
+
"very_helpful", "essential"
|
|
57
|
+
- "session_type": one of "single_task", "multi_task", "iterative_refinement", \
|
|
58
|
+
"exploration", "quick_question"
|
|
59
|
+
- "friction_counts": object with keys "tool_failed", "misunderstood_intent", \
|
|
60
|
+
"repeated_corrections", "context_lost", "wrong_approach" each mapped to a count (integer)
|
|
61
|
+
- "friction_detail": string — brief description of the main friction point, if any
|
|
62
|
+
- "primary_success": one of "none", "fast_accurate_search", "correct_code_edits", \
|
|
63
|
+
"good_explanations", "proactive_help", "multi_file_changes", "good_debugging"
|
|
64
|
+
- "brief_summary": string — 1-2 sentence summary of what happened in this session
|
|
65
|
+
|
|
66
|
+
{_JSON_SUFFIX}"""
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def build_project_areas_prompt(data: dict[str, Any]) -> str:
|
|
70
|
+
"""Build prompt to identify project areas from session summaries."""
|
|
71
|
+
data_str = json.dumps(data, indent=2, ensure_ascii=False)
|
|
72
|
+
return f"""\
|
|
73
|
+
You are analyzing OpenCode session data to identify the main areas of a project \
|
|
74
|
+
that the user works on. Sessions involve interactions with agents (build, explore, \
|
|
75
|
+
librarian, oracle) using tools, skills, and AGENTS.md project rules.
|
|
76
|
+
|
|
77
|
+
## Session Data
|
|
78
|
+
{data_str}
|
|
79
|
+
|
|
80
|
+
## Instructions
|
|
81
|
+
|
|
82
|
+
Identify 4-5 distinct project areas based on the session summaries. For each area, \
|
|
83
|
+
provide a name, how many sessions relate to it, a description, and typical tasks \
|
|
84
|
+
performed in that area.
|
|
85
|
+
|
|
86
|
+
Return a JSON object:
|
|
87
|
+
{{
|
|
88
|
+
"areas": [
|
|
89
|
+
{{"name": "string", "session_count": 5, "description": "string", "typical_tasks": ["string"]}}
|
|
90
|
+
]
|
|
91
|
+
}}
|
|
92
|
+
|
|
93
|
+
{_JSON_SUFFIX}"""
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def build_interaction_style_prompt(data: dict[str, Any]) -> str:
|
|
97
|
+
"""Build prompt to describe the user's interaction style."""
|
|
98
|
+
data_str = json.dumps(data, indent=2, ensure_ascii=False)
|
|
99
|
+
return f"""\
|
|
100
|
+
You are analyzing OpenCode usage patterns to describe how a user interacts with \
|
|
101
|
+
their AI-powered development environment. Consider how they use agents, tools, \
|
|
102
|
+
sessions, and skills.
|
|
103
|
+
|
|
104
|
+
## Usage Pattern Data
|
|
105
|
+
{data_str}
|
|
106
|
+
|
|
107
|
+
## Instructions
|
|
108
|
+
|
|
109
|
+
Describe the user's interaction style based on their usage patterns. Focus on \
|
|
110
|
+
observable behaviors: how they structure sessions, which agents they prefer, \
|
|
111
|
+
how they handle friction, and what kinds of tasks they delegate.
|
|
112
|
+
|
|
113
|
+
Return a JSON object:
|
|
114
|
+
{{
|
|
115
|
+
"narrative": "string — 2-3 sentence description of your interaction style",
|
|
116
|
+
"key_patterns": ["string — specific observable pattern"],
|
|
117
|
+
"strengths": ["string"],
|
|
118
|
+
"growth_areas": ["string"]
|
|
119
|
+
}}
|
|
120
|
+
|
|
121
|
+
{_JSON_SUFFIX}"""
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def build_agent_performance_prompt(data: dict[str, Any]) -> str:
|
|
125
|
+
"""Build prompt to analyze agent usage, costs, and efficiency."""
|
|
126
|
+
data_str = json.dumps(data, indent=2, ensure_ascii=False)
|
|
127
|
+
return f"""\
|
|
128
|
+
You are analyzing OpenCode agent performance data. Agents include build (primary \
|
|
129
|
+
coder), explore (research/search), librarian (documentation), and oracle \
|
|
130
|
+
(architecture/planning). Each agent can use different models, tools, and skills.
|
|
131
|
+
|
|
132
|
+
## Agent Performance Data
|
|
133
|
+
{data_str}
|
|
134
|
+
|
|
135
|
+
## Instructions
|
|
136
|
+
|
|
137
|
+
Analyze the agent usage patterns, costs, and efficiency. Identify which agents \
|
|
138
|
+
perform best, where costs concentrate, which model pairings work well for which \
|
|
139
|
+
task types, and where there are opportunities to improve efficiency.
|
|
140
|
+
|
|
141
|
+
Return a JSON object:
|
|
142
|
+
{{
|
|
143
|
+
"top_performers": [{{"agent": "string", "strength": "string", "usage_pattern": "string"}}],
|
|
144
|
+
"cost_insights": ["string — specific cost observation"],
|
|
145
|
+
"model_pairing_tips": ["string — which model works best for which task type"],
|
|
146
|
+
"efficiency_opportunities": ["string"]
|
|
147
|
+
}}
|
|
148
|
+
|
|
149
|
+
{_JSON_SUFFIX}"""
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def build_friction_prompt(data: dict[str, Any]) -> str:
|
|
153
|
+
"""Build prompt to analyze friction patterns across sessions."""
|
|
154
|
+
data_str = json.dumps(data, indent=2, ensure_ascii=False)
|
|
155
|
+
return f"""\
|
|
156
|
+
You are analyzing friction patterns from OpenCode sessions. Friction includes \
|
|
157
|
+
tool failures, misunderstood intent, repeated corrections, lost context, and \
|
|
158
|
+
wrong approaches taken by agents.
|
|
159
|
+
|
|
160
|
+
## Friction Data
|
|
161
|
+
{data_str}
|
|
162
|
+
|
|
163
|
+
## Instructions
|
|
164
|
+
|
|
165
|
+
Analyze the friction patterns across sessions. Identify the most common friction \
|
|
166
|
+
categories, their root causes, and quick actionable fixes the user can apply.
|
|
167
|
+
|
|
168
|
+
Return a JSON object:
|
|
169
|
+
{{
|
|
170
|
+
"top_friction_categories": [
|
|
171
|
+
{{"category": "string", "frequency": "high|medium|low", "description": "string", \
|
|
172
|
+
"examples": ["string"]}}
|
|
173
|
+
],
|
|
174
|
+
"root_causes": ["string"],
|
|
175
|
+
"quick_fixes": ["string — actionable fix"]
|
|
176
|
+
}}
|
|
177
|
+
|
|
178
|
+
{_JSON_SUFFIX}"""
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def build_suggestions_prompt(data: dict[str, Any]) -> str:
|
|
182
|
+
"""Build prompt to generate actionable workflow improvement suggestions."""
|
|
183
|
+
data_str = json.dumps(data, indent=2, ensure_ascii=False)
|
|
184
|
+
return f"""\
|
|
185
|
+
You are generating actionable suggestions to improve an OpenCode user's workflow. \
|
|
186
|
+
OpenCode has powerful features that many users underutilize:
|
|
187
|
+
|
|
188
|
+
- **Skills**: Installable domain expertise that agents can load (e.g., playwright, \
|
|
189
|
+
git-master, frontend-ui-ux). Users can create custom skills.
|
|
190
|
+
- **AGENTS.md**: Project-specific rules and conventions that agents follow. Adding \
|
|
191
|
+
rules here shapes agent behavior for your codebase.
|
|
192
|
+
- **Hooks**: Automation triggers that run on events (e.g., pre-commit checks, \
|
|
193
|
+
auto-formatting). Configure in opencode.json.
|
|
194
|
+
- **Headless mode**: Run analysis via `opencode run` for scripted/automated workflows.
|
|
195
|
+
|
|
196
|
+
## User Data
|
|
197
|
+
{data_str}
|
|
198
|
+
|
|
199
|
+
## Instructions
|
|
200
|
+
|
|
201
|
+
Based on the user's patterns, suggest concrete improvements in three categories: \
|
|
202
|
+
AGENTS.md additions (specific rules to add), skill candidates (custom skills to create), \
|
|
203
|
+
and workflow patterns (better ways to use OpenCode).
|
|
204
|
+
|
|
205
|
+
Return a JSON object:
|
|
206
|
+
{{
|
|
207
|
+
"agents_md_additions": [
|
|
208
|
+
{{"rule": "string — specific rule to add to AGENTS.md", "rationale": "string"}}
|
|
209
|
+
],
|
|
210
|
+
"skill_candidates": [
|
|
211
|
+
{{"name": "string", "description": "string", "trigger_phrases": ["string"]}}
|
|
212
|
+
],
|
|
213
|
+
"workflow_patterns": [
|
|
214
|
+
{{"pattern": "string", "benefit": "string", "how_to": "string"}}
|
|
215
|
+
]
|
|
216
|
+
}}
|
|
217
|
+
|
|
218
|
+
{_JSON_SUFFIX}"""
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def build_tool_health_prompt(data: dict[str, Any]) -> str:
|
|
222
|
+
"""Build prompt to analyze tool usage patterns and error rates."""
|
|
223
|
+
data_str = json.dumps(data, indent=2, ensure_ascii=False)
|
|
224
|
+
return f"""\
|
|
225
|
+
You are analyzing tool usage health across OpenCode sessions. Tools include file \
|
|
226
|
+
operations (read, write, edit, glob, grep), shell commands (bash), LSP operations \
|
|
227
|
+
(diagnostics, definitions, references), and specialized tools (ast_grep, web fetch).
|
|
228
|
+
|
|
229
|
+
## Tool Usage Data
|
|
230
|
+
{data_str}
|
|
231
|
+
|
|
232
|
+
## Instructions
|
|
233
|
+
|
|
234
|
+
Analyze tool usage patterns and error rates. Identify problematic tools with high \
|
|
235
|
+
error rates, provide efficiency tips for better tool usage, and suggest recovery \
|
|
236
|
+
patterns for common tool failures.
|
|
237
|
+
|
|
238
|
+
Return a JSON object:
|
|
239
|
+
{{
|
|
240
|
+
"problematic_tools": [{{"tool": "string", "error_rate": "string", "likely_cause": \
|
|
241
|
+
"string", "fix": "string"}}],
|
|
242
|
+
"efficiency_tips": ["string — how to use tools more effectively"],
|
|
243
|
+
"recovery_patterns": ["string — what to do when tools fail"]
|
|
244
|
+
}}
|
|
245
|
+
|
|
246
|
+
{_JSON_SUFFIX}"""
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def build_horizon_prompt(data: dict[str, Any]) -> str:
|
|
250
|
+
"""Build prompt to identify future workflow opportunities."""
|
|
251
|
+
data_str = json.dumps(data, indent=2, ensure_ascii=False)
|
|
252
|
+
return f"""\
|
|
253
|
+
You are identifying future opportunities for an OpenCode user's workflow. Consider \
|
|
254
|
+
automation via hooks and headless mode (`opencode run`), skill gaps that could be \
|
|
255
|
+
filled with custom skills, and how their workflow could evolve as they adopt more \
|
|
256
|
+
OpenCode features like AGENTS.md rules and session management.
|
|
257
|
+
|
|
258
|
+
## Current Workflow Data
|
|
259
|
+
{data_str}
|
|
260
|
+
|
|
261
|
+
## Instructions
|
|
262
|
+
|
|
263
|
+
Identify automation opportunities (with effort estimates), skill gaps that would \
|
|
264
|
+
help but aren't currently available, and ways the user's workflow could evolve.
|
|
265
|
+
|
|
266
|
+
Return a JSON object:
|
|
267
|
+
{{
|
|
268
|
+
"automation_opportunities": [{{"opportunity": "string", "how": "string", \
|
|
269
|
+
"effort": "low|medium|high"}}],
|
|
270
|
+
"skill_gaps": ["string — capability that would help but isn't available"],
|
|
271
|
+
"workflow_evolutions": ["string — how your workflow could evolve"]
|
|
272
|
+
}}
|
|
273
|
+
|
|
274
|
+
{_JSON_SUFFIX}"""
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def build_at_a_glance_prompt(all_insights: dict[str, Any], stats_summary: dict[str, Any]) -> str:
|
|
278
|
+
"""Build prompt to synthesize all insights into an executive summary."""
|
|
279
|
+
insights_str = json.dumps(all_insights, indent=2, ensure_ascii=False)
|
|
280
|
+
stats_str = json.dumps(stats_summary, indent=2, ensure_ascii=False)
|
|
281
|
+
return f"""\
|
|
282
|
+
You are creating an executive summary of an OpenCode user's workflow analysis. \
|
|
283
|
+
You have access to all previously generated insights and overall usage statistics.
|
|
284
|
+
|
|
285
|
+
## All Insights
|
|
286
|
+
{insights_str}
|
|
287
|
+
|
|
288
|
+
## Usage Statistics
|
|
289
|
+
{stats_str}
|
|
290
|
+
|
|
291
|
+
## Instructions
|
|
292
|
+
|
|
293
|
+
Synthesize everything into a concise at-a-glance summary. Focus on the most \
|
|
294
|
+
impactful observations: what's working well (top 3), what's hindering productivity \
|
|
295
|
+
(top 3), quick wins with effort estimates, and ambitious workflow improvements \
|
|
296
|
+
to consider.
|
|
297
|
+
|
|
298
|
+
Return a JSON object:
|
|
299
|
+
{{
|
|
300
|
+
"whats_working": ["string — top 3 things working well"],
|
|
301
|
+
"whats_hindering": ["string — top 3 friction points"],
|
|
302
|
+
"quick_wins": [{{"action": "string", "impact": "string", "effort": "low|medium|high"}}],
|
|
303
|
+
"ambitious_workflows": ["string — bigger workflow improvements to consider"]
|
|
304
|
+
}}
|
|
305
|
+
|
|
306
|
+
{_JSON_SUFFIX}"""
|