agentsys 5.3.0 → 5.3.2

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 (137) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.cursor/commands/audit-project-agents.md +454 -0
  4. package/.cursor/commands/audit-project-github.md +141 -0
  5. package/.cursor/commands/audit-project.md +330 -0
  6. package/.cursor/commands/consult.md +417 -0
  7. package/.cursor/commands/debate.md +381 -0
  8. package/.cursor/commands/delivery-approval.md +334 -0
  9. package/.cursor/commands/deslop.md +142 -0
  10. package/.cursor/commands/drift-detect.md +259 -0
  11. package/.cursor/commands/enhance.md +172 -0
  12. package/.cursor/commands/learn.md +165 -0
  13. package/.cursor/commands/next-task.md +519 -0
  14. package/.cursor/commands/perf.md +464 -0
  15. package/.cursor/commands/repo-map.md +124 -0
  16. package/.cursor/commands/ship-ci-review-loop.md +468 -0
  17. package/.cursor/commands/ship-deployment.md +348 -0
  18. package/.cursor/commands/ship-error-handling.md +265 -0
  19. package/.cursor/commands/ship.md +517 -0
  20. package/.cursor/commands/sync-docs.md +171 -0
  21. package/.cursor/commands/web-ctl.md +101 -0
  22. package/.cursor/skills/consult/SKILL.md +425 -0
  23. package/.cursor/skills/debate/SKILL.md +316 -0
  24. package/.cursor/skills/deslop/SKILL.md +204 -0
  25. package/.cursor/skills/discover-tasks/SKILL.md +297 -0
  26. package/.cursor/skills/drift-analysis/SKILL.md +324 -0
  27. package/.cursor/skills/enhance-agent-prompts/SKILL.md +277 -0
  28. package/.cursor/skills/enhance-claude-memory/SKILL.md +387 -0
  29. package/.cursor/skills/enhance-cross-file/SKILL.md +110 -0
  30. package/.cursor/skills/enhance-docs/SKILL.md +298 -0
  31. package/.cursor/skills/enhance-hooks/SKILL.md +554 -0
  32. package/.cursor/skills/enhance-orchestrator/SKILL.md +255 -0
  33. package/.cursor/skills/enhance-plugins/SKILL.md +319 -0
  34. package/.cursor/skills/enhance-prompts/SKILL.md +340 -0
  35. package/.cursor/skills/enhance-skills/SKILL.md +436 -0
  36. package/.cursor/skills/learn/SKILL.md +349 -0
  37. package/.cursor/skills/orchestrate-review/SKILL.md +260 -0
  38. package/.cursor/skills/perf-analyzer/SKILL.md +37 -0
  39. package/.cursor/skills/perf-baseline-manager/SKILL.md +30 -0
  40. package/.cursor/skills/perf-benchmarker/SKILL.md +52 -0
  41. package/.cursor/skills/perf-code-paths/SKILL.md +32 -0
  42. package/.cursor/skills/perf-investigation-logger/SKILL.md +41 -0
  43. package/.cursor/skills/perf-profiler/SKILL.md +42 -0
  44. package/.cursor/skills/perf-theory-gatherer/SKILL.md +35 -0
  45. package/.cursor/skills/perf-theory-tester/SKILL.md +36 -0
  46. package/.cursor/skills/repo-mapping/SKILL.md +83 -0
  47. package/.cursor/skills/sync-docs/SKILL.md +351 -0
  48. package/.cursor/skills/validate-delivery/SKILL.md +186 -0
  49. package/.cursor/skills/web-auth/SKILL.md +177 -0
  50. package/.cursor/skills/web-browse/SKILL.md +516 -0
  51. package/.kiro/agents/agent-enhancer.json +12 -0
  52. package/.kiro/agents/ci-fixer.json +13 -0
  53. package/.kiro/agents/ci-monitor.json +12 -0
  54. package/.kiro/agents/claudemd-enhancer.json +12 -0
  55. package/.kiro/agents/consult-agent.json +13 -0
  56. package/.kiro/agents/cross-file-enhancer.json +12 -0
  57. package/.kiro/agents/debate-orchestrator.json +13 -0
  58. package/.kiro/agents/delivery-validator.json +12 -0
  59. package/.kiro/agents/deslop-agent.json +12 -0
  60. package/.kiro/agents/docs-enhancer.json +12 -0
  61. package/.kiro/agents/exploration-agent.json +12 -0
  62. package/.kiro/agents/hooks-enhancer.json +11 -0
  63. package/.kiro/agents/implementation-agent.json +13 -0
  64. package/.kiro/agents/learn-agent.json +12 -0
  65. package/.kiro/agents/map-validator.json +11 -0
  66. package/.kiro/agents/perf-analyzer.json +12 -0
  67. package/.kiro/agents/perf-code-paths.json +11 -0
  68. package/.kiro/agents/perf-investigation-logger.json +12 -0
  69. package/.kiro/agents/perf-orchestrator.json +13 -0
  70. package/.kiro/agents/perf-theory-gatherer.json +12 -0
  71. package/.kiro/agents/perf-theory-tester.json +13 -0
  72. package/.kiro/agents/plan-synthesizer.json +12 -0
  73. package/.kiro/agents/planning-agent.json +12 -0
  74. package/.kiro/agents/plugin-enhancer.json +12 -0
  75. package/.kiro/agents/prompt-enhancer.json +12 -0
  76. package/.kiro/agents/reviewer-perf-test.json +11 -0
  77. package/.kiro/agents/reviewer-quality-security.json +11 -0
  78. package/.kiro/agents/simple-fixer.json +13 -0
  79. package/.kiro/agents/skills-enhancer.json +11 -0
  80. package/.kiro/agents/sync-docs-agent.json +13 -0
  81. package/.kiro/agents/task-discoverer.json +12 -0
  82. package/.kiro/agents/test-coverage-checker.json +12 -0
  83. package/.kiro/agents/web-session.json +12 -0
  84. package/.kiro/agents/worktree-manager.json +13 -0
  85. package/.kiro/skills/consult/SKILL.md +425 -0
  86. package/.kiro/skills/debate/SKILL.md +316 -0
  87. package/.kiro/skills/deslop/SKILL.md +204 -0
  88. package/.kiro/skills/discover-tasks/SKILL.md +297 -0
  89. package/.kiro/skills/drift-analysis/SKILL.md +324 -0
  90. package/.kiro/skills/enhance-agent-prompts/SKILL.md +277 -0
  91. package/.kiro/skills/enhance-claude-memory/SKILL.md +387 -0
  92. package/.kiro/skills/enhance-cross-file/SKILL.md +110 -0
  93. package/.kiro/skills/enhance-docs/SKILL.md +298 -0
  94. package/.kiro/skills/enhance-hooks/SKILL.md +554 -0
  95. package/.kiro/skills/enhance-orchestrator/SKILL.md +255 -0
  96. package/.kiro/skills/enhance-plugins/SKILL.md +319 -0
  97. package/.kiro/skills/enhance-prompts/SKILL.md +340 -0
  98. package/.kiro/skills/enhance-skills/SKILL.md +436 -0
  99. package/.kiro/skills/learn/SKILL.md +349 -0
  100. package/.kiro/skills/orchestrate-review/SKILL.md +260 -0
  101. package/.kiro/skills/perf-analyzer/SKILL.md +37 -0
  102. package/.kiro/skills/perf-baseline-manager/SKILL.md +30 -0
  103. package/.kiro/skills/perf-benchmarker/SKILL.md +52 -0
  104. package/.kiro/skills/perf-code-paths/SKILL.md +32 -0
  105. package/.kiro/skills/perf-investigation-logger/SKILL.md +41 -0
  106. package/.kiro/skills/perf-profiler/SKILL.md +42 -0
  107. package/.kiro/skills/perf-theory-gatherer/SKILL.md +35 -0
  108. package/.kiro/skills/perf-theory-tester/SKILL.md +36 -0
  109. package/.kiro/skills/repo-mapping/SKILL.md +83 -0
  110. package/.kiro/skills/sync-docs/SKILL.md +351 -0
  111. package/.kiro/skills/validate-delivery/SKILL.md +186 -0
  112. package/.kiro/skills/web-auth/SKILL.md +177 -0
  113. package/.kiro/skills/web-browse/SKILL.md +516 -0
  114. package/.kiro/steering/audit-project-agents.md +459 -0
  115. package/.kiro/steering/audit-project-github.md +146 -0
  116. package/.kiro/steering/audit-project.md +330 -0
  117. package/.kiro/steering/consult.md +422 -0
  118. package/.kiro/steering/debate.md +386 -0
  119. package/.kiro/steering/delivery-approval.md +339 -0
  120. package/.kiro/steering/deslop.md +149 -0
  121. package/.kiro/steering/drift-detect.md +264 -0
  122. package/.kiro/steering/enhance.md +177 -0
  123. package/.kiro/steering/learn.md +166 -0
  124. package/.kiro/steering/next-task.md +481 -0
  125. package/.kiro/steering/perf.md +469 -0
  126. package/.kiro/steering/repo-map.md +126 -0
  127. package/.kiro/steering/ship-ci-review-loop.md +473 -0
  128. package/.kiro/steering/ship-deployment.md +353 -0
  129. package/.kiro/steering/ship-error-handling.md +270 -0
  130. package/.kiro/steering/ship.md +522 -0
  131. package/.kiro/steering/sync-docs.md +178 -0
  132. package/.kiro/steering/web-ctl.md +106 -0
  133. package/CHANGELOG.md +15 -0
  134. package/bin/cli.js +2 -2
  135. package/lib/adapter-transforms.js +34 -2
  136. package/package.json +1 -1
  137. package/site/content.json +1 -1
@@ -0,0 +1,297 @@
1
+ ---
2
+ name: discover-tasks
3
+ description: "Use when user asks to \"discover tasks\", \"find next task\", \"prioritize issues\", \"what should I work on\", or \"list open issues\". Discovers and ranks tasks from GitHub, GitLab, local files, and custom sources."
4
+ version: 5.1.1
5
+ allowed-tools: "Bash(gh:*), Bash(glab:*), Bash(git:*), Bash(grep:*), Grep, Read, AskUserQuestion"
6
+ ---
7
+
8
+ # discover-tasks
9
+
10
+ Discover tasks from configured sources, validate them, and present for user selection.
11
+
12
+ ## When to Use
13
+
14
+ Invoked during Phase 2 of `/next-task` workflow, after policy selection. Also usable standalone when the user wants to discover and select tasks from configured sources.
15
+
16
+ ## Workflow
17
+
18
+ ### Phase 1: Load Policy and Claimed Tasks
19
+
20
+ ```javascript
21
+ // Use relative path from skill directory to plugin lib
22
+ // Path: skills/discover-tasks/ -> ../../lib/state/workflow-state.js
23
+ const workflowState = require('../../lib/state/workflow-state.js');
24
+
25
+ const state = workflowState.readState();
26
+ const policy = state.policy;
27
+
28
+ // Load claimed tasks from registry
29
+ const claimedTasks = workflowState.readTasks().tasks || [];
30
+ const claimedIds = new Set(claimedTasks.map(t => t.id));
31
+ ```
32
+
33
+ ### Phase 2: Fetch Tasks by Source
34
+
35
+ **Source types:**
36
+ - `github` / `gh-issues`: GitHub CLI
37
+ - `gh-projects`: GitHub Projects (v2 boards)
38
+ - `gitlab`: GitLab CLI
39
+ - `local` / `tasks-md`: Local markdown files
40
+ - `custom`: CLI/MCP/Skill tool
41
+ - `other`: Agent interprets description
42
+
43
+ **GitHub Issues:**
44
+ ```bash
45
+ # Fetch with pagination awareness
46
+ gh issue list --state open \
47
+ --json number,title,body,labels,assignees,createdAt,url \
48
+ --limit 100 > /tmp/gh-issues.json
49
+ ```
50
+
51
+ **GitLab Issues:**
52
+ ```bash
53
+ glab issue list --state opened --output json --per-page 100 > /tmp/glab-issues.json
54
+ ```
55
+
56
+ **Local tasks.md:**
57
+ ```bash
58
+ for f in PLAN.md tasks.md TODO.md; do
59
+ [ -f "$f" ] && grep -n '^\s*- \[ \]' "$f"
60
+ done
61
+ ```
62
+
63
+ **GitHub Projects (v2):**
64
+ ```javascript
65
+ // Extract gh-projects parameters from policy
66
+ const projectNumber = policy.taskSource.projectNumber;
67
+ const owner = policy.taskSource.owner;
68
+ if (!projectNumber || !owner) {
69
+ throw new Error('gh-projects source missing projectNumber or owner in policy.taskSource');
70
+ }
71
+ ```
72
+
73
+ ```bash
74
+ # Requires 'project' token scope. If permission error: gh auth refresh -s project
75
+ gh project item-list "$PROJECT_NUMBER" --owner "$OWNER" --format json --limit 100 > /tmp/gh-project-items.json
76
+ ```
77
+
78
+ ```javascript
79
+ const fs = require('fs');
80
+ const raw = JSON.parse(fs.readFileSync('/tmp/gh-project-items.json', 'utf8'));
81
+ const items = (raw.items || []);
82
+
83
+ // Filter to ISSUE type only (exclude PULL_REQUEST, DRAFT_ISSUE)
84
+ const issues = items
85
+ .filter(item => item.content && item.content.type === 'ISSUE')
86
+ .map(item => ({
87
+ number: item.content.number,
88
+ title: item.content.title,
89
+ body: item.content.body || '',
90
+ labels: (item.content.labels || []).map(l => typeof l === 'object' ? l.name || '' : l).filter(Boolean),
91
+ url: item.content.url,
92
+ createdAt: item.content.createdAt
93
+ }));
94
+ ```
95
+
96
+ [WARN] If `gh project item-list` returns a permission error, tell the user:
97
+ `Run: gh auth refresh -s project`
98
+
99
+ **Custom Source:**
100
+ ```javascript
101
+ const { sources } = require('../../lib');
102
+ const capabilities = sources.getToolCapabilities(toolName);
103
+ // Execute capabilities.commands.list_issues
104
+ ```
105
+
106
+ ### Phase 2.5: Collect PR-Linked Issues (GitHub only)
107
+
108
+ ```javascript
109
+ // Default for non-GitHub sources - always defined so Phase 3 filter is safe
110
+ let prLinkedIssues = new Set();
111
+ ```
112
+
113
+ For GitHub sources (`policy.taskSource?.source === 'github'`, `'gh-issues'`, or `'gh-projects'`), fetch all open PRs and build a Set of issue numbers that already have an associated PR. Skip to Phase 3 for all other sources.
114
+
115
+ ```bash
116
+ # Only run when policy.taskSource?.source is 'github', 'gh-issues', or 'gh-projects'
117
+ # Note: covers up to 100 open PRs. If repo has more, some linked issues may not be excluded.
118
+ gh pr list --state open --json number,title,body,headRefName --limit 100 > /tmp/gh-prs.json
119
+ ```
120
+
121
+ ```javascript
122
+ const fs = require('fs');
123
+ try {
124
+ const prs = JSON.parse(fs.readFileSync('/tmp/gh-prs.json', 'utf8') || '[]');
125
+
126
+ for (const pr of prs) {
127
+ // 1. Branch name suffix: fix/some-thing-123 extracts 123
128
+ // Note: heuristic - branches like "release-2026" will false-positive on issue #2026.
129
+ // Patterns 2 and 3 are more precise; this is a best-effort supplement.
130
+ const branchMatch = (pr.headRefName || '').match(/-(\d+)$/);
131
+ if (branchMatch) prLinkedIssues.add(branchMatch[1]);
132
+
133
+ // 2. PR body closing keywords (GitHub's full keyword set, with word boundary)
134
+ if (pr.body) {
135
+ const bodyMatches = pr.body.matchAll(/\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)/gi);
136
+ for (const m of bodyMatches) prLinkedIssues.add(m[1]);
137
+ }
138
+
139
+ // 3. PR title (#N) convention - capture all occurrences
140
+ const titleMatches = (pr.title || '').matchAll(/\(#(\d+)\)/g);
141
+ for (const m of titleMatches) prLinkedIssues.add(m[1]);
142
+ }
143
+ } catch (e) {
144
+ console.log('[WARN] Could not parse open PRs, skipping PR-link filter:', e.message);
145
+ prLinkedIssues = new Set();
146
+ }
147
+ ```
148
+
149
+ ### Phase 3: Filter and Score
150
+
151
+ **Exclude claimed tasks:**
152
+ ```javascript
153
+ const available = tasks.filter(t => !claimedIds.has(String(t.number || t.id)));
154
+ ```
155
+
156
+ **Exclude issues with open PRs (GitHub only):**
157
+ ```javascript
158
+ const filtered = available.filter(t => {
159
+ const id = String(t.number || t.id);
160
+ if (prLinkedIssues.has(id)) {
161
+ console.log(`[INFO] Skipping #${id} - already has an open PR`);
162
+ return false;
163
+ }
164
+ return true;
165
+ });
166
+ ```
167
+
168
+ **Apply priority filter** (pass `filtered` through scoring pipeline):
169
+ ```javascript
170
+ const LABEL_MAPS = {
171
+ bugs: ['bug', 'fix', 'error', 'defect'],
172
+ security: ['security', 'vulnerability', 'cve'],
173
+ features: ['enhancement', 'feature', 'improvement']
174
+ };
175
+
176
+ function filterByPriority(tasks, filter) {
177
+ if (filter === 'continue' || filter === 'all') return tasks;
178
+ const targetLabels = LABEL_MAPS[filter] || [];
179
+ return tasks.filter(t => {
180
+ const labels = (t.labels || []).map(l => (l.name || l).toLowerCase());
181
+ return targetLabels.some(target => labels.some(l => l.includes(target)));
182
+ });
183
+ }
184
+
185
+ const prioritized = filterByPriority(filtered, policy.priorityFilter);
186
+ // Assign score to each task so it is available for display in the UI
187
+ const topTasks = prioritized.map(t => ({ ...t, score: scoreTask(t) })).sort((a, b) => b.score - a.score);
188
+ ```
189
+
190
+ **Score tasks:**
191
+ ```javascript
192
+ function scoreTask(task) {
193
+ let score = 0;
194
+ const labels = (task.labels || []).map(l => (l.name || l).toLowerCase());
195
+
196
+ // Priority labels
197
+ if (labels.some(l => l.includes('critical') || l.includes('p0'))) score += 100;
198
+ if (labels.some(l => l.includes('high') || l.includes('p1'))) score += 50;
199
+ if (labels.some(l => l.includes('security'))) score += 40;
200
+
201
+ // Quick wins
202
+ if (labels.some(l => l.includes('small') || l.includes('quick'))) score += 20;
203
+
204
+ // Age (older bugs get priority)
205
+ if (task.createdAt) {
206
+ const ageInDays = (Date.now() - new Date(task.createdAt)) / 86400000;
207
+ if (labels.includes('bug') && ageInDays > 30) score += 10;
208
+ }
209
+
210
+ return score;
211
+ }
212
+ ```
213
+
214
+ ### Phase 4: Present to User via AskUserQuestion
215
+
216
+ **CRITICAL**: Labels MUST be max 30 characters (OpenCode limit).
217
+
218
+ ```javascript
219
+ function truncateLabel(num, title) {
220
+ const prefix = `#${num}: `;
221
+ const maxLen = 30 - prefix.length;
222
+ return title.length > maxLen
223
+ ? prefix + title.substring(0, maxLen - 1) + '...'
224
+ : prefix + title;
225
+ }
226
+
227
+ const options = topTasks.slice(0, 5).map(task => ({
228
+ label: truncateLabel(task.number, task.title),
229
+ description: `Score: ${task.score} | ${(task.labels || []).slice(0, 2).join(', ')}`
230
+ }));
231
+
232
+ AskUserQuestion({
233
+ questions: [{
234
+ header: "Select Task",
235
+ question: "Which task should I work on?",
236
+ options,
237
+ multiSelect: false
238
+ }]
239
+ });
240
+ ```
241
+
242
+ ### Phase 5: Update State
243
+
244
+ ```javascript
245
+ workflowState.updateState({
246
+ task: {
247
+ id: String(selectedTask.number),
248
+ source: policy.taskSource?.source || policy.taskSource,
249
+ title: selectedTask.title,
250
+ description: selectedTask.body || '',
251
+ labels: selectedTask.labels?.map(l => l.name || l) || [],
252
+ url: selectedTask.url
253
+ }
254
+ });
255
+
256
+ workflowState.completePhase({
257
+ tasksAnalyzed: tasks.length,
258
+ selectedTask: selectedTask.number
259
+ });
260
+ ```
261
+
262
+ ### Phase 6: Post Comment (GitHub only)
263
+
264
+ **Skip this phase entirely for non-GitHub sources (GitLab, local, custom).** Run for `github`, `gh-issues`, and `gh-projects` sources.
265
+
266
+ ```bash
267
+ # Only run for GitHub sources (github, gh-issues, gh-projects). Use policy.taskSource?.source from Phase 1 to check.
268
+ gh issue comment "$TASK_ID" --body "[BOT] Workflow started for this issue."
269
+ ```
270
+
271
+ ## Output Format
272
+
273
+ ```markdown
274
+ ## Task Selected
275
+
276
+ **Task**: #{id} - {title}
277
+ **Source**: {source}
278
+ **URL**: {url}
279
+
280
+ Proceeding to worktree setup...
281
+ ```
282
+
283
+ ## Error Handling
284
+
285
+ If no tasks found:
286
+ 1. Suggest creating issues
287
+ 2. Suggest running /audit-project
288
+ 3. Suggest using 'all' priority filter
289
+
290
+ ## Constraints
291
+
292
+ - MUST use AskUserQuestion for task selection (not plain text)
293
+ - Labels MUST be max 30 characters
294
+ - Exclude tasks already claimed by other workflows
295
+ - Exclude issues that already have an open PR (GitHub and GitHub Projects sources)
296
+ - PR-link detection covers up to 100 open PRs (--limit 100 is the fetch cap)
297
+ - Top 5 tasks only
@@ -0,0 +1,324 @@
1
+ ---
2
+ name: drift-analysis
3
+ description: Use when the user asks about plan drift, reality check, comparing docs to code, project state analysis, roadmap alignment, implementation gaps, or needs guidance on identifying discrepancies between documented plans and actual implementation state.
4
+ version: 5.1.0
5
+ ---
6
+
7
+ # Drift Analysis
8
+
9
+ Knowledge and patterns for analyzing project state, detecting plan drift, and creating prioritized reconstruction plans.
10
+
11
+ ## Architecture Overview
12
+
13
+ ```
14
+ /drift-detect
15
+
16
+ ├─→ collectors.js (pure JavaScript)
17
+ │ ├─ scanGitHubState()
18
+ │ ├─ analyzeDocumentation()
19
+ │ └─ scanCodebase()
20
+
21
+ └─→ plan-synthesizer (Opus)
22
+ └─ Deep semantic analysis with full context
23
+ ```
24
+
25
+ **Data collection**: Pure JavaScript (no LLM overhead)
26
+ **Semantic analysis**: Single Opus call with complete context
27
+
28
+ ## Drift Detection Patterns
29
+
30
+ ### Types of Drift
31
+
32
+ **Plan Drift**: When documented plans diverge from actual implementation
33
+ - PLAN.md items remain unchecked for extended periods
34
+ - Roadmap milestones slip without updates
35
+ - Sprint/phase goals not reflected in code changes
36
+
37
+ **Documentation Drift**: When documentation falls behind implementation
38
+ - New features exist without corresponding docs
39
+ - README describes features that don't exist
40
+ - API docs don't match actual endpoints
41
+
42
+ **Issue Drift**: When issue tracking diverges from reality
43
+ - Stale issues that no longer apply
44
+ - Completed work without closed issues
45
+ - High-priority items neglected
46
+
47
+ **Scope Drift**: When project scope expands beyond original plans
48
+ - More features documented than can be delivered
49
+ - Continuous addition without completion
50
+ - Ever-growing backlog with no pruning
51
+
52
+ ### Detection Signals
53
+
54
+ ```
55
+ HIGH-CONFIDENCE DRIFT INDICATORS:
56
+ - Milestone 30+ days overdue with open issues
57
+ - PLAN.md < 30% completion after 90 days
58
+ - 5+ high-priority issues stale > 60 days
59
+ - README features not found in codebase
60
+
61
+ MEDIUM-CONFIDENCE INDICATORS:
62
+ - Documentation files unchanged for 180+ days
63
+ - Draft PRs open > 30 days
64
+ - Issue themes don't match code activity
65
+ - Large gap between documented and implemented features
66
+
67
+ LOW-CONFIDENCE INDICATORS:
68
+ - Many TODOs in codebase
69
+ - Stale dependencies
70
+ - Old git branches not merged
71
+ ```
72
+
73
+ ## Prioritization Framework
74
+
75
+ ### Priority Calculation
76
+
77
+ ```javascript
78
+ function calculatePriority(item, weights) {
79
+ let score = 0;
80
+
81
+ // Severity base score
82
+ const severityScores = {
83
+ critical: 15,
84
+ high: 10,
85
+ medium: 5,
86
+ low: 2
87
+ };
88
+ score += severityScores[item.severity] || 5;
89
+
90
+ // Category multiplier
91
+ const categoryWeights = {
92
+ security: 2.0, // Security issues get 2x
93
+ bugs: 1.5, // Bugs get 1.5x
94
+ infrastructure: 1.3,
95
+ features: 1.0,
96
+ documentation: 0.8
97
+ };
98
+ score *= categoryWeights[item.category] || 1.0;
99
+
100
+ // Recency boost
101
+ if (item.createdRecently) score *= 1.2;
102
+
103
+ // Stale penalty (old items slightly deprioritized)
104
+ if (item.daysStale > 180) score *= 0.9;
105
+
106
+ return Math.round(score);
107
+ }
108
+ ```
109
+
110
+ ### Time Bucket Thresholds
111
+
112
+ | Bucket | Criteria | Max Items |
113
+ |--------|----------|-----------|
114
+ | Immediate | severity=critical OR priority >= 15 | 5 |
115
+ | Short-term | severity=high OR priority >= 10 | 10 |
116
+ | Medium-term | priority >= 5 | 15 |
117
+ | Backlog | everything else | 20 |
118
+
119
+ ### Priority Weights (Default)
120
+
121
+ ```yaml
122
+ security: 10 # Security issues always top priority
123
+ bugs: 8 # Bugs affect users directly
124
+ features: 5 # New functionality
125
+ documentation: 3 # Important but not urgent
126
+ tech-debt: 4 # Keeps codebase healthy
127
+ ```
128
+
129
+ ## Cross-Reference Patterns
130
+
131
+ ### Document-to-Code Matching
132
+
133
+ ```javascript
134
+ // Fuzzy matching for feature names
135
+ function featureMatch(docFeature, codeFeature) {
136
+ const normalize = s => s
137
+ .toLowerCase()
138
+ .replace(/[-_\s]+/g, '')
139
+ .replace(/s$/, ''); // Remove trailing 's'
140
+
141
+ const docNorm = normalize(docFeature);
142
+ const codeNorm = normalize(codeFeature);
143
+
144
+ return docNorm.includes(codeNorm) ||
145
+ codeNorm.includes(docNorm) ||
146
+ levenshteinDistance(docNorm, codeNorm) < 3;
147
+ }
148
+ ```
149
+
150
+ ### Common Mismatches
151
+
152
+ | Documented As | Implemented As |
153
+ |---------------|----------------|
154
+ | "user authentication" | auth/, login/, session/ |
155
+ | "API endpoints" | routes/, api/, handlers/ |
156
+ | "database models" | models/, entities/, schemas/ |
157
+ | "caching layer" | cache/, redis/, memcache/ |
158
+ | "logging system" | logger/, logs/, telemetry/ |
159
+
160
+ ## Output Templates
161
+
162
+ ### Drift Report Section
163
+
164
+ ```markdown
165
+ ## Drift Analysis
166
+
167
+ ### {drift_type}
168
+ **Severity**: {severity}
169
+ **Detected In**: {source}
170
+
171
+ {description}
172
+
173
+ **Evidence**:
174
+ {evidence_items}
175
+
176
+ **Recommendation**: {recommendation}
177
+ ```
178
+
179
+ ### Gap Report Section
180
+
181
+ ```markdown
182
+ ## Gap: {gap_title}
183
+
184
+ **Category**: {category}
185
+ **Severity**: {severity}
186
+
187
+ {description}
188
+
189
+ **Impact**: {impact_description}
190
+
191
+ **To Address**:
192
+ 1. {action_item_1}
193
+ 2. {action_item_2}
194
+ ```
195
+
196
+ ### Reconstruction Plan Section
197
+
198
+ ```markdown
199
+ ## Reconstruction Plan
200
+
201
+ ### Immediate Actions (This Week)
202
+ {immediate_items_numbered}
203
+
204
+ ### Short-Term (This Month)
205
+ {short_term_items_numbered}
206
+
207
+ ### Medium-Term (This Quarter)
208
+ {medium_term_items_numbered}
209
+
210
+ ### Backlog
211
+ {backlog_items_numbered}
212
+ ```
213
+
214
+ ## Best Practices
215
+
216
+ ### When Analyzing Drift
217
+
218
+ 1. **Compare timestamps, not just content**
219
+ - When was the doc last updated vs. last code change?
220
+ - Are milestones dated realistically?
221
+
222
+ 2. **Look for patterns, not individual items**
223
+ - One stale issue isn't drift; 10 stale issues is a pattern
224
+ - One undocumented feature isn't drift; 5 undocumented features is
225
+
226
+ 3. **Consider context**
227
+ - Active development naturally has some drift
228
+ - Mature projects should have minimal drift
229
+ - Post-launch projects often have documentation lag
230
+
231
+ 4. **Weight by impact**
232
+ - User-facing drift matters more than internal
233
+ - Public API drift matters more than implementation details
234
+
235
+ ### When Creating Plans
236
+
237
+ 1. **Be actionable, not exhaustive**
238
+ - Top 5 immediate items, not top 50
239
+ - Each item should be completable in reasonable time
240
+
241
+ 2. **Group related items**
242
+ - "Update authentication docs" not "Update login page docs" + "Update signup docs"
243
+
244
+ 3. **Include success criteria**
245
+ - How do we know this drift item is resolved?
246
+
247
+ 4. **Balance categories**
248
+ - All security first, but don't ignore everything else
249
+ - Mix quick wins with important work
250
+
251
+ ## Data Collection (JavaScript)
252
+
253
+ The collectors.js module extracts data without LLM overhead:
254
+
255
+ ### GitHub Data
256
+ - Open issues categorized by labels
257
+ - Open PRs with draft status
258
+ - Milestones with due dates
259
+ - Stale items (> 90 days inactive)
260
+ - Theme analysis from titles
261
+
262
+ ### Documentation Data
263
+ - Parsed README, PLAN.md, CLAUDE.md, CHANGELOG.md
264
+ - Checkbox completion counts
265
+ - Section analysis
266
+ - Feature lists
267
+
268
+ ### Code Data
269
+ - Directory structure
270
+ - Framework detection
271
+ - Test framework presence
272
+ - Health indicators (CI, linting, tests)
273
+
274
+ ## Semantic Analysis (Opus)
275
+
276
+ The plan-synthesizer receives all collected data and performs:
277
+
278
+ 1. **Cross-referencing**: Match documented features to implementation
279
+ 2. **Drift identification**: Find divergence patterns
280
+ 3. **Gap analysis**: Identify what's missing
281
+ 4. **Prioritization**: Context-aware ranking
282
+ 5. **Report generation**: Actionable recommendations
283
+
284
+ ## Example Input/Output
285
+
286
+ ### Collected Data (from collectors.js)
287
+
288
+ ```json
289
+ {
290
+ "github": {
291
+ "issues": [...],
292
+ "categorized": { "bugs": [...], "features": [...] },
293
+ "stale": [...]
294
+ },
295
+ "docs": {
296
+ "files": { "README.md": {...}, "PLAN.md": {...} },
297
+ "checkboxes": { "total": 15, "checked": 3 }
298
+ },
299
+ "code": {
300
+ "frameworks": ["Express"],
301
+ "health": { "hasTests": true, "hasCi": true }
302
+ }
303
+ }
304
+ ```
305
+
306
+ ### Analysis Output (from plan-synthesizer)
307
+
308
+ ```markdown
309
+ # Reality Check Report
310
+
311
+ ## Executive Summary
312
+ Project has moderate drift: 8 stale priority issues and 20% plan completion.
313
+ Strong code health (tests + CI) but documentation lags implementation.
314
+
315
+ ## Drift Analysis
316
+ ### Priority Neglect
317
+ **Severity**: high
318
+ 8 high-priority issues inactive for 60+ days...
319
+
320
+ ## Prioritized Plan
321
+ ### Immediate
322
+ 1. Close #45 (already implemented)
323
+ 2. Update README API section...
324
+ ```