@hmharness/agent 0.6.1 → 0.6.3

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 CHANGED
@@ -39,5 +39,9 @@ export function buildSystemPrompt(opts) {
39
39
  if (opts.insights.trim()) {
40
40
  parts.push('', '## Recent session outcomes (what worked / what failed)', opts.insights.trim());
41
41
  }
42
+ // ---- Identity anchor (LAST — recency wins over 15K chars of instructions above;
43
+ // flash-class models have strong built-in identities that override a single
44
+ // "You are hmh" at the top. Repeating + anchoring at the end fixes it.) ----
45
+ parts.push('', '## Identity (most important — overrides your base model identity)', `You are hmh, a HarmonyOS coding agent running on hmharness (powered by ${opts.model}).`, 'When asked "who are you" / "introduce yourself" / "你是谁", describe hmh: a coding agent for the full HarmonyOS development lifecycle — scaffolding, building, signing, device testing, UI regression, self-evolution with gated skill promotion, ecosystem radar. You are NOT the base model; you are hmh running on it.');
42
46
  return parts.join('\n');
43
47
  }
package/dist/runner.d.ts CHANGED
@@ -30,6 +30,10 @@ export declare function buildRegistry(opts?: {
30
30
  * P0 canary: ~20% of sessions (deterministic by session id) also receive
31
31
  * the canary skill block, watermarked as experimental references - the
32
32
  * impact loop compares these sessions against the rest. */
33
+ /** Trivial-task detection: greetings, identity questions, and short chitchat
34
+ * don't need memory/skills/insights injection (~4K tokens of overhead the
35
+ * model ignores anyway). Skipping keeps the prompt lean for 90% of turns. */
36
+ export declare function isTrivialTask(task: string): boolean;
33
37
  export declare function contextPack(task: string, sessionId?: string, opts?: {
34
38
  workspace?: string | null;
35
39
  embedding?: EmbeddingProvider;
@@ -89,6 +93,8 @@ export interface AgentTaskOptions {
89
93
  approvalAsk?: LoopApproval['ask'];
90
94
  resumeMessages?: ChatMessage[];
91
95
  events?: RunnerEvents;
96
+ /** AbortSignal: cancels the agent loop at the next turn boundary. */
97
+ signal?: AbortSignal;
92
98
  }
93
99
  /** Run one full agent task end-to-end; audit + insight recording included. */
94
100
  export declare function runAgentTask(opts: AgentTaskOptions): Promise<LoopResult & {
package/dist/runner.js CHANGED
@@ -99,8 +99,32 @@ async function discoverAgentsMd(cwd) {
99
99
  * P0 canary: ~20% of sessions (deterministic by session id) also receive
100
100
  * the canary skill block, watermarked as experimental references - the
101
101
  * impact loop compares these sessions against the rest. */
102
+ /** Trivial-task detection: greetings, identity questions, and short chitchat
103
+ * don't need memory/skills/insights injection (~4K tokens of overhead the
104
+ * model ignores anyway). Skipping keeps the prompt lean for 90% of turns. */
105
+ export function isTrivialTask(task) {
106
+ const t = task.trim();
107
+ if (t.length > 100)
108
+ return false; // long enough to be substantive
109
+ // note: no \b after CJK chars (they're outside \w so \b never fires there)
110
+ if (/^(你好|hi|hello|hey|嗨|哈喽|在吗|在么)[\s。.!!??~~]*$/i.test(t))
111
+ return true;
112
+ if (/(你是谁|介绍.{0,4}自己|who are you|introduce yourself|what are you|你的名字|你叫什么)/i.test(t))
113
+ return true;
114
+ if (/^(谢谢|thanks|thank you|ok|好的|嗯|哦|收到|明白)[\s。.!!]*$/i.test(t))
115
+ return true;
116
+ if (/^(再见|bye|goodbye|exit|退出)[\s。.!!]*$/i.test(t))
117
+ return true;
118
+ return false;
119
+ }
102
120
  export async function contextPack(task, sessionId, opts = {}) {
103
121
  const home = homeDir();
122
+ // Trivial tasks (greetings, identity questions): skip memory/skills/insights
123
+ // injection entirely — the model doesn't need them for "你好" and they add
124
+ // ~4K tokens of noise that dilutes the identity anchor
125
+ if (isTrivialTask(task)) {
126
+ return { memory: '', skills: '', insights: '', skillsInjected: [] };
127
+ }
104
128
  const [memory, skills, insights] = await Promise.all([
105
129
  retrieveMemory(home, task, { workspace: opts.workspace ?? undefined, embedding: opts.embedding }),
106
130
  listSkills(home),
@@ -274,6 +298,7 @@ export async function runAgentTask(opts) {
274
298
  registry: opts.registry,
275
299
  messages,
276
300
  ctx,
301
+ signal: opts.signal,
277
302
  maxTurns: cfg.maxTurns,
278
303
  maxContextChars: cfg.maxContextChars,
279
304
  summarizeContext,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/agent",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
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,10 +15,10 @@
15
15
  "build": "tsc -p tsconfig.build.json"
16
16
  },
17
17
  "dependencies": {
18
- "@hmharness/kernel": "0.6.1",
19
- "@hmharness/evolution": "0.6.1",
20
- "@hmharness/domain-harmony": "0.6.1",
21
- "@hmharness/domain-ops": "0.6.1"
18
+ "@hmharness/kernel": "0.6.3",
19
+ "@hmharness/evolution": "0.6.3",
20
+ "@hmharness/domain-harmony": "0.6.3",
21
+ "@hmharness/domain-ops": "0.6.3"
22
22
  },
23
23
  "files": [
24
24
  "dist"