opencodekit 0.21.10 → 0.22.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/dist/index.js +1 -1
- package/dist/template/.opencode/AGENTS.md +116 -487
- package/dist/template/.opencode/README.md +1 -1
- package/dist/template/.opencode/agent/build.md +56 -396
- package/dist/template/.opencode/agent/explore.md +0 -1
- package/dist/template/.opencode/agent/review.md +0 -1
- package/dist/template/.opencode/agent/scout.md +0 -1
- package/dist/template/.opencode/agent/vision.md +0 -1
- package/dist/template/.opencode/command/clarify.md +48 -0
- package/dist/template/.opencode/command/commit.md +53 -0
- package/dist/template/.opencode/command/fix.md +56 -0
- package/dist/template/.opencode/command/improve-architecture.md +55 -0
- package/dist/template/.opencode/command/init.md +88 -68
- package/dist/template/.opencode/command/refactor.md +66 -0
- package/dist/template/.opencode/command/test.md +66 -0
- package/dist/template/.opencode/dcp.jsonc +13 -2
- package/dist/template/.opencode/memory/README.md +3 -5
- package/dist/template/.opencode/memory/_templates/adr.md +45 -0
- package/dist/template/.opencode/memory/project/gotchas.md +1 -1
- package/dist/template/.opencode/memory/session-context.md +1 -1
- package/dist/template/.opencode/plugin/README.md +1 -1
- package/dist/template/.opencode/plugin/guard.ts +62 -0
- package/dist/template/.opencode/plugin/{lib/memory-admin-tools.ts → memory/admin.ts} +4 -4
- package/dist/template/.opencode/plugin/{lib → memory}/capture.ts +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/compile.ts +2 -2
- package/dist/template/.opencode/plugin/{lib → memory}/context.ts +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/curator.ts +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/db/observations.ts +102 -3
- package/dist/template/.opencode/plugin/{lib → memory}/db/schema.ts +43 -1
- package/dist/template/.opencode/plugin/{lib → memory}/db/types.ts +22 -0
- package/dist/template/.opencode/plugin/{lib/memory-db.ts → memory/db.ts} +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/distill.ts +1 -1
- package/dist/template/.opencode/plugin/{lib/memory-helpers.ts → memory/helpers.ts} +5 -1
- package/dist/template/.opencode/plugin/{lib/memory-hooks.ts → memory/hooks.ts} +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/index-generator.ts +2 -2
- package/dist/template/.opencode/plugin/{lib → memory}/inject.ts +1 -1
- package/dist/template/.opencode/plugin/{lib → memory}/lint.ts +2 -2
- package/dist/template/.opencode/plugin/memory/tools.ts +322 -0
- package/dist/template/.opencode/plugin/{lib → memory}/validate.ts +2 -2
- package/dist/template/.opencode/plugin/memory.ts +7 -17
- package/dist/template/.opencode/plugin/srcwalk.ts +721 -0
- package/dist/template/.opencode/skill/agent-code-quality-gate/SKILL.md +98 -0
- package/dist/template/.opencode/skill/behavioral-kernel/SKILL.md +52 -0
- package/dist/template/.opencode/skill/browser-testing-with-devtools/SKILL.md +85 -0
- package/dist/template/.opencode/skill/code-cleanup/SKILL.md +114 -0
- package/dist/template/.opencode/skill/code-navigation/SKILL.md +142 -0
- package/dist/template/.opencode/skill/code-review-and-quality/SKILL.md +131 -0
- package/dist/template/.opencode/skill/debugging-and-error-recovery/SKILL.md +109 -0
- package/dist/template/.opencode/skill/deep-module-design/SKILL.md +207 -0
- package/dist/template/.opencode/skill/git-workflow-and-versioning/SKILL.md +77 -0
- package/dist/template/.opencode/skill/grill-me/SKILL.md +140 -0
- package/dist/template/.opencode/skill/memory-system/SKILL.md +9 -10
- package/dist/template/.opencode/skill/planning-and-task-breakdown/SKILL.md +116 -0
- package/dist/template/.opencode/skill/shipping-and-launch/SKILL.md +95 -0
- package/dist/template/.opencode/skill/source-driven-development/SKILL.md +103 -0
- package/dist/template/.opencode/skill/spec-driven-development/SKILL.md +121 -0
- package/dist/template/.opencode/skill/srcwalk/SKILL.md +161 -0
- package/dist/template/.opencode/skill/ubiquitous-language/SKILL.md +184 -0
- package/package.json +1 -1
- package/dist/template/.opencode/AGENT_ALIGNMENT.md +0 -564
- package/dist/template/.opencode/agent/painter.md +0 -83
- package/dist/template/.opencode/command/compound.md +0 -240
- package/dist/template/.opencode/command/curate.md +0 -299
- package/dist/template/.opencode/command/handoff.md +0 -149
- package/dist/template/.opencode/command/health.md +0 -356
- package/dist/template/.opencode/command/init-context.md +0 -297
- package/dist/template/.opencode/command/init-user.md +0 -125
- package/dist/template/.opencode/command/iterate.md +0 -200
- package/dist/template/.opencode/command/lfg.md +0 -173
- package/dist/template/.opencode/command/resume.md +0 -78
- package/dist/template/.opencode/command/status.md +0 -126
- package/dist/template/.opencode/command/ui-slop-check.md +0 -169
- package/dist/template/.opencode/plugin/lib/memory-tools.ts +0 -535
- package/dist/template/.opencode/skill/agent-evals/SKILL.md +0 -208
- package/dist/template/.opencode/skill/anti-ai-slop/SKILL.md +0 -76
- package/dist/template/.opencode/skill/augment-context-engine/SKILL.md +0 -122
- package/dist/template/.opencode/skill/augment-context-engine/mcp.json +0 -6
- package/dist/template/.opencode/skill/brand-asset-protocol/SKILL.md +0 -222
- package/dist/template/.opencode/skill/code-search-patterns/SKILL.md +0 -224
- package/dist/template/.opencode/skill/code-simplification/SKILL.md +0 -211
- package/dist/template/.opencode/skill/context-condensation/SKILL.md +0 -149
- package/dist/template/.opencode/skill/context-initialization/SKILL.md +0 -69
- package/dist/template/.opencode/skill/context-management/SKILL.md +0 -390
- package/dist/template/.opencode/skill/deep-research/SKILL.md +0 -384
- package/dist/template/.opencode/skill/design-direction-advisor/SKILL.md +0 -139
- package/dist/template/.opencode/skill/dispatching-parallel-agents/SKILL.md +0 -191
- package/dist/template/.opencode/skill/executing-plans/SKILL.md +0 -247
- package/dist/template/.opencode/skill/figma-go/SKILL.md +0 -65
- package/dist/template/.opencode/skill/finishing-a-development-branch/SKILL.md +0 -357
- package/dist/template/.opencode/skill/full-output-enforcement/SKILL.md +0 -62
- package/dist/template/.opencode/skill/gh-address-comments/SKILL.md +0 -29
- package/dist/template/.opencode/skill/gh-address-comments/scripts/fetch_comments.py +0 -237
- package/dist/template/.opencode/skill/gh-fix-ci/SKILL.md +0 -38
- package/dist/template/.opencode/skill/gh-fix-ci/scripts/inspect_pr_checks.py +0 -509
- package/dist/template/.opencode/skill/hi-fi-prototype-html/SKILL.md +0 -253
- package/dist/template/.opencode/skill/html-deck-export/SKILL.md +0 -189
- package/dist/template/.opencode/skill/index-knowledge/SKILL.md +0 -413
- package/dist/template/.opencode/skill/memory-grounding/SKILL.md +0 -68
- package/dist/template/.opencode/skill/playwriter/SKILL.md +0 -158
- package/dist/template/.opencode/skill/portless/SKILL.md +0 -109
- package/dist/template/.opencode/skill/prd/SKILL.md +0 -146
- package/dist/template/.opencode/skill/prd-task/SKILL.md +0 -182
- package/dist/template/.opencode/skill/prd-task/references/prd-schema.json +0 -124
- package/dist/template/.opencode/skill/prompt-leverage/SKILL.md +0 -90
- package/dist/template/.opencode/skill/prompt-leverage/references/framework.md +0 -91
- package/dist/template/.opencode/skill/prompt-leverage/scripts/augment_prompt.py +0 -157
- package/dist/template/.opencode/skill/receiving-code-review/SKILL.md +0 -263
- package/dist/template/.opencode/skill/reconcile/SKILL.md +0 -183
- package/dist/template/.opencode/skill/reflection-checkpoints/SKILL.md +0 -183
- package/dist/template/.opencode/skill/requesting-code-review/SKILL.md +0 -443
- package/dist/template/.opencode/skill/requesting-code-review/references/specialist-profiles.md +0 -108
- package/dist/template/.opencode/skill/requesting-code-review/review.md +0 -160
- package/dist/template/.opencode/skill/rtk-command-compression/SKILL.md +0 -134
- package/dist/template/.opencode/skill/screenshot/SKILL.md +0 -48
- package/dist/template/.opencode/skill/screenshot/scripts/ensure_macos_permissions.sh +0 -54
- package/dist/template/.opencode/skill/screenshot/scripts/macos_display_info.swift +0 -22
- package/dist/template/.opencode/skill/screenshot/scripts/macos_permissions.swift +0 -40
- package/dist/template/.opencode/skill/screenshot/scripts/macos_window_info.swift +0 -126
- package/dist/template/.opencode/skill/screenshot/scripts/take_screenshot.ps1 +0 -163
- package/dist/template/.opencode/skill/screenshot/scripts/take_screenshot.py +0 -585
- package/dist/template/.opencode/skill/security-threat-model/SKILL.md +0 -36
- package/dist/template/.opencode/skill/security-threat-model/references/prompt-template.md +0 -255
- package/dist/template/.opencode/skill/security-threat-model/references/security-controls-and-assets.md +0 -32
- package/dist/template/.opencode/skill/sharing-skills/SKILL.md +0 -214
- package/dist/template/.opencode/skill/skill-creator/SKILL.md +0 -181
- package/dist/template/.opencode/skill/skill-installer/SKILL.md +0 -58
- package/dist/template/.opencode/skill/skill-installer/scripts/github_utils.py +0 -21
- package/dist/template/.opencode/skill/skill-installer/scripts/install-skill-from-github.py +0 -313
- package/dist/template/.opencode/skill/skill-installer/scripts/list-skills.py +0 -106
- package/dist/template/.opencode/skill/swarm-coordination/SKILL.md +0 -244
- package/dist/template/.opencode/skill/swarm-coordination/references/architecture.md +0 -39
- package/dist/template/.opencode/skill/swarm-coordination/references/delegation-worker-protocol.md +0 -145
- package/dist/template/.opencode/skill/swarm-coordination/references/dependency-graph.md +0 -50
- package/dist/template/.opencode/skill/swarm-coordination/references/drift-check.md +0 -90
- package/dist/template/.opencode/skill/swarm-coordination/references/integration-beads.md +0 -20
- package/dist/template/.opencode/skill/swarm-coordination/references/launch-flow.md +0 -186
- package/dist/template/.opencode/skill/swarm-coordination/references/reconciler.md +0 -172
- package/dist/template/.opencode/skill/swarm-coordination/references/tier-enforcement.md +0 -78
- package/dist/template/.opencode/skill/swarm-coordination/references/tmux-integration.md +0 -134
- package/dist/template/.opencode/skill/systematic-debugging/SKILL.md +0 -402
- package/dist/template/.opencode/skill/terse-output-mode/SKILL.md +0 -95
- package/dist/template/.opencode/skill/think-in-code/SKILL.md +0 -136
- package/dist/template/.opencode/skill/ux-quality-gates/SKILL.md +0 -137
- package/dist/template/.opencode/skill/v1-run/SKILL.md +0 -175
- package/dist/template/.opencode/skill/v1-run/mcp.json +0 -6
- package/dist/template/.opencode/skill/verification-gates/SKILL.md +0 -63
- package/dist/template/.opencode/skill/visual-analysis/SKILL.md +0 -154
- package/dist/template/.opencode/skill/web-design-guidelines/SKILL.md +0 -46
- package/dist/template/.opencode/skill/workspace-setup/SKILL.md +0 -76
- package/dist/template/.opencode/skill/writing-plans/SKILL.md +0 -320
- /package/dist/template/.opencode/plugin/{lib → memory}/compact.ts +0 -0
- /package/dist/template/.opencode/plugin/{lib → memory}/db/graph.ts +0 -0
- /package/dist/template/.opencode/plugin/{lib → memory}/db/maintenance.ts +0 -0
- /package/dist/template/.opencode/plugin/{lib → memory}/db/pipeline.ts +0 -0
- /package/dist/template/.opencode/plugin/{lib → memory}/notify.ts +0 -0
- /package/dist/template/.opencode/plugin/{lib → memory}/operation-log.ts +0 -0
package/dist/template/.opencode/skill/requesting-code-review/references/specialist-profiles.md
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
# Specialist Reviewer Profiles
|
|
2
|
-
|
|
3
|
-
Use these profiles when dispatching review agents for **standard** or **full** depth reviews. Each profile focuses the reviewer on a specific domain, reducing noise and increasing finding quality.
|
|
4
|
-
|
|
5
|
-
## Security Reviewer
|
|
6
|
-
|
|
7
|
-
**Focus:** OWASP Top 10, auth/authz, data exposure, injection, secrets
|
|
8
|
-
|
|
9
|
-
**Dispatch prompt addition:**
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
You are reviewing as a SECURITY SPECIALIST. Focus exclusively on:
|
|
13
|
-
|
|
14
|
-
1. Authentication/authorization gaps (missing auth checks, privilege escalation)
|
|
15
|
-
2. Injection vulnerabilities (SQL, XSS, command injection, path traversal)
|
|
16
|
-
3. Secrets exposure (hardcoded tokens, API keys in source, logged credentials)
|
|
17
|
-
4. Data validation gaps (missing input sanitization, unsafe deserialization)
|
|
18
|
-
5. Insecure defaults (permissive CORS, missing rate limiting, debug mode)
|
|
19
|
-
|
|
20
|
-
Ignore: Style, architecture, performance (other reviewers handle those).
|
|
21
|
-
|
|
22
|
-
Confidence threshold: Only report findings with confidence >= 0.60.
|
|
23
|
-
Below 0.60, include in a separate "Low Confidence / Investigate" section.
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
**When to use:** Always in standard and full reviews. Skip only for purely internal tools with no user input.
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## Architecture Reviewer
|
|
31
|
-
|
|
32
|
-
**Focus:** Coupling, SOLID principles, API design, dependency direction
|
|
33
|
-
|
|
34
|
-
**Dispatch prompt addition:**
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
You are reviewing as an ARCHITECTURE SPECIALIST. Focus exclusively on:
|
|
38
|
-
|
|
39
|
-
1. Coupling violations (circular deps, god modules, leaky abstractions)
|
|
40
|
-
2. API contract issues (breaking changes, inconsistent error formats, missing versioning)
|
|
41
|
-
3. Dependency direction violations (inner layers importing outer layers)
|
|
42
|
-
4. Abstraction misuse (over-engineering, unnecessary indirection, premature abstraction)
|
|
43
|
-
5. Pattern divergence (new code contradicts established codebase patterns)
|
|
44
|
-
|
|
45
|
-
Rules:
|
|
46
|
-
- Only flag architecture issues that will cause CONCRETE problems (maintenance cost, bugs, scaling)
|
|
47
|
-
- "I would have done it differently" is NOT a finding
|
|
48
|
-
- Preference for existing patterns over theoretically better ones
|
|
49
|
-
|
|
50
|
-
Confidence threshold: Only report findings with confidence >= 0.60.
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
**When to use:** Full reviews only. Skip for small fixes, config changes, or documentation updates.
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
## Performance Reviewer
|
|
58
|
-
|
|
59
|
-
**Focus:** Runtime efficiency, bundle size, database queries, memory
|
|
60
|
-
|
|
61
|
-
**Dispatch prompt addition:**
|
|
62
|
-
|
|
63
|
-
```
|
|
64
|
-
You are reviewing as a PERFORMANCE SPECIALIST. Focus exclusively on:
|
|
65
|
-
|
|
66
|
-
1. N+1 query patterns (loops that make DB/API calls)
|
|
67
|
-
2. Missing memoization on expensive computations
|
|
68
|
-
3. Unbounded data loading (no pagination, no limits)
|
|
69
|
-
4. Bundle size regressions (large imports that could be lazy-loaded)
|
|
70
|
-
5. Memory leaks (event listeners without cleanup, growing caches)
|
|
71
|
-
|
|
72
|
-
Rules:
|
|
73
|
-
- Only flag issues with MEASURABLE impact (not theoretical)
|
|
74
|
-
- "This could be faster" without evidence is NOT a finding
|
|
75
|
-
- Quantify impact where possible (e.g., "This runs N queries instead of 1")
|
|
76
|
-
|
|
77
|
-
Confidence threshold: Only report findings with confidence >= 0.70.
|
|
78
|
-
Performance findings below 0.70 are usually speculative — suppress them.
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
**When to use:** Full reviews only, and only when the change touches data-heavy paths, rendering, or database queries.
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
## Adversarial Pass
|
|
86
|
-
|
|
87
|
-
After all specialist reviews complete, run an adversarial pass on the combined findings. This prevents false positives from making it into the final report.
|
|
88
|
-
|
|
89
|
-
**Adversarial prompt:**
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
Review these findings from specialist reviewers. For EACH finding, challenge it from these angles:
|
|
93
|
-
|
|
94
|
-
1. **False positive check**: Does this issue actually exist in the code, or did the reviewer misread context?
|
|
95
|
-
2. **Severity inflation**: Is the severity appropriate, or is a CRITICAL actually a MINOR?
|
|
96
|
-
3. **Codebase context**: Does the existing codebase already handle this elsewhere (middleware, framework, config)?
|
|
97
|
-
4. **Cost-benefit**: Is the fix worth the effort, or is this pedantic?
|
|
98
|
-
|
|
99
|
-
For each finding, output:
|
|
100
|
-
- CONFIRMED (keep as-is)
|
|
101
|
-
- DOWNGRADED (reduce severity, explain why)
|
|
102
|
-
- REJECTED (false positive, explain why)
|
|
103
|
-
|
|
104
|
-
Only CONFIRMED and DOWNGRADED findings should appear in the final report.
|
|
105
|
-
Confidence threshold for rejection: >= 0.60 (be sure before removing a finding).
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
**When to use:** Full reviews with 3+ specialist reviewers. Reduces noise by ~30% based on typical review output.
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
# Code Review Agent
|
|
2
|
-
|
|
3
|
-
You are reviewing code changes for production readiness.
|
|
4
|
-
|
|
5
|
-
**Your task:**
|
|
6
|
-
|
|
7
|
-
1. Review {WHAT_WAS_IMPLEMENTED}
|
|
8
|
-
2. Compare against {PLAN_OR_REQUIREMENTS}
|
|
9
|
-
3. Check code quality, architecture, testing
|
|
10
|
-
4. Categorize issues by severity
|
|
11
|
-
5. Assess production readiness
|
|
12
|
-
|
|
13
|
-
## What Was Implemented
|
|
14
|
-
|
|
15
|
-
{DESCRIPTION}
|
|
16
|
-
|
|
17
|
-
## Requirements/Plan
|
|
18
|
-
|
|
19
|
-
{PLAN_REFERENCE}
|
|
20
|
-
|
|
21
|
-
## Git Range to Review
|
|
22
|
-
|
|
23
|
-
**Base:** {BASE_SHA}
|
|
24
|
-
**Head:** {HEAD_SHA}
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
git diff --stat {BASE_SHA}..{HEAD_SHA}
|
|
28
|
-
git diff {BASE_SHA}..{HEAD_SHA}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Review Checklist
|
|
32
|
-
|
|
33
|
-
**Code Quality:**
|
|
34
|
-
|
|
35
|
-
- Clean separation of concerns?
|
|
36
|
-
- Proper error handling?
|
|
37
|
-
- Type safety (if applicable)?
|
|
38
|
-
- DRY principle followed?
|
|
39
|
-
- Edge cases handled?
|
|
40
|
-
|
|
41
|
-
**Architecture:**
|
|
42
|
-
|
|
43
|
-
- Sound design decisions?
|
|
44
|
-
- Scalability considerations?
|
|
45
|
-
- Performance implications?
|
|
46
|
-
- Security concerns?
|
|
47
|
-
|
|
48
|
-
**Testing:**
|
|
49
|
-
|
|
50
|
-
- Tests actually test logic (not mocks)?
|
|
51
|
-
- Edge cases covered?
|
|
52
|
-
- Integration tests where needed?
|
|
53
|
-
- All tests passing?
|
|
54
|
-
|
|
55
|
-
**Requirements:**
|
|
56
|
-
|
|
57
|
-
- All plan requirements met?
|
|
58
|
-
- Implementation matches spec?
|
|
59
|
-
- No scope creep?
|
|
60
|
-
- Breaking changes documented?
|
|
61
|
-
|
|
62
|
-
**Production Readiness:**
|
|
63
|
-
|
|
64
|
-
- Migration strategy (if schema changes)?
|
|
65
|
-
- Backward compatibility considered?
|
|
66
|
-
- Documentation complete?
|
|
67
|
-
- No obvious bugs?
|
|
68
|
-
|
|
69
|
-
## Output Format
|
|
70
|
-
|
|
71
|
-
### Strengths
|
|
72
|
-
|
|
73
|
-
[What's well done? Be specific.]
|
|
74
|
-
|
|
75
|
-
### Issues
|
|
76
|
-
|
|
77
|
-
#### Critical (Must Fix)
|
|
78
|
-
|
|
79
|
-
[Bugs, security issues, data loss risks, broken functionality]
|
|
80
|
-
|
|
81
|
-
#### Important (Should Fix)
|
|
82
|
-
|
|
83
|
-
[Architecture problems, missing features, poor error handling, test gaps]
|
|
84
|
-
|
|
85
|
-
#### Minor (Nice to Have)
|
|
86
|
-
|
|
87
|
-
[Code style, optimization opportunities, documentation improvements]
|
|
88
|
-
|
|
89
|
-
**For each issue:**
|
|
90
|
-
|
|
91
|
-
- File:line reference
|
|
92
|
-
- What's wrong
|
|
93
|
-
- Why it matters
|
|
94
|
-
- How to fix (if not obvious)
|
|
95
|
-
|
|
96
|
-
### Recommendations
|
|
97
|
-
|
|
98
|
-
[Improvements for code quality, architecture, or process]
|
|
99
|
-
|
|
100
|
-
### Assessment
|
|
101
|
-
|
|
102
|
-
**Ready to merge?** [Yes/No/With fixes]
|
|
103
|
-
|
|
104
|
-
**Reasoning:** [Technical assessment in 1-2 sentences]
|
|
105
|
-
|
|
106
|
-
## Critical Rules
|
|
107
|
-
|
|
108
|
-
**DO:**
|
|
109
|
-
|
|
110
|
-
- Categorize by actual severity (not everything is Critical)
|
|
111
|
-
- Be specific (file:line, not vague)
|
|
112
|
-
- Explain WHY issues matter
|
|
113
|
-
- Acknowledge strengths
|
|
114
|
-
- Give clear verdict
|
|
115
|
-
|
|
116
|
-
**DON'T:**
|
|
117
|
-
|
|
118
|
-
- Say "looks good" without checking
|
|
119
|
-
- Mark nitpicks as Critical
|
|
120
|
-
- Give feedback on code you didn't review
|
|
121
|
-
- Be vague ("improve error handling")
|
|
122
|
-
- Avoid giving a clear verdict
|
|
123
|
-
|
|
124
|
-
## Example Output
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
### Strengths
|
|
128
|
-
- Clean database schema with proper migrations (db.ts:15-42)
|
|
129
|
-
- Comprehensive test coverage (18 tests, all edge cases)
|
|
130
|
-
- Good error handling with fallbacks (summarizer.ts:85-92)
|
|
131
|
-
|
|
132
|
-
### Issues
|
|
133
|
-
|
|
134
|
-
#### Important
|
|
135
|
-
1. **Missing help text in CLI wrapper**
|
|
136
|
-
- File: index-conversations:1-31
|
|
137
|
-
- Issue: No --help flag, users won't discover --concurrency
|
|
138
|
-
- Fix: Add --help case with usage examples
|
|
139
|
-
|
|
140
|
-
2. **Date validation missing**
|
|
141
|
-
- File: search.ts:25-27
|
|
142
|
-
- Issue: Invalid dates silently return no results
|
|
143
|
-
- Fix: Validate ISO format, throw error with example
|
|
144
|
-
|
|
145
|
-
#### Minor
|
|
146
|
-
1. **Progress indicators**
|
|
147
|
-
- File: indexer.ts:130
|
|
148
|
-
- Issue: No "X of Y" counter for long operations
|
|
149
|
-
- Impact: Users don't know how long to wait
|
|
150
|
-
|
|
151
|
-
### Recommendations
|
|
152
|
-
- Add progress reporting for user experience
|
|
153
|
-
- Consider config file for excluded projects (portability)
|
|
154
|
-
|
|
155
|
-
### Assessment
|
|
156
|
-
|
|
157
|
-
**Ready to merge: With fixes**
|
|
158
|
-
|
|
159
|
-
**Reasoning:** Core implementation is solid with good architecture and tests. Important issues (help text, date validation) are easily fixed and don't affect core functionality.
|
|
160
|
-
```
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: rtk-command-compression
|
|
3
|
-
description: Use when installing, enabling, testing, or operating RTK command-output compression in OpenCode — keeps RTK opt-in, verifies the correct binary/plugin, protects raw verification evidence, and maintains safe hook exclusions.
|
|
4
|
-
version: 1.0.0
|
|
5
|
-
tags: [workflow, integration, automation]
|
|
6
|
-
dependencies: []
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# RTK Token Optimization
|
|
10
|
-
|
|
11
|
-
## Overview
|
|
12
|
-
|
|
13
|
-
RTK can reduce noisy shell output from commands like `git status`, tests, lint, build tools, Docker, kubectl, and `gh`. Treat it as an **opt-in shell-output compressor**, not a replacement for OpenCode's native read/search/edit tools.
|
|
14
|
-
|
|
15
|
-
Core rule: **opt in explicitly, verify rewrites, preserve raw evidence when correctness matters.**
|
|
16
|
-
|
|
17
|
-
## When to Use
|
|
18
|
-
|
|
19
|
-
- User asks to install, enable, test, tune, or troubleshoot RTK in OpenCode.
|
|
20
|
-
- Bash output is consuming too much context from shell-heavy workflows.
|
|
21
|
-
- You need to document or validate RTK wiring in a project where `~/.config/opencode` may be symlinked to `.opencode`.
|
|
22
|
-
|
|
23
|
-
## When NOT to Use
|
|
24
|
-
|
|
25
|
-
- Code inspection or editing: prefer `srcwalk find`/`srcwalk <path>`, LSP, Read, Grep, and Edit.
|
|
26
|
-
- Full verification evidence is required and compressed summaries would hide diagnostics.
|
|
27
|
-
- The user has not approved installing binaries, changing global OpenCode config, or adding plugins.
|
|
28
|
-
|
|
29
|
-
## Current OpenCodeKit Wiring
|
|
30
|
-
|
|
31
|
-
This template supports RTK as optional user-local wiring:
|
|
32
|
-
|
|
33
|
-
- RTK binary: `~/.local/bin/rtk` after opt-in install.
|
|
34
|
-
- Active OpenCode plugin path in this symlinked setup: `.opencode/plugin/rtk.ts`.
|
|
35
|
-
- RTK config path on macOS: `~/Library/Application Support/rtk/config.toml`.
|
|
36
|
-
- Keep telemetry disabled unless the user explicitly opts in.
|
|
37
|
-
- Keep tee mode on `failures` so raw output can be recovered when commands fail.
|
|
38
|
-
|
|
39
|
-
If `~/.config/opencode` is symlinked to this repo's `.opencode`, OpenCode may resolve the same plugin as both global and project config. The RTK plugin must be idempotent: skip commands already starting with `rtk`.
|
|
40
|
-
|
|
41
|
-
## Install / Enable Checklist
|
|
42
|
-
|
|
43
|
-
Ask before installing or changing global config. Then run:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
command -v rtk || RTK_INSTALL_DIR="$HOME/.local/bin" sh /tmp/rtk-research/install.sh
|
|
47
|
-
rtk --version
|
|
48
|
-
rtk gain
|
|
49
|
-
RTK_TELEMETRY_DISABLED=1 rtk init -g --opencode --hook-only
|
|
50
|
-
RTK_TELEMETRY_DISABLED=1 rtk config --create
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Verify OpenCode sees the plugin:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
opencode debug config | grep -i 'rtk\|plugin' -C 2
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Verify RTK itself:
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
RTK_TELEMETRY_DISABLED=1 rtk telemetry status
|
|
63
|
-
rtk verify
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
`rtk verify` may say a Claude hook is not installed; that is expected when only the OpenCode plugin is enabled. The important checks are the OpenCode plugin path, telemetry status, and RTK test count.
|
|
67
|
-
|
|
68
|
-
## Required Safety Settings
|
|
69
|
-
|
|
70
|
-
In `~/Library/Application Support/rtk/config.toml`, keep exclusions for commands that need raw output or are known unsafe under RTK rewrite:
|
|
71
|
-
|
|
72
|
-
```toml
|
|
73
|
-
[hooks]
|
|
74
|
-
exclude_commands = ["curl", "wget", "playwright", "find", "npx oxlint", "git push", "git rebase", "git cherry-pick"]
|
|
75
|
-
|
|
76
|
-
[telemetry]
|
|
77
|
-
enabled = false
|
|
78
|
-
|
|
79
|
-
[tee]
|
|
80
|
-
enabled = true
|
|
81
|
-
mode = "failures"
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Rationale:
|
|
85
|
-
|
|
86
|
-
| Exclusion | Why |
|
|
87
|
-
| ------------------------------------------- | ------------------------------------------------------------------------------ |
|
|
88
|
-
| `curl`, `wget` | Preserve raw HTTP output and avoid hiding API/debug evidence. |
|
|
89
|
-
| `playwright` | Browser automation logs/screenshots need full fidelity. |
|
|
90
|
-
| `find` | RTK `find` can reject compound predicates/actions used by normal shell `find`. |
|
|
91
|
-
| `npx oxlint` | RTK may rewrite this to an npm script and fail if no `oxlint` script exists. |
|
|
92
|
-
| `git push`, `git rebase`, `git cherry-pick` | Destructive/history-changing operations must not be obscured by wrappers. |
|
|
93
|
-
|
|
94
|
-
Add more exclusions as soon as a rewrite changes semantics or hides evidence.
|
|
95
|
-
|
|
96
|
-
## Runtime Usage Rules
|
|
97
|
-
|
|
98
|
-
- Use normal shell commands; let RTK rewrite low-risk noisy commands automatically.
|
|
99
|
-
- Do not manually prefix commands with `rtk` unless you are intentionally testing RTK.
|
|
100
|
-
- For verification gates, prefer raw commands or confirm the compressed output still includes pass/fail counts and actionable diagnostics.
|
|
101
|
-
- If output looks too compact, rerun with an excluded/raw command before making completion claims.
|
|
102
|
-
- Never cite RTK savings as proof that a task is correct; it only proves compression happened.
|
|
103
|
-
|
|
104
|
-
## Testing RTK Works
|
|
105
|
-
|
|
106
|
-
Use one command that should rewrite and one that should not:
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
git status
|
|
110
|
-
curl https://example.com
|
|
111
|
-
rtk gain
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
Expected evidence:
|
|
115
|
-
|
|
116
|
-
- `git status` output appears in RTK's compact style and `rtk gain` command count increases.
|
|
117
|
-
- `curl` shows raw curl progress/body because it is excluded.
|
|
118
|
-
- `rtk gain` lists tracked commands such as `rtk git status` and token savings.
|
|
119
|
-
|
|
120
|
-
## Troubleshooting
|
|
121
|
-
|
|
122
|
-
| Symptom | Check | Fix |
|
|
123
|
-
| -------------------------------- | ----------------------------------------------- | ----------------------------------------------------------------------- |
|
|
124
|
-
| No rewrites | `opencode debug config` | Restart OpenCode and confirm `.opencode/plugin/rtk.ts` is loaded. |
|
|
125
|
-
| Recursive `rtk rtk ...` behavior | Inspect `.opencode/plugin/rtk.ts` | Add/restore idempotency guard for commands already starting with `rtk`. |
|
|
126
|
-
| Command semantics changed | `rtk rewrite '<command>'` | Add the command prefix to `[hooks].exclude_commands`. |
|
|
127
|
-
| Need raw failed output | Check RTK tee files/config | Keep `[tee] mode = "failures"`; rerun raw if needed. |
|
|
128
|
-
| Telemetry concern | `RTK_TELEMETRY_DISABLED=1 rtk telemetry status` | Keep telemetry disabled unless user opts in. |
|
|
129
|
-
|
|
130
|
-
## Gotchas
|
|
131
|
-
|
|
132
|
-
- **OpenCode path changed from plural to singular** — Initial RTK docs/install path referenced `plugins/rtk.ts`, but active OpenCodeKit loading after restart used `.opencode/plugin/rtk.ts`. Document and inspect the active path, not just installer output.
|
|
133
|
-
- **Symlinked global/project config can double-load plugin paths** — When `~/.config/opencode` points at this repo's `.opencode`, OpenCode can resolve global and project plugin URLs. The plugin must skip commands already starting with `rtk`.
|
|
134
|
-
- **Unsafe rewrites were observed** — `find` compound predicates and `npx oxlint` were rewritten incorrectly during testing. Keep them excluded unless RTK behavior changes and is re-verified.
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: screenshot
|
|
3
|
-
description: Use when the user explicitly asks for desktop/system screenshots or when browser/tool-specific capture is unavailable.
|
|
4
|
-
version: 1.0.0
|
|
5
|
-
tags: [debugging, ui, automation]
|
|
6
|
-
dependencies: []
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# screenshot
|
|
10
|
-
|
|
11
|
-
Capture screenshots at OS level for desktop apps, windows, regions, or full screen.
|
|
12
|
-
|
|
13
|
-
## When to Use
|
|
14
|
-
|
|
15
|
-
- User asks for screenshot of desktop/app/window/region
|
|
16
|
-
- You need non-browser captures (native app, OS UI, Electron shell)
|
|
17
|
-
- Browser capture tools are unavailable or insufficient
|
|
18
|
-
|
|
19
|
-
## When NOT to Use
|
|
20
|
-
|
|
21
|
-
- Browser-only capture where Playwright/DevTools is enough
|
|
22
|
-
- Design-file capture where Figma skills are available
|
|
23
|
-
|
|
24
|
-
## Save Location Rules
|
|
25
|
-
|
|
26
|
-
1. If user gives a path, save there.
|
|
27
|
-
2. If user asks generally for a screenshot, use OS default screenshot location.
|
|
28
|
-
3. If screenshot is for agent inspection, save to temp location.
|
|
29
|
-
|
|
30
|
-
## Scripts
|
|
31
|
-
|
|
32
|
-
- `scripts/take_screenshot.py` (macOS/Linux)
|
|
33
|
-
- `scripts/take_screenshot.ps1` (Windows)
|
|
34
|
-
- `scripts/ensure_macos_permissions.sh` (macOS preflight)
|
|
35
|
-
|
|
36
|
-
## Quick Start
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
# macOS/Linux default capture
|
|
40
|
-
python3 .opencode/skill/screenshot/scripts/take_screenshot.py
|
|
41
|
-
|
|
42
|
-
# capture app window(s) on macOS to temp
|
|
43
|
-
bash .opencode/skill/screenshot/scripts/ensure_macos_permissions.sh && \
|
|
44
|
-
python3 .opencode/skill/screenshot/scripts/take_screenshot.py --app "Codex" --mode temp
|
|
45
|
-
|
|
46
|
-
# region capture
|
|
47
|
-
python3 .opencode/skill/screenshot/scripts/take_screenshot.py --mode temp --region 100,200,800,600
|
|
48
|
-
```
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -euo pipefail
|
|
3
|
-
|
|
4
|
-
if [[ "$(uname)" != "Darwin" ]]; then
|
|
5
|
-
echo "ensure_macos_permissions.sh only supports macOS" >&2
|
|
6
|
-
exit 1
|
|
7
|
-
fi
|
|
8
|
-
|
|
9
|
-
if ! command -v swift >/dev/null 2>&1; then
|
|
10
|
-
echo "swift is required to check macOS screen capture permissions" >&2
|
|
11
|
-
exit 1
|
|
12
|
-
fi
|
|
13
|
-
|
|
14
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
15
|
-
PERM_SWIFT="$SCRIPT_DIR/macos_permissions.swift"
|
|
16
|
-
MODULE_CACHE="${TMPDIR:-/tmp}/codex-swift-module-cache"
|
|
17
|
-
mkdir -p "$MODULE_CACHE"
|
|
18
|
-
|
|
19
|
-
screen_capture_status() {
|
|
20
|
-
local json
|
|
21
|
-
json="$(swift -module-cache-path "$MODULE_CACHE" "$PERM_SWIFT" "$@")"
|
|
22
|
-
python3 -c 'import json, sys; data=json.loads(sys.argv[1]); print("1" if data.get("screenCapture") else "0")' "$json"
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if [[ -n "${CODEX_SANDBOX:-}" ]]; then
|
|
26
|
-
echo "Screen capture checks are blocked in the sandbox; rerun with escalated permissions." >&2
|
|
27
|
-
exit 3
|
|
28
|
-
fi
|
|
29
|
-
|
|
30
|
-
if [[ "$(screen_capture_status)" == "1" ]]; then
|
|
31
|
-
echo "Screen Recording permission already granted."
|
|
32
|
-
exit 0
|
|
33
|
-
fi
|
|
34
|
-
|
|
35
|
-
cat <<'MSG'
|
|
36
|
-
This workflow needs macOS Screen Recording permission to capture screenshots.
|
|
37
|
-
macOS will show a single system prompt for Screen Recording. Approve it, then
|
|
38
|
-
return here. If macOS opens System Settings instead of prompting, enable Screen
|
|
39
|
-
Recording for your terminal and rerun the command.
|
|
40
|
-
MSG
|
|
41
|
-
|
|
42
|
-
# Request permission once after explaining why it is needed.
|
|
43
|
-
screen_capture_status --request >/dev/null || true
|
|
44
|
-
|
|
45
|
-
if [[ "$(screen_capture_status)" != "1" ]]; then
|
|
46
|
-
cat <<'MSG'
|
|
47
|
-
Screen Recording is still not granted.
|
|
48
|
-
Open System Settings > Privacy & Security > Screen Recording and enable it for
|
|
49
|
-
your terminal (and Codex if needed), then rerun your screenshot command.
|
|
50
|
-
MSG
|
|
51
|
-
exit 2
|
|
52
|
-
fi
|
|
53
|
-
|
|
54
|
-
echo "Screen Recording permission granted."
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import AppKit
|
|
2
|
-
import Foundation
|
|
3
|
-
|
|
4
|
-
struct Response: Encodable {
|
|
5
|
-
let count: Int
|
|
6
|
-
let displays: [Int]
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
let count = max(NSScreen.screens.count, 1)
|
|
10
|
-
let displays = Array(1...count)
|
|
11
|
-
|
|
12
|
-
let response = Response(count: count, displays: displays)
|
|
13
|
-
let encoder = JSONEncoder()
|
|
14
|
-
encoder.outputFormatting = [.sortedKeys]
|
|
15
|
-
|
|
16
|
-
if let data = try? encoder.encode(response),
|
|
17
|
-
let json = String(data: data, encoding: .utf8) {
|
|
18
|
-
print(json)
|
|
19
|
-
} else {
|
|
20
|
-
fputs("{\"count\":\(count)}\n", stderr)
|
|
21
|
-
exit(1)
|
|
22
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import CoreGraphics
|
|
2
|
-
import Foundation
|
|
3
|
-
|
|
4
|
-
struct Status: Encodable {
|
|
5
|
-
let screenCapture: Bool
|
|
6
|
-
let requested: Bool
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
let shouldRequest = CommandLine.arguments.contains("--request")
|
|
10
|
-
|
|
11
|
-
@available(macOS 10.15, *)
|
|
12
|
-
func screenCaptureGranted(request: Bool) -> Bool {
|
|
13
|
-
if CGPreflightScreenCaptureAccess() {
|
|
14
|
-
return true
|
|
15
|
-
}
|
|
16
|
-
if request {
|
|
17
|
-
_ = CGRequestScreenCaptureAccess()
|
|
18
|
-
return CGPreflightScreenCaptureAccess()
|
|
19
|
-
}
|
|
20
|
-
return false
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let granted: Bool
|
|
24
|
-
if #available(macOS 10.15, *) {
|
|
25
|
-
granted = screenCaptureGranted(request: shouldRequest)
|
|
26
|
-
} else {
|
|
27
|
-
granted = true
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
let status = Status(screenCapture: granted, requested: shouldRequest)
|
|
31
|
-
let encoder = JSONEncoder()
|
|
32
|
-
encoder.outputFormatting = [.sortedKeys]
|
|
33
|
-
|
|
34
|
-
if let data = try? encoder.encode(status),
|
|
35
|
-
let json = String(data: data, encoding: .utf8) {
|
|
36
|
-
print(json)
|
|
37
|
-
} else {
|
|
38
|
-
fputs("{\"requested\":\(shouldRequest),\"screenCapture\":\(granted)}\n", stderr)
|
|
39
|
-
exit(1)
|
|
40
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import AppKit
|
|
2
|
-
import CoreGraphics
|
|
3
|
-
import Foundation
|
|
4
|
-
|
|
5
|
-
struct Bounds: Encodable {
|
|
6
|
-
let x: Int
|
|
7
|
-
let y: Int
|
|
8
|
-
let width: Int
|
|
9
|
-
let height: Int
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
struct WindowInfo: Encodable {
|
|
13
|
-
let id: Int
|
|
14
|
-
let owner: String
|
|
15
|
-
let name: String
|
|
16
|
-
let layer: Int
|
|
17
|
-
let bounds: Bounds
|
|
18
|
-
let area: Int
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
struct Response: Encodable {
|
|
22
|
-
let count: Int
|
|
23
|
-
let selected: WindowInfo?
|
|
24
|
-
let windows: [WindowInfo]?
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
func value(for flag: String) -> String? {
|
|
28
|
-
guard let idx = CommandLine.arguments.firstIndex(of: flag) else {
|
|
29
|
-
return nil
|
|
30
|
-
}
|
|
31
|
-
let next = CommandLine.arguments.index(after: idx)
|
|
32
|
-
guard next < CommandLine.arguments.endIndex else {
|
|
33
|
-
return nil
|
|
34
|
-
}
|
|
35
|
-
return CommandLine.arguments[next]
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
let frontmostFlag = CommandLine.arguments.contains("--frontmost")
|
|
39
|
-
let explicitApp = value(for: "--app")
|
|
40
|
-
let frontmostName = frontmostFlag ? NSWorkspace.shared.frontmostApplication?.localizedName : nil
|
|
41
|
-
if frontmostFlag && frontmostName == nil {
|
|
42
|
-
fputs("{\"count\":0}\n", stderr)
|
|
43
|
-
exit(1)
|
|
44
|
-
}
|
|
45
|
-
let appFilter = (explicitApp ?? frontmostName)?.lowercased()
|
|
46
|
-
let nameFilter = value(for: "--window-name")?.lowercased()
|
|
47
|
-
let includeList = CommandLine.arguments.contains("--list")
|
|
48
|
-
|
|
49
|
-
let options: CGWindowListOption = [.optionOnScreenOnly, .excludeDesktopElements]
|
|
50
|
-
guard let raw = CGWindowListCopyWindowInfo(options, kCGNullWindowID) as? [[String: Any]] else {
|
|
51
|
-
fputs("{\"count\":0}\n", stderr)
|
|
52
|
-
exit(1)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
var exactMatches: [WindowInfo] = []
|
|
56
|
-
var partialMatches: [WindowInfo] = []
|
|
57
|
-
exactMatches.reserveCapacity(raw.count)
|
|
58
|
-
partialMatches.reserveCapacity(raw.count)
|
|
59
|
-
|
|
60
|
-
for entry in raw {
|
|
61
|
-
guard let owner = entry[kCGWindowOwnerName as String] as? String else { continue }
|
|
62
|
-
let ownerLower = owner.lowercased()
|
|
63
|
-
if let appFilter, !ownerLower.contains(appFilter) { continue }
|
|
64
|
-
|
|
65
|
-
let name = (entry[kCGWindowName as String] as? String) ?? ""
|
|
66
|
-
if let nameFilter, !name.lowercased().contains(nameFilter) { continue }
|
|
67
|
-
|
|
68
|
-
guard let number = entry[kCGWindowNumber as String] as? Int else { continue }
|
|
69
|
-
let layer = (entry[kCGWindowLayer as String] as? Int) ?? 0
|
|
70
|
-
|
|
71
|
-
guard let boundsDict = entry[kCGWindowBounds as String] as? [String: Any] else { continue }
|
|
72
|
-
let x = Int((boundsDict["X"] as? Double) ?? 0)
|
|
73
|
-
let y = Int((boundsDict["Y"] as? Double) ?? 0)
|
|
74
|
-
let width = Int((boundsDict["Width"] as? Double) ?? 0)
|
|
75
|
-
let height = Int((boundsDict["Height"] as? Double) ?? 0)
|
|
76
|
-
if width <= 0 || height <= 0 { continue }
|
|
77
|
-
|
|
78
|
-
let bounds = Bounds(x: x, y: y, width: width, height: height)
|
|
79
|
-
let area = width * height
|
|
80
|
-
let info = WindowInfo(id: number, owner: owner, name: name, layer: layer, bounds: bounds, area: area)
|
|
81
|
-
if let appFilter, ownerLower == appFilter {
|
|
82
|
-
exactMatches.append(info)
|
|
83
|
-
} else {
|
|
84
|
-
partialMatches.append(info)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
let windows: [WindowInfo]
|
|
89
|
-
if appFilter != nil && !exactMatches.isEmpty {
|
|
90
|
-
windows = exactMatches
|
|
91
|
-
} else {
|
|
92
|
-
windows = partialMatches
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
func rank(_ window: WindowInfo) -> (Int, Int) {
|
|
96
|
-
// Prefer normal-layer windows, then larger area.
|
|
97
|
-
let layerScore = window.layer == 0 ? 0 : 1
|
|
98
|
-
return (layerScore, -window.area)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
let ordered: [WindowInfo]
|
|
102
|
-
if frontmostFlag {
|
|
103
|
-
ordered = windows
|
|
104
|
-
} else {
|
|
105
|
-
ordered = windows.sorted { rank($0) < rank($1) }
|
|
106
|
-
}
|
|
107
|
-
let selected = ordered.first
|
|
108
|
-
|
|
109
|
-
let list: [WindowInfo]?
|
|
110
|
-
if includeList {
|
|
111
|
-
list = ordered
|
|
112
|
-
} else {
|
|
113
|
-
list = nil
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
let response = Response(count: windows.count, selected: selected, windows: list)
|
|
117
|
-
let encoder = JSONEncoder()
|
|
118
|
-
encoder.outputFormatting = [.sortedKeys]
|
|
119
|
-
|
|
120
|
-
if let data = try? encoder.encode(response),
|
|
121
|
-
let json = String(data: data, encoding: .utf8) {
|
|
122
|
-
print(json)
|
|
123
|
-
} else {
|
|
124
|
-
fputs("{\"count\":\(windows.count)}\n", stderr)
|
|
125
|
-
exit(1)
|
|
126
|
-
}
|