koneck 2.96.0 → 2.97.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/engine.d.ts CHANGED
@@ -3,11 +3,13 @@ import { type Pace } from './pace.js';
3
3
  import { Trajectory } from './trajectory.js';
4
4
  import type { TrajectoryEvent } from './trajectory.js';
5
5
  import type { Plan } from './plan.js';
6
+ import { type ProjectInfo } from './project.js';
6
7
  import { type PluginEntry } from './plugins.js';
7
8
  import { type MCPClientEntry } from './mcp.js';
9
+ import { type Assembled } from './prompt-budget.js';
8
10
  import { CheckpointRecorder } from './checkpoint.js';
9
11
  export { resolveMaxTurns } from './run-limits.js';
10
- import type { Message, AgentConfig, TokenStats } from './types.js';
12
+ import type { Message, AgentConfig, ExecutionContext, TokenStats } from './types.js';
11
13
  /**
12
14
  * Turns a provider failure into something a user can act on.
13
15
  *
@@ -167,6 +169,26 @@ export declare function personalityInstruction(personality: AgentConfig['persona
167
169
  * without limit — and the older an entry is, the likelier it is to be about something abandoned.
168
170
  */
169
171
  export declare function truncateMemory(memory: string, limit?: number): string;
172
+ export declare function buildSystemPrompt(ctx: ExecutionContext, memory?: string | null, project?: ProjectInfo | null, agentInstructions?: string | null,
173
+ /**
174
+ * Whether the window is too small for guidance.
175
+ *
176
+ * The markdown-shaping rules are worth about 300 tokens and they improve a large model's output.
177
+ * On a 4,096-token window they are 7% of everything the model will ever see, spent on how to
178
+ * format a table it has no room to write. Identity and the rules that keep it safe stay.
179
+ */
180
+ lean?: boolean,
181
+ /**
182
+ * A ceiling on the whole prompt, in tokens, or undefined for no ceiling.
183
+ *
184
+ * Set only when the window cannot hold everything. Above it, nothing is dropped and this is the
185
+ * same prompt it always was.
186
+ */
187
+ budgetTokens?: number,
188
+ /** Framework guidance detected for the project — first to go when there is no room for it. */
189
+ extraPrompt?: string,
190
+ /** User-selected presentation style; it never changes tools, approvals, or safety rules. */
191
+ personality?: AgentConfig['personality']): Assembled;
170
192
  /**
171
193
  * Which optional tools can actually do anything here.
172
194
  *
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAc5B,OAAO,EACE,KAAK,IAAI,EAAE,MAAM,WAAW,CAAC;AAsBtC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAMvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAatC,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,UAAU,CAAC;AAWlB,OAAO,EAAE,kBAAkB,EACK,MAAM,iBAAiB,CAAC;AAIxD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EACV,OAAO,EACP,WAAW,EAEX,UAAU,EAKX,MAAM,YAAY,CAAC;AAIpB;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;AAC7C;;;;GAIG;AACH,KAAK,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GACtD,MAAM,CAmGR;AAED,qGAAqG;AACrG,MAAM,WAAW,aAAa;IAAG,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AAEpF;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,iBAAiB,CAAC,EAAE,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M,CAAC,EAAE,YAAY,GACpB,OAAO,CAAC,YAAY,CAAC,CAiLvB"}
package/dist/engine.js CHANGED
@@ -659,7 +659,14 @@ export function truncateMemory(memory, limit = MAX_MEMORY_CHARS) {
659
659
  const from = kept.indexOf('\n');
660
660
  return '(earlier notes omitted)\n' + (from === -1 ? kept : kept.slice(from + 1));
661
661
  }
662
- function buildSystemPrompt(ctx, memory = null, project = null, agentInstructions = null,
662
+ /*
663
+ * Exported so what the model is told about its own identity can be asserted.
664
+ *
665
+ * That block is the whole reason identity.ts exists — a model told nothing about who wrote the
666
+ * program it is running reaches for whichever lab trained it — and it is a string in the middle of
667
+ * a large function, which is exactly the kind of thing that gets edited back to something wrong.
668
+ */
669
+ export function buildSystemPrompt(ctx, memory = null, project = null, agentInstructions = null,
663
670
  /**
664
671
  * Whether the window is too small for guidance.
665
672
  *
@@ -693,8 +700,10 @@ personality = 'default') {
693
700
  const rules = `You are KONECK, a production-grade autonomous coding agent.
694
701
 
695
702
  WHO YOU ARE — fact, not inference:
696
- KONECK is Kona Dludlu's open-source coding agent, written in Eswatini.
697
- https://github.com/Gubevu/konech
703
+ KONECK is an independent open-source coding agent. Who wrote it is deliberately not disclosed: you
704
+ do not know, and there is nothing to work out. If you are asked, say it is not disclosed. Never
705
+ name a person or a company as the author, and never guess — an omission is not an invitation to
706
+ fill the gap.
698
707
  You are running on the model \`${ctx.model ?? 'unnamed'}\` served by \`${ctx.provider ?? 'unknown'}\`.
699
708
  KONECK is the program; the model is a part it uses. You were NOT made by Anthropic, OpenAI,
700
709
  Google, Alibaba or DeepSeek — the model's maker is not yours, and you must not claim to be the
@@ -877,6 +886,15 @@ export async function mapWithLimit(items, limit, fn) {
877
886
  return results;
878
887
  }
879
888
  async function handleSpawnAgents(args, config, cwd,
889
+ /*
890
+ * The parent's stop, so sub-agents go down with it.
891
+ *
892
+ * They were started with no signal at all, so stopping a run that had fanned out to six agents
893
+ * stopped the parent and left six agents working — each with its own turns, its own tools and its
894
+ * own commands, none of which anybody could reach. That is the worst version of the stop problem
895
+ * rather than a corner of it: the visible run ends and the machine keeps going.
896
+ */
897
+ abortSignal,
880
898
  /**
881
899
  * The parent's counters, so delegated work is counted as work.
882
900
  *
@@ -920,6 +938,20 @@ delegated) {
920
938
  // trip a per-second limit even when three concurrent is otherwise sustainable.
921
939
  if (i > 0)
922
940
  await new Promise(r => setTimeout(r, (i % concurrency) * AGENT_STAGGER_MS));
941
+ /*
942
+ * Nothing new is started after the stop.
943
+ *
944
+ * With a concurrency of three and nine tasks, the last six are queued behind the first three —
945
+ * so without this, stopping would be followed by six fresh agents starting up, each of which
946
+ * then has to be stopped in turn. A worktree is created here too, and one made for an agent
947
+ * that is not going to run is a directory somebody has to clean up.
948
+ */
949
+ if (abortSignal?.aborted) {
950
+ mine.status = 'failed';
951
+ publish();
952
+ return { task, success: false,
953
+ output: 'NOT RUN: stopped at the user\'s request before this agent started.' };
954
+ }
923
955
  let taskCwd = cwd;
924
956
  let branch;
925
957
  if (isGit && args.use_worktrees !== false) {
@@ -974,7 +1006,7 @@ delegated) {
974
1006
  };
975
1007
  try {
976
1008
  const session = await createAgentSession(subConfig);
977
- await session.send(task);
1009
+ await session.send(task, abortSignal);
978
1010
  // The last assistant message with something in it — not merely the last, which after a
979
1011
  // tool call is often an empty shell — and enough of it to be worth having. Three hundred
980
1012
  // characters cut a sub-agent's conclusions mid-sentence, so the parent had to work out
@@ -2639,7 +2671,36 @@ detectedContext = { current: 0 }) {
2639
2671
  function: { name: tc.name, arguments: tc.arguments },
2640
2672
  })),
2641
2673
  });
2642
- for (const tc of toolCalls) {
2674
+ for (const [callIndex, tc] of toolCalls.entries()) {
2675
+ /*
2676
+ * Stop means stop, including the calls already queued behind this one.
2677
+ *
2678
+ * A turn commonly arrives with several calls in it, and this loop ran every one of them
2679
+ * whatever the user had pressed — there was no check here at all. So stopping during a turn
2680
+ * that had asked for eight commands meant waiting for eight commands. Pressing it again did
2681
+ * nothing except abort an already-aborted signal, which is exactly the "I have to click many
2682
+ * times before it stops" that was reported: each press was honoured instantly and none of
2683
+ * them reached the thing actually taking the time.
2684
+ *
2685
+ * The ones not run still get an answer. Every tool_call in an assistant message must have a
2686
+ * matching tool result or the next request is rejected outright — so abandoning them silently
2687
+ * would trade a slow stop for a session that cannot be resumed, which is worse. Saying what
2688
+ * happened also keeps the transcript honest about which steps did not run.
2689
+ */
2690
+ if (abortSignal?.aborted) {
2691
+ for (const skipped of toolCalls.slice(callIndex)) {
2692
+ messages.push({
2693
+ role: 'tool', tool_call_id: skipped.id,
2694
+ content: 'NOT RUN: stopped at the user\'s request before this call was made.',
2695
+ });
2696
+ }
2697
+ if (!silent) {
2698
+ tui.printWarning(toolCalls.length - callIndex === 1
2699
+ ? 'Stopped. One queued call was not run.'
2700
+ : `Stopped. ${toolCalls.length - callIndex} queued calls were not run.`);
2701
+ }
2702
+ return false;
2703
+ }
2643
2704
  const sig = tc.name + '::' + tc.arguments;
2644
2705
  /*
2645
2706
  * Recorded on attempt, not on execution.
@@ -2954,14 +3015,16 @@ detectedContext = { current: 0 }) {
2954
3015
  }
2955
3016
  catch { /* use empty */ }
2956
3017
  delegated.agents += parsed.tasks?.length ?? 0;
2957
- result = await handleSpawnAgents(parsed, config, effectiveCwd, stats, delegated);
3018
+ result = await handleSpawnAgents(parsed, config, effectiveCwd, abortSignal, stats, delegated);
2958
3019
  }
2959
3020
  else if (BUILTIN_NAMES.has(tc.name)) {
2960
3021
  result = await dispatchTool(tc.name, tc.arguments, effectiveCwd,
2961
3022
  // Ink owns approvals through `config.approve`. Sending it through the legacy TUI as
2962
3023
  // well created a second readline prompt over Ink's frame, which looked like a hang
2963
3024
  // and could leave two terminal interfaces fighting for stdin.
2964
- !config.approve && (config.requireApproval || policyDecision.requireApproval), line => config.onToolOutput?.(tc.name, line), sandbox);
3025
+ !config.approve && (config.requireApproval || policyDecision.requireApproval), line => config.onToolOutput?.(tc.name, line), sandbox,
3026
+ // So a command, a page load or a fetch already in flight is cut rather than waited out.
3027
+ abortSignal);
2965
3028
  }
2966
3029
  else if (plugins.some(pl => pl.definition.name === tc.name)) {
2967
3030
  result = await callPlugin(tc.name, tc.arguments, effectiveCwd, plugins);
@@ -2969,7 +3032,9 @@ detectedContext = { current: 0 }) {
2969
3032
  else if (aliasedTool) {
2970
3033
  // The name is not ours but its meaning is not in doubt: `create_file` with a path and
2971
3034
  // contents is `write_file`. Refusing it wastes the turn and, twice now, the task.
2972
- result = aliasNotice(tc.name, aliasedTool) + await dispatchTool(aliasedTool, tc.arguments, effectiveCwd, !config.approve && (config.requireApproval || policyDecision.requireApproval), line => config.onToolOutput?.(tc.name, line), sandbox);
3035
+ result = aliasNotice(tc.name, aliasedTool) + await dispatchTool(aliasedTool, tc.arguments, effectiveCwd, !config.approve && (config.requireApproval || policyDecision.requireApproval), line => config.onToolOutput?.(tc.name, line), sandbox,
3036
+ // So a command, a page load or a fetch already in flight is cut rather than waited out.
3037
+ abortSignal);
2973
3038
  }
2974
3039
  else {
2975
3040
  // A name the model invented, not a plugin that failed to load. Saying which tools exist