@hmharness/agent 0.23.49 → 0.23.51
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/prompt.js +1 -1
- package/dist/runner.js +21 -6
- package/dist/tools.js +4 -0
- package/package.json +11 -11
package/dist/prompt.js
CHANGED
|
@@ -31,7 +31,7 @@ export function buildSystemPrompt(opts) {
|
|
|
31
31
|
// ---- Git forge 域(GitHub / AtomGit,2026-10-30 用户特性) ----
|
|
32
32
|
'', '## Git forges (GitHub / AtomGit)', 'Repository operations on GitHub or AtomGit — listing/creating repos, PRs, issues, releases, checking CI — go through the forge_* tools (host: "github" → gh CLI, "atomgit" → ag CLI). Do NOT send the user to the website for anything a forge_* tool can do.', 'Call forge_status first; when a host is not logged in, run forge_login for it (it shows the device code / URL the user must complete in the browser) — do not tell the user to run gh/ag commands by hand.', 'Credentials live in gh/ag\'s own storage and never pass through you: never ask for or store a platform token yourself.',
|
|
33
33
|
// ---- 通用工作风格 ----
|
|
34
|
-
'', 'Working style: read before writing; prefer small focused commands; verify results; state tradeoffs briefly. For risky operations (deleting, overwriting, publishing) say what will happen first. When a command fails twice with the same error, switch strategy instead of repeating it. For multi-line/quoted logic, write a temp .cjs file and run it with node - never fight cmd.exe quoting with node -e one-liners.', '', 'Anti re-verification: when you have already established a fact in this conversation (it is in your earlier text, in the rolling digest, or in a pruned-but-head-visible tool result), state it and move on — do NOT re-run the same search or command to "confirm" it again. Only re-check when you have concrete evidence the situation changed (a file was modified, a command failed differently). Identical re-calls return a cached reminder;
|
|
34
|
+
'', 'Working style: read before writing; prefer small focused commands; verify results; state tradeoffs briefly. For risky operations (deleting, overwriting, publishing) say what will happen first. When a command fails twice with the same error, switch strategy instead of repeating it. For multi-line/quoted logic, write a temp .cjs file and run it with node - never fight cmd.exe quoting with node -e one-liners.', '', 'Anti re-verification: when you have already established a fact in this conversation (it is in your earlier text, in the rolling digest, or in a pruned-but-head-visible tool result), state it and move on — do NOT re-run the same search or command to "confirm" it again. Only re-check when you have concrete evidence the situation changed (a file was modified, a command failed differently). Identical re-calls of read-only tools (read_file, list_dir) return a cached reminder while nothing has changed; commands, edits and every other tool always run for real - after you change anything, re-run to see the fresh result.',
|
|
35
35
|
// ---- [Codex] 最终答复结构(gpt_5_2_prompt "Final answer structure and style guidelines" 的 hmh 压缩版) ----
|
|
36
36
|
'', '## Final answer structure', 'Your reply is standard markdown rendered by both the TUI and the web UI - keep it concise, factual, present tense, active voice; never emit ANSI escapes or literally write "bold"/"monospace".', '- Match length to task size: small change (under ~10 lines) = 2-5 sentences or up to 3 bullets, no header; medium = up to 6 bullets or 6-10 sentences; large = 1-2 bullets per file/area. Never paste large code blocks, whole files, or before/after diffs - cite `path:line` instead, and summarize raw command output down to its key lines rather than reproducing it.', '- Headers only when they help, short (1-3 words, Title Case; a `##` line or a bolded lead-in), no blank line between a header and its first bullet. Bullets start with `- `, one line each, 4-6 per list, related points merged, one topic per bullet, ordered by importance, parallel in wording, never nested. Go general, then specific, then supporting; lead subsections with a bolded-keyword bullet.', '- Backticks for commands, paths, env vars, and code identifiers - never mix backticks with `**` in one span. File references: inline code, each a full standalone path, optional `:line`, no file:// URIs, no line ranges.', '- Answer code changes with what changed in the first sentence, then context; propose next steps only when natural. Be self-contained (no "as above"). Review answers: findings first, ordered by severity, each with `path:line`; then open questions; a short summary last.', '- Greetings, simple confirmations, and single-step operations are plain sentences with zero formatting.', '- For comparisons (2+ items by 2+ attributes) use a markdown table; multi-line code goes in fenced blocks.', '- 中文答复同样适用:短标题(≤6 字)、要点化、先结论后细节;命令/路径/标识保留英文原文与反引号。');
|
|
37
37
|
// ---- AGENTS.md / CLAUDE.md / .cursorrules 注入(被动发现,不需模型主动调用) ----
|
package/dist/runner.js
CHANGED
|
@@ -601,7 +601,17 @@ export async function runAgentTask(opts) {
|
|
|
601
601
|
time: new Date().toISOString(),
|
|
602
602
|
session: session.id,
|
|
603
603
|
task: opts.task.slice(0, 120),
|
|
604
|
-
|
|
604
|
+
// 2026-11-25: use the kernel's own stop reason (the same signal the
|
|
605
|
+
// observability trajectory, the cognitive recorder and the routing
|
|
606
|
+
// backfill already consume above) instead of re-deriving a two-valued
|
|
607
|
+
// "turn-budget"/"ok" from the turn count. The old line made every task
|
|
608
|
+
// that merely finished inside the budget read as "ok", so the impact
|
|
609
|
+
// loop's okRate measured "did not time out", not outcome.
|
|
610
|
+
// SCOPE - honest boundary: reason==='final' means "the model produced a
|
|
611
|
+
// final answer", NOT "the answer is correct". Correctness needs an
|
|
612
|
+
// external verifier; this fix aligns the signal and stops mis-labelling
|
|
613
|
+
// valve/interrupt stops as successes.
|
|
614
|
+
outcome: result.reason === 'final' ? 'ok' : result.reason,
|
|
605
615
|
turns: result.turns,
|
|
606
616
|
toolUses: result.toolUses,
|
|
607
617
|
toolsUsed: [...new Set(toolsUsed)],
|
|
@@ -638,24 +648,30 @@ export async function runAgentTask(opts) {
|
|
|
638
648
|
* journal only; failures never surface into the user's chat. */
|
|
639
649
|
async function triggerBackgroundEvolve(home) {
|
|
640
650
|
try {
|
|
641
|
-
const { runEvolution } = await import('@hmharness/evolution');
|
|
651
|
+
const { buildCaseRunner, runEvolution } = await import('@hmharness/evolution');
|
|
642
652
|
const { defaultConfig, loadConfig, resolveProvider, chat } = await import('@hmharness/kernel');
|
|
643
653
|
const cfg = await loadConfig();
|
|
644
654
|
const provider = resolveProvider(cfg, 'evolve');
|
|
645
655
|
if (!provider.apiKey)
|
|
646
656
|
return; // no provider configured - stay quiet
|
|
647
657
|
const reg = nativeRegistry(0);
|
|
658
|
+
// 2026-11-25 root cause #2: this runner used to drop the skills prompt
|
|
659
|
+
// (its signature ignored the second argument), so the baseline and the
|
|
660
|
+
// candidate got identical messages and the gate compared A against A.
|
|
661
|
+
// Non-tool cases now go through the shared case-runner, which always
|
|
662
|
+
// injects; tool cases pass the prompt into the loop's system prompt.
|
|
663
|
+
const plainRunCase = buildCaseRunner({ chat: (msgs) => chat(provider, msgs) });
|
|
648
664
|
await runEvolution({
|
|
649
665
|
home,
|
|
650
666
|
provider,
|
|
651
|
-
runCase: async (c) => {
|
|
667
|
+
runCase: async (c, skillsPrompt) => {
|
|
652
668
|
if (c.tools) {
|
|
653
669
|
const { buildSystemPrompt } = await import("./prompt.js");
|
|
654
670
|
const res2 = await runLoop({
|
|
655
671
|
provider,
|
|
656
672
|
registry: reg,
|
|
657
673
|
messages: [
|
|
658
|
-
{ role: 'system', content: buildSystemPrompt({ cwd: process.cwd(), home, memory: '', skills: '', insights: '', model: provider.model }) },
|
|
674
|
+
{ role: 'system', content: buildSystemPrompt({ cwd: process.cwd(), home, memory: '', skills: skillsPrompt ?? '', insights: '', model: provider.model }) },
|
|
659
675
|
{ role: 'user', content: c.prompt },
|
|
660
676
|
],
|
|
661
677
|
ctx: { cwd: process.cwd(), home },
|
|
@@ -663,8 +679,7 @@ async function triggerBackgroundEvolve(home) {
|
|
|
663
679
|
});
|
|
664
680
|
return res2.text;
|
|
665
681
|
}
|
|
666
|
-
|
|
667
|
-
return r.message.content ?? '';
|
|
682
|
+
return plainRunCase(c, skillsPrompt ?? '');
|
|
668
683
|
},
|
|
669
684
|
log: () => undefined,
|
|
670
685
|
});
|
package/dist/tools.js
CHANGED
|
@@ -30,6 +30,9 @@ function safePath(p, cwd) {
|
|
|
30
30
|
export const readFileTool = {
|
|
31
31
|
name: 'read_file',
|
|
32
32
|
description: 'Read a text file. Returns the full content (truncated at 60k chars).',
|
|
33
|
+
// read-only: the loop may dedup an exact repeat, and only until something
|
|
34
|
+
// changes the world (readOnly on Tool, kernel/loop.ts)
|
|
35
|
+
readOnly: true,
|
|
33
36
|
parameters: {
|
|
34
37
|
type: 'object',
|
|
35
38
|
properties: { path: { type: 'string', description: 'file path (absolute or relative to cwd)' } },
|
|
@@ -137,6 +140,7 @@ export const editFileTool = {
|
|
|
137
140
|
export const listDirTool = {
|
|
138
141
|
name: 'list_dir',
|
|
139
142
|
description: 'List a directory: names with d/- prefix and size.',
|
|
143
|
+
readOnly: true,
|
|
140
144
|
parameters: {
|
|
141
145
|
type: 'object',
|
|
142
146
|
properties: { path: { type: 'string', description: 'directory path (default cwd)' } },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/agent",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.51",
|
|
4
4
|
"description": "hmharness agent execution layer: base tools, system prompt, sub-agent spawn, and the shared task runner that frontends (cli, web) drive.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
"build": "tsc -p tsconfig.build.json"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@hmharness/cognitive": "0.23.
|
|
19
|
-
"@hmharness/domain-harmony": "0.23.
|
|
20
|
-
"@hmharness/domain-ops": "0.23.
|
|
21
|
-
"@hmharness/evolution": "0.23.
|
|
22
|
-
"@hmharness/kernel": "0.23.
|
|
23
|
-
"@hmharness/observability": "0.23.
|
|
24
|
-
"@hmharness/sandbox": "0.23.
|
|
25
|
-
"@hmharness/lsp": "0.23.
|
|
26
|
-
"@hmharness/browser": "0.23.
|
|
27
|
-
"@hmharness/extension": "0.23.
|
|
18
|
+
"@hmharness/cognitive": "0.23.51",
|
|
19
|
+
"@hmharness/domain-harmony": "0.23.51",
|
|
20
|
+
"@hmharness/domain-ops": "0.23.51",
|
|
21
|
+
"@hmharness/evolution": "0.23.51",
|
|
22
|
+
"@hmharness/kernel": "0.23.51",
|
|
23
|
+
"@hmharness/observability": "0.23.51",
|
|
24
|
+
"@hmharness/sandbox": "0.23.51",
|
|
25
|
+
"@hmharness/lsp": "0.23.51",
|
|
26
|
+
"@hmharness/browser": "0.23.51",
|
|
27
|
+
"@hmharness/extension": "0.23.51"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"dist"
|