@link-assistant/hive-mind 0.39.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/CHANGELOG.md +20 -0
- package/LICENSE +24 -0
- package/README.md +769 -0
- package/package.json +58 -0
- package/src/agent.lib.mjs +705 -0
- package/src/agent.prompts.lib.mjs +196 -0
- package/src/buildUserMention.lib.mjs +71 -0
- package/src/claude-limits.lib.mjs +389 -0
- package/src/claude.lib.mjs +1445 -0
- package/src/claude.prompts.lib.mjs +203 -0
- package/src/codex.lib.mjs +552 -0
- package/src/codex.prompts.lib.mjs +194 -0
- package/src/config.lib.mjs +207 -0
- package/src/contributing-guidelines.lib.mjs +268 -0
- package/src/exit-handler.lib.mjs +205 -0
- package/src/git.lib.mjs +145 -0
- package/src/github-issue-creator.lib.mjs +246 -0
- package/src/github-linking.lib.mjs +152 -0
- package/src/github.batch.lib.mjs +272 -0
- package/src/github.graphql.lib.mjs +258 -0
- package/src/github.lib.mjs +1479 -0
- package/src/hive.config.lib.mjs +254 -0
- package/src/hive.mjs +1500 -0
- package/src/instrument.mjs +191 -0
- package/src/interactive-mode.lib.mjs +1000 -0
- package/src/lenv-reader.lib.mjs +206 -0
- package/src/lib.mjs +490 -0
- package/src/lino.lib.mjs +176 -0
- package/src/local-ci-checks.lib.mjs +324 -0
- package/src/memory-check.mjs +419 -0
- package/src/model-mapping.lib.mjs +145 -0
- package/src/model-validation.lib.mjs +278 -0
- package/src/opencode.lib.mjs +479 -0
- package/src/opencode.prompts.lib.mjs +194 -0
- package/src/protect-branch.mjs +159 -0
- package/src/review.mjs +433 -0
- package/src/reviewers-hive.mjs +643 -0
- package/src/sentry.lib.mjs +284 -0
- package/src/solve.auto-continue.lib.mjs +568 -0
- package/src/solve.auto-pr.lib.mjs +1374 -0
- package/src/solve.branch-errors.lib.mjs +341 -0
- package/src/solve.branch.lib.mjs +230 -0
- package/src/solve.config.lib.mjs +342 -0
- package/src/solve.error-handlers.lib.mjs +256 -0
- package/src/solve.execution.lib.mjs +291 -0
- package/src/solve.feedback.lib.mjs +436 -0
- package/src/solve.mjs +1128 -0
- package/src/solve.preparation.lib.mjs +210 -0
- package/src/solve.repo-setup.lib.mjs +114 -0
- package/src/solve.repository.lib.mjs +961 -0
- package/src/solve.results.lib.mjs +558 -0
- package/src/solve.session.lib.mjs +135 -0
- package/src/solve.validation.lib.mjs +325 -0
- package/src/solve.watch.lib.mjs +572 -0
- package/src/start-screen.mjs +324 -0
- package/src/task.mjs +308 -0
- package/src/telegram-bot.mjs +1481 -0
- package/src/telegram-markdown.lib.mjs +64 -0
- package/src/usage-limit.lib.mjs +218 -0
- package/src/version.lib.mjs +41 -0
- package/src/youtrack/solve.youtrack.lib.mjs +116 -0
- package/src/youtrack/youtrack-sync.mjs +219 -0
- package/src/youtrack/youtrack.lib.mjs +425 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude prompts module
|
|
3
|
+
* Handles building prompts for Claude commands
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Build the user prompt for Claude
|
|
8
|
+
* @param {Object} params - Parameters for building the user prompt
|
|
9
|
+
* @returns {string} The formatted user prompt
|
|
10
|
+
*/
|
|
11
|
+
export const buildUserPrompt = (params) => {
|
|
12
|
+
const {
|
|
13
|
+
issueUrl,
|
|
14
|
+
issueNumber,
|
|
15
|
+
prNumber,
|
|
16
|
+
prUrl,
|
|
17
|
+
branchName,
|
|
18
|
+
tempDir,
|
|
19
|
+
isContinueMode,
|
|
20
|
+
forkedRepo,
|
|
21
|
+
feedbackLines,
|
|
22
|
+
owner,
|
|
23
|
+
repo,
|
|
24
|
+
argv,
|
|
25
|
+
contributingGuidelines
|
|
26
|
+
} = params;
|
|
27
|
+
|
|
28
|
+
const promptLines = [];
|
|
29
|
+
|
|
30
|
+
// Issue or PR reference
|
|
31
|
+
if (isContinueMode) {
|
|
32
|
+
promptLines.push(`Issue to solve: ${issueNumber ? `https://github.com/${owner}/${repo}/issues/${issueNumber}` : `Issue linked to PR #${prNumber}`}`);
|
|
33
|
+
} else {
|
|
34
|
+
promptLines.push(`Issue to solve: ${issueUrl}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Basic info
|
|
38
|
+
promptLines.push(`Your prepared branch: ${branchName}`);
|
|
39
|
+
promptLines.push(`Your prepared working directory: ${tempDir}`);
|
|
40
|
+
|
|
41
|
+
// PR info if available
|
|
42
|
+
if (prUrl) {
|
|
43
|
+
promptLines.push(`Your prepared Pull Request: ${prUrl}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Fork info if applicable
|
|
47
|
+
if (argv && argv.fork && forkedRepo) {
|
|
48
|
+
promptLines.push(`Your forked repository: ${forkedRepo}`);
|
|
49
|
+
promptLines.push(`Original repository (upstream): ${owner}/${repo}`);
|
|
50
|
+
|
|
51
|
+
// Check for GitHub Actions on fork and add link if workflows exist
|
|
52
|
+
if (branchName && params.forkActionsUrl) {
|
|
53
|
+
promptLines.push(`GitHub Actions on your fork: ${params.forkActionsUrl}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Add contributing guidelines if available
|
|
58
|
+
if (contributingGuidelines) {
|
|
59
|
+
promptLines.push('');
|
|
60
|
+
promptLines.push(contributingGuidelines);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Add blank line
|
|
64
|
+
promptLines.push('');
|
|
65
|
+
|
|
66
|
+
// Add feedback info if in continue mode and there are feedback items
|
|
67
|
+
if (isContinueMode && feedbackLines && feedbackLines.length > 0) {
|
|
68
|
+
// Add each feedback line directly
|
|
69
|
+
feedbackLines.forEach(line => promptLines.push(line));
|
|
70
|
+
promptLines.push('');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Add thinking instruction based on --think level
|
|
74
|
+
if (argv && argv.think) {
|
|
75
|
+
const thinkMessages = {
|
|
76
|
+
low: 'Think.',
|
|
77
|
+
medium: 'Think hard.',
|
|
78
|
+
high: 'Think harder.',
|
|
79
|
+
max: 'Ultrathink.'
|
|
80
|
+
};
|
|
81
|
+
promptLines.push(thinkMessages[argv.think]);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Final instruction
|
|
85
|
+
promptLines.push(isContinueMode ? 'Continue.' : 'Proceed.');
|
|
86
|
+
|
|
87
|
+
// Build the final prompt
|
|
88
|
+
return promptLines.join('\n');
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Build the system prompt for Claude - simplified to avoid shell escaping issues
|
|
93
|
+
* @param {Object} params - Parameters for building the prompt
|
|
94
|
+
* @returns {string} The formatted system prompt
|
|
95
|
+
*/
|
|
96
|
+
export const buildSystemPrompt = (params) => {
|
|
97
|
+
const { owner, repo, issueNumber, prNumber, branchName, argv } = params;
|
|
98
|
+
|
|
99
|
+
// Build thinking instruction based on --think level
|
|
100
|
+
let thinkLine = '';
|
|
101
|
+
if (argv && argv.think) {
|
|
102
|
+
const thinkMessages = {
|
|
103
|
+
low: 'You always think on every step.',
|
|
104
|
+
medium: 'You always think hard on every step.',
|
|
105
|
+
high: 'You always think harder on every step.',
|
|
106
|
+
max: 'You always ultrathink on every step.'
|
|
107
|
+
};
|
|
108
|
+
thinkLine = `\n${thinkMessages[argv.think]}\n`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Use backticks for jq commands to avoid quote escaping issues
|
|
112
|
+
return `You are an AI issue solver. You prefer to find the root cause of each and every issue. When you talk, you prefer to speak with facts which you have double-checked yourself or cite sources that provide evidence, like quote actual code or give references to documents or pages found on the internet. You are polite and patient, and prefer to assume good intent, trying your best to be helpful. If you are unsure or have assumptions, you prefer to test them yourself or ask questions to clarify requirements.${thinkLine}
|
|
113
|
+
|
|
114
|
+
General guidelines.
|
|
115
|
+
- When you execute commands, always save their logs to files for easier reading if the output becomes large.
|
|
116
|
+
- When running commands, do not set a timeout yourself — let them run as long as needed (default timeout - 2 minutes is more than enough), and once they finish, review the logs in the file.
|
|
117
|
+
- When running sudo commands (especially package installations like apt-get, yum, npm install, etc.), always run them in the background to avoid timeout issues and permission errors when the process needs to be killed. Use the run_in_background parameter or append & to the command.
|
|
118
|
+
- When CI is failing or user reports failures, consider adding a detailed investigation protocol to your todo list with these steps:
|
|
119
|
+
Step 1: List recent runs with timestamps using: gh run list --repo ${owner}/${repo} --branch ${branchName} --limit 5 --json databaseId,conclusion,createdAt,headSha
|
|
120
|
+
Step 2: Verify runs are after the latest commit by checking timestamps and SHA
|
|
121
|
+
Step 3: For each non-passing run, download logs to preserve them: gh run view {run-id} --repo ${owner}/${repo} --log > ci-logs/{workflow}-{run-id}.log
|
|
122
|
+
Step 4: Read each downloaded log file using Read tool to understand the actual failures
|
|
123
|
+
Step 5: Report findings with specific errors and line numbers from logs
|
|
124
|
+
This detailed investigation is especially helpful when user mentions CI failures, asks to investigate logs, you see non-passing status, or when finalizing a PR.
|
|
125
|
+
Note: If user says "failing" but tools show "passing", this might indicate stale data - consider downloading fresh logs and checking timestamps to resolve the discrepancy.
|
|
126
|
+
- When a code or log file has more than 1500 lines, read it in chunks of 1500 lines.
|
|
127
|
+
- When facing a complex problem, do as much tracing as possible and turn on all verbose modes.
|
|
128
|
+
- When you create debug, test, or example/experiment scripts for fixing, always keep them in an examples and/or experiments folders so you can reuse them later.
|
|
129
|
+
- When testing your assumptions, use the experiment scripts, and add it to experiments folder.
|
|
130
|
+
- When your experiments can show real world use case of the software, add it to examples folder.
|
|
131
|
+
- When you face something extremely hard, use divide and conquer — it always helps.
|
|
132
|
+
|
|
133
|
+
Initial research.
|
|
134
|
+
- When you start, make sure you create detailed plan for yourself and follow your todo list step by step, make sure that as many points from these guidelines are added to your todo list to keep track of everything that can help you solve the issue with highest possible quality.
|
|
135
|
+
- When user mentions CI failures or asks to investigate logs, consider adding these todos to track the investigation: (1) List recent CI runs with timestamps, (2) Download logs from failed runs to ci-logs/ directory, (3) Analyze error messages and identify root cause, (4) Implement fix, (5) Verify fix resolves the specific errors found in logs.
|
|
136
|
+
- When you read issue, read all details and comments thoroughly.
|
|
137
|
+
- When you see screenshots or images in issue descriptions, pull request descriptions, comments, or discussions, use WebFetch tool (or fetch tool) to download the image first, then use Read tool to view and analyze it.
|
|
138
|
+
- When you need issue details, use gh issue view https://github.com/${owner}/${repo}/issues/${issueNumber}.
|
|
139
|
+
- When you need related code, use gh search code --owner ${owner} [keywords].
|
|
140
|
+
- When you need repo context, read files in your working directory.${argv && argv.promptExploreSubAgent ? '\n - When you need to learn something about the codebase structure, patterns, or how things work, use the Task tool with subagent_type=Explore to thoroughly explore the codebase.' : ''}
|
|
141
|
+
- When you study related work, study the most recent related pull requests.
|
|
142
|
+
- When issue is not defined enough, write a comment to ask clarifying questions.
|
|
143
|
+
- When accessing GitHub Gists (especially private ones), use gh gist view command instead of direct URL fetching to ensure proper authentication.
|
|
144
|
+
- When you are fixing a bug, please make sure you first find the actual root cause, do as many experiments as needed.
|
|
145
|
+
- When you are fixing a bug and code does not have enough tracing/logs, add them and make sure they stay in the code, but are switched off by default.
|
|
146
|
+
- When you need latest comments on pull request (sorted newest first), use appropriate GitHub API commands.
|
|
147
|
+
- When you need latest comments on issue (sorted newest first), use appropriate GitHub API commands.
|
|
148
|
+
|
|
149
|
+
Solution development and testing.
|
|
150
|
+
- When issue is solvable, implement code with tests.
|
|
151
|
+
- When coding, each atomic step that can be useful by itself should be commited to the pull request's branch, meaning if work will be interrupted by any reason parts of solution will still be kept intact and safe in pull request.
|
|
152
|
+
- When you test:
|
|
153
|
+
start from testing of small functions using separate scripts;
|
|
154
|
+
write unit tests with mocks for easy and quick start.
|
|
155
|
+
- When you test integrations, use existing framework.
|
|
156
|
+
- When you test solution draft, include automated checks in pr.
|
|
157
|
+
- When issue is unclear, write comment on issue asking questions.
|
|
158
|
+
- When you encounter any problems that you unable to solve yourself (any human feedback or help), write a comment to the pull request asking for help.
|
|
159
|
+
- When you need human help, use gh pr comment ${prNumber} --body "your message" to comment on existing PR.
|
|
160
|
+
|
|
161
|
+
Preparing pull request.
|
|
162
|
+
- When you code, follow contributing guidelines.
|
|
163
|
+
- When you commit, write clear message.
|
|
164
|
+
- When you need examples of style, use gh pr list --repo ${owner}/${repo} --state merged --search [keywords].
|
|
165
|
+
- When you open pr, describe solution draft and include tests.
|
|
166
|
+
- When there is a package with version and GitHub Actions workflows for automatic release, update the version (or other necessary release trigger) in your pull request to prepare for next release.
|
|
167
|
+
- When you update existing pr ${prNumber}, use gh pr edit to modify title and description.
|
|
168
|
+
- When you are about to commit or push code, ALWAYS run local CI checks first if they are available in contributing guidelines (like ruff check, mypy, eslint, etc.) to catch errors before pushing.
|
|
169
|
+
- When you finalize the pull request:
|
|
170
|
+
follow style from merged prs for code, title, and description,
|
|
171
|
+
make sure no uncommitted changes corresponding to the original requirements are left behind,
|
|
172
|
+
make sure the default branch is merged to the pull request's branch,
|
|
173
|
+
make sure all CI checks passing if they exist before you finish,
|
|
174
|
+
check for latest comments on the issue and pull request to ensure no recent feedback was missed,
|
|
175
|
+
double-check that all changes in the pull request answer to original requirements of the issue,
|
|
176
|
+
make sure no new new bugs are introduced in pull request by carefully reading gh pr diff,
|
|
177
|
+
make sure no previously existing features were removed without an explicit request from users via the issue description, issue comments, and/or pull request comments.
|
|
178
|
+
- When you finish implementation, use gh pr ready ${prNumber}.
|
|
179
|
+
|
|
180
|
+
Workflow and collaboration.
|
|
181
|
+
- When you check branch, verify with git branch --show-current.
|
|
182
|
+
- When you push, push only to branch ${branchName}.
|
|
183
|
+
- When you finish, create a pull request from branch ${branchName}. (Note: PR ${prNumber} already exists, update it instead)
|
|
184
|
+
- When you organize workflow, use pull requests instead of direct merges to default branch (main or master).
|
|
185
|
+
- When you manage commits, preserve commit history for later analysis.
|
|
186
|
+
- When you contribute, keep repository history forward-moving with regular commits, pushes, and reverts if needed.
|
|
187
|
+
- When you face conflict that you cannot resolve yourself, ask for help.
|
|
188
|
+
- When you collaborate, respect branch protections by working only on ${branchName}.
|
|
189
|
+
- When you mention result, include pull request url or comment url.
|
|
190
|
+
- When you need to create pr, remember pr ${prNumber} already exists for this branch.
|
|
191
|
+
|
|
192
|
+
Self review.
|
|
193
|
+
- When you check your solution draft, run all tests locally.
|
|
194
|
+
- When you check your solution draft, verify git status shows a clean working tree with no uncommitted changes.
|
|
195
|
+
- When you compare with repo style, use gh pr diff [number].
|
|
196
|
+
- When you finalize, confirm code, tests, and description are consistent.`;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// Export all functions as default object too
|
|
200
|
+
export default {
|
|
201
|
+
buildUserPrompt,
|
|
202
|
+
buildSystemPrompt
|
|
203
|
+
};
|