jeo-code 0.6.14 → 0.6.15

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 CHANGED
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  The README mirrors the latest 5 entries — regenerate with `bun run changelog:sync`.
8
8
 
9
+ ## [0.6.15] - 2026-06-17
10
+ _Query-aware OKF memory injection with budget-priority selection, and a truthful end-of-turn Todos receipt._
11
+
12
+ ### Added
13
+ - **Concept-level memory search & budget-aware injection (OKF Sprint 03).** `memoryPromptSection(cwd, query?)` now loads the OKF concept bundle and selects what to inject by priority — high-confidence core facts first, then query relevance (the one-shot task text is wired in as the query), then stable order — dropping whole lowest-priority concepts to fit `MEMORY_INJECT_MAX_CHARS` (3000) instead of truncating mid-string. New exported helpers `loadConcepts` / `scoreConcept` / `searchConcepts`. The `index.md` rebuild now emits progressive-disclosure `- [title](/relpath) — description` rows. Injection-hardening (DATA framing, fence neutralization) and the `MEMORY.md` fallback are retained.
14
+
15
+ ### Changed
16
+ - **End-of-turn Todos receipt tells the truth.** A successful `finish` shows the Todos checklist fully complete so it agrees with the `done` badge (the model's last `todo` call often forgets to flip the final items, and the once-per-turn done gate can't force it); cancel/error finishes pass `ok:false` so any unfinished items stay honestly shown. The live frame is unchanged, so in-progress work still renders truthfully.
17
+
18
+
9
19
  ## [0.6.14] - 2026-06-16
10
20
  _Memory distillation survives malformed model output, and stream-idle stalls retry instead of failing the turn._
11
21
 
package/README.ja.md CHANGED
@@ -158,11 +158,11 @@ CI は `.github/workflows/npm-publish.yml` で公開します — GitHub リリ
158
158
  ## 変更履歴 (Changelog)
159
159
 
160
160
  <!-- CHANGELOG:START (auto-generated from CHANGELOG.md — run `bun run changelog:sync`) -->
161
+ - **[0.6.15]** (2026-06-17) — Query-aware OKF memory injection with budget-priority selection, and a truthful end-of-turn Todos receipt.
161
162
  - **[0.6.14]** (2026-06-16) — Memory distillation survives malformed model output, and stream-idle stalls retry instead of failing the turn.
162
163
  - **[0.6.13]** (2026-06-16) — `team` engine: concrete uncommitted-work reporting and stricter empty-run handling.
163
164
  - **[0.6.12]** (2026-06-16) — OKF-backed memory distillation — session learnings become structured concept files.
164
165
  - **[0.6.11]** (2026-06-16) — Larger reasoning budgets, and terminal capability-response sequences kept out of the prompt.
165
- - **[0.6.10]** (2026-06-16) — OKF memory-format foundation and a hardened bashTool subprocess drain.
166
166
 
167
167
  See [CHANGELOG.md](CHANGELOG.md) for the full history.
168
168
  <!-- CHANGELOG:END -->
package/README.ko.md CHANGED
@@ -158,11 +158,11 @@ CI는 `.github/workflows/npm-publish.yml`로 배포합니다 — GitHub 릴리
158
158
  ## 변경 이력 (Changelog)
159
159
 
160
160
  <!-- CHANGELOG:START (auto-generated from CHANGELOG.md — run `bun run changelog:sync`) -->
161
+ - **[0.6.15]** (2026-06-17) — Query-aware OKF memory injection with budget-priority selection, and a truthful end-of-turn Todos receipt.
161
162
  - **[0.6.14]** (2026-06-16) — Memory distillation survives malformed model output, and stream-idle stalls retry instead of failing the turn.
162
163
  - **[0.6.13]** (2026-06-16) — `team` engine: concrete uncommitted-work reporting and stricter empty-run handling.
163
164
  - **[0.6.12]** (2026-06-16) — OKF-backed memory distillation — session learnings become structured concept files.
164
165
  - **[0.6.11]** (2026-06-16) — Larger reasoning budgets, and terminal capability-response sequences kept out of the prompt.
165
- - **[0.6.10]** (2026-06-16) — OKF memory-format foundation and a hardened bashTool subprocess drain.
166
166
 
167
167
  See [CHANGELOG.md](CHANGELOG.md) for the full history.
168
168
  <!-- CHANGELOG:END -->
package/README.md CHANGED
@@ -158,11 +158,11 @@ Required npm token permissions (repository secret `NPM_TOKEN`):
158
158
  ## Changelog
159
159
 
160
160
  <!-- CHANGELOG:START (auto-generated from CHANGELOG.md — run `bun run changelog:sync`) -->
161
+ - **[0.6.15]** (2026-06-17) — Query-aware OKF memory injection with budget-priority selection, and a truthful end-of-turn Todos receipt.
161
162
  - **[0.6.14]** (2026-06-16) — Memory distillation survives malformed model output, and stream-idle stalls retry instead of failing the turn.
162
163
  - **[0.6.13]** (2026-06-16) — `team` engine: concrete uncommitted-work reporting and stricter empty-run handling.
163
164
  - **[0.6.12]** (2026-06-16) — OKF-backed memory distillation — session learnings become structured concept files.
164
165
  - **[0.6.11]** (2026-06-16) — Larger reasoning budgets, and terminal capability-response sequences kept out of the prompt.
165
- - **[0.6.10]** (2026-06-16) — OKF memory-format foundation and a hardened bashTool subprocess drain.
166
166
 
167
167
  See [CHANGELOG.md](CHANGELOG.md) for the full history.
168
168
  <!-- CHANGELOG:END -->
package/README.zh.md CHANGED
@@ -158,11 +158,11 @@ CI 通过 `.github/workflows/npm-publish.yml` 发布 — GitHub 发布 release
158
158
  ## 更新日志 (Changelog)
159
159
 
160
160
  <!-- CHANGELOG:START (auto-generated from CHANGELOG.md — run `bun run changelog:sync`) -->
161
+ - **[0.6.15]** (2026-06-17) — Query-aware OKF memory injection with budget-priority selection, and a truthful end-of-turn Todos receipt.
161
162
  - **[0.6.14]** (2026-06-16) — Memory distillation survives malformed model output, and stream-idle stalls retry instead of failing the turn.
162
163
  - **[0.6.13]** (2026-06-16) — `team` engine: concrete uncommitted-work reporting and stricter empty-run handling.
163
164
  - **[0.6.12]** (2026-06-16) — OKF-backed memory distillation — session learnings become structured concept files.
164
165
  - **[0.6.11]** (2026-06-16) — Larger reasoning budgets, and terminal capability-response sequences kept out of the prompt.
165
- - **[0.6.10]** (2026-06-16) — OKF memory-format foundation and a hardened bashTool subprocess drain.
166
166
 
167
167
  See [CHANGELOG.md](CHANGELOG.md) for the full history.
168
168
  <!-- CHANGELOG:END -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jeo-code",
3
- "version": "0.6.14",
3
+ "version": "0.6.15",
4
4
 
5
5
  "description": "Clean, highly optimized AI coding agent using spec-first loop",
6
6
  "type": "module",
@@ -3,10 +3,12 @@
3
3
  * (plan/gjc-inheritance.md B6; gjc memories/ 2-phase consolidation 참조).
4
4
  *
5
5
  * Session end distills durable learnings (repo facts, commands that work,
6
- * gotchas, user preferences) into `.jeo/memory/MEMORY.md` with ONE model call,
7
- * merging into the existing doc. The next session injects the doc back into
8
- * the system prompt under a hard char cap local-first (nullclaw/zeroclaw),
9
- * no remote backend, disable with JEO_NO_MEMORY=1.
6
+ * gotchas, user preferences) into the OKF concept bundle under `.jeo/memory/`
7
+ * (type-partitioned `facts/`, `commands/`, dirs) with ONE model call, upserting
8
+ * each concept; a legacy single `MEMORY.md` doc is the fallback when the model
9
+ * returns plain text. The next session reads the bundle back (bundle-first, then
10
+ * MEMORY.md) and injects it into the system prompt under a hard char cap —
11
+ * local-first (nullclaw/zeroclaw), no remote backend, disable with JEO_NO_MEMORY=1.
10
12
  */
11
13
  import * as fs from "node:fs/promises";
12
14
  import { spawn as nodeSpawn } from "node:child_process";
@@ -47,16 +49,181 @@ export async function loadMemory(cwd: string): Promise<string> {
47
49
  }
48
50
  }
49
51
 
52
+ /** Render a single index.md-style section: a `## header` followed by one bullet
53
+ * per concept (`**title**: description`), with the concept body indented beneath. */
54
+ function renderConceptSection(header: string, list: { title: string; description: string; body: string }[]): string {
55
+ const lines = [`## ${header}`];
56
+ for (const c of list) {
57
+ lines.push(`- **${c.title}**${c.description ? `: ${c.description}` : ""}`);
58
+ if (c.body) {
59
+ for (const bodyLine of c.body.split("\n")) lines.push(` ${bodyLine}`);
60
+ }
61
+ }
62
+ return lines.join("\n");
63
+ }
64
+
65
+ /** A loaded OKF concept: frontmatter fields + body + bundle-relative path. */
66
+ export interface Concept {
67
+ type: string;
68
+ title: string;
69
+ description: string;
70
+ body: string;
71
+ tags: string[];
72
+ /** high | medium | low — distiller defaults to "high"; drives core selection. */
73
+ confidence: string;
74
+ /** Bundle-relative path, e.g. `commands/bun-test.md`. */
75
+ relPath: string;
76
+ }
77
+
78
+ /** Read every concept document in the bundle into structured `Concept`s. Reserved
79
+ * files (index.md/log.md) and raw/ payloads are skipped; unparseable or
80
+ * frontmatter-less files are ignored (lenient consumption). */
81
+ export async function loadConcepts(cwd: string): Promise<Concept[]> {
82
+ return loadConceptsFromBundle(path.join(cwd, ".jeo", "memory"));
83
+ }
84
+
85
+ async function loadConceptsFromBundle(bundleDir: string): Promise<Concept[]> {
86
+ const files = await findMarkdownFiles(bundleDir);
87
+ const concepts: Concept[] = [];
88
+ for (const file of files) {
89
+ const relPath = path.relative(bundleDir, file).replace(/\\/g, "/");
90
+ if (isReservedFile(relPath)) continue;
91
+ let parsed;
92
+ try {
93
+ parsed = parseConcept(await fs.readFile(file, "utf-8"));
94
+ } catch {
95
+ continue;
96
+ }
97
+ if (!parsed.hasFrontmatter) continue;
98
+ const fm = parsed.frontmatter;
99
+ concepts.push({
100
+ type: (fm.type as string) || "RepoFact",
101
+ title: (fm.title as string) || path.basename(file, ".md"),
102
+ description: (fm.description as string) || "",
103
+ body: parsed.body.trim(),
104
+ tags: Array.isArray(fm.tags) ? fm.tags.filter((t): t is string => typeof t === "string") : [],
105
+ confidence: typeof fm.confidence === "string" ? fm.confidence : "high",
106
+ relPath,
107
+ });
108
+ }
109
+ return concepts;
110
+ }
111
+
112
+ /** Tokenize a free-text query into distinct lowercased keywords (len ≥ 3). */
113
+ function tokenize(query?: string): string[] {
114
+ if (!query) return [];
115
+ return Array.from(new Set((query.toLowerCase().match(/[a-z0-9]+/g) ?? []).filter(t => t.length >= 3)));
116
+ }
117
+
118
+ /** Relevance score of a concept against query tokens. Field weights mirror
119
+ * llm-wiki's retrieval bias (title ≫ tags ≫ type/description ≫ body). 0 = no hit. */
120
+ export function scoreConcept(concept: Concept, tokens: string[]): number {
121
+ if (tokens.length === 0) return 0;
122
+ const title = concept.title.toLowerCase();
123
+ const desc = concept.description.toLowerCase();
124
+ const body = concept.body.toLowerCase();
125
+ const type = concept.type.toLowerCase();
126
+ const tags = concept.tags.map(t => t.toLowerCase());
127
+ let score = 0;
128
+ for (const t of tokens) {
129
+ if (title.includes(t)) score += 5;
130
+ if (tags.some(tag => tag.includes(t))) score += 3;
131
+ if (type.includes(t)) score += 2;
132
+ if (desc.includes(t)) score += 2;
133
+ if (body.includes(t)) score += 1;
134
+ }
135
+ return score;
136
+ }
137
+
138
+ /** Search the bundle's concepts for a query, returning the relevant ones (score > 0)
139
+ * highest-score first. A type/tags/title/body keyword match all contribute. */
140
+ export function searchConcepts(concepts: Concept[], query: string): { concept: Concept; score: number }[] {
141
+ const tokens = tokenize(query);
142
+ return concepts
143
+ .map(concept => ({ concept, score: scoreConcept(concept, tokens) }))
144
+ .filter(r => r.score > 0)
145
+ .sort((a, b) => b.score - a.score);
146
+ }
147
+
148
+ /** Priority order for injection: high-confidence "core" concepts first, then by
149
+ * query relevance (descending), preserving input order as a stable tiebreak. */
150
+ function priorityOrder(concepts: Concept[], query?: string): Concept[] {
151
+ const tokens = tokenize(query);
152
+ return concepts
153
+ .map((concept, i) => ({ concept, i, core: concept.confidence === "high", score: scoreConcept(concept, tokens) }))
154
+ .sort((a, b) => {
155
+ if (a.core !== b.core) return a.core ? -1 : 1;
156
+ if (b.score !== a.score) return b.score - a.score;
157
+ return a.i - b.i;
158
+ })
159
+ .map(s => s.concept);
160
+ }
161
+
162
+ /** Group items by their `type` into ordered `{ header, list }` sections: TYPE_LAYOUT
163
+ * order first, then any unknown types under their raw type name (lenient). The one
164
+ * place that encodes the section ordering — shared by render and index. */
165
+ function groupByTypeLayout<T extends { type: string }>(items: T[]): { header: string; list: T[] }[] {
166
+ const byType = new Map<string, T[]>();
167
+ for (const it of items) {
168
+ const list = byType.get(it.type) ?? [];
169
+ list.push(it);
170
+ byType.set(it.type, list);
171
+ }
172
+ const sections: { header: string; list: T[] }[] = [];
173
+ const rendered = new Set<string>();
174
+ for (const { type, header } of TYPE_LAYOUT) {
175
+ rendered.add(type);
176
+ const list = byType.get(type);
177
+ if (list && list.length > 0) sections.push({ header, list });
178
+ }
179
+ for (const [type, list] of byType) {
180
+ if (rendered.has(type) || list.length === 0) continue;
181
+ sections.push({ header: type, list });
182
+ }
183
+ return sections;
184
+ }
185
+
186
+ /** Render a set of concepts as a compact markdown block grouped by type in
187
+ * TYPE_LAYOUT order, with any unknown types appended under their raw type name. */
188
+ function renderConcepts(concepts: Concept[]): string {
189
+ return groupByTypeLayout(concepts)
190
+ .map(({ header, list }) => renderConceptSection(header, list))
191
+ .join("\n\n");
192
+ }
193
+
194
+ /** Greedily select concepts (in priority order) whose grouped render stays within
195
+ * `budget` chars, dropping the lowest-priority concepts first. At least the
196
+ * top-priority concept is always kept (the framing/backstop cap still applies). */
197
+ function selectWithinBudget(concepts: Concept[], query: string | undefined, budget: number): Concept[] {
198
+ const ordered = priorityOrder(concepts, query);
199
+ const selected: Concept[] = [];
200
+ for (const c of ordered) {
201
+ if (renderConcepts([...selected, c]).length <= budget) selected.push(c);
202
+ }
203
+ if (selected.length === 0 && ordered.length > 0) selected.push(ordered[0]!);
204
+ return selected;
205
+ }
206
+
50
207
  /** System-prompt block carrying prior-session learnings; "" when empty or disabled.
208
+ * Selection (Sprint 03): always-included high-confidence core + concepts most
209
+ * relevant to `query` (the current task), chosen whole within MEMORY_INJECT_MAX_CHARS
210
+ * (lowest-priority dropped first) — never a mid-concept string truncation. Falls
211
+ * back to the legacy single MEMORY.md doc when no concept bundle exists.
51
212
  * The memory text is MODEL-DISTILLED from session transcripts (which include tool
52
213
  * outputs — file contents, web results), so it is injection-hardened like subagent
53
214
  * reports: tag-breakout sequences are neutralized and the block is framed as DATA. */
54
- export async function memoryPromptSection(cwd: string): Promise<string> {
215
+ export async function memoryPromptSection(cwd: string, query?: string): Promise<string> {
55
216
  if (jeoEnv("NO_MEMORY") === "1") return "";
56
- let memory = await loadMemory(cwd);
217
+ // Prefer the OKF concept bundle (budget-selected); fall back to legacy MEMORY.md.
218
+ const concepts = await loadConcepts(cwd);
219
+ let memory = concepts.length > 0
220
+ ? renderConcepts(selectWithinBudget(concepts, query, MEMORY_INJECT_MAX_CHARS))
221
+ : await loadMemory(cwd);
57
222
  if (!memory) return "";
223
+ // Backstop: legacy MEMORY.md is a single blob (not concept-selectable), and a
224
+ // pathological single concept can exceed the budget — hard-cap either way.
58
225
  if (memory.length > MEMORY_INJECT_MAX_CHARS) {
59
- memory = memory.slice(0, MEMORY_INJECT_MAX_CHARS) + "\n…(memory truncated — full doc in .jeo/memory/MEMORY.md)";
226
+ memory = memory.slice(0, MEMORY_INJECT_MAX_CHARS) + "\n…(memory truncated — full doc in .jeo/memory/)";
60
227
  }
61
228
  // Neutralize the fence tags so distilled content can never close the block and
62
229
  // smuggle instruction-shaped text into the bare system prompt.
@@ -120,33 +287,20 @@ async function findMarkdownFiles(dir: string): Promise<string[]> {
120
287
  }
121
288
 
122
289
  async function rebuildIndex(bundleDir: string): Promise<void> {
123
- const files = await findMarkdownFiles(bundleDir);
124
- const concepts: { type: string; title: string; relPath: string }[] = [];
125
- for (const file of files) {
126
- const relPath = path.relative(bundleDir, file);
127
- if (isReservedFile(relPath)) continue;
128
- try {
129
- const content = await fs.readFile(file, "utf-8");
130
- const parsed = parseConcept(content);
131
- concepts.push({
132
- type: (parsed.frontmatter.type as string) || "RepoFact",
133
- title: (parsed.frontmatter.title as string) || path.basename(file, ".md"),
134
- relPath,
135
- });
136
- } catch {
137
- // ignore
138
- }
139
- }
290
+ const concepts = await loadConceptsFromBundle(bundleDir);
140
291
 
141
- let body = "# Index\n\n";
142
- for (const { type, header } of TYPE_LAYOUT) {
143
- const list = concepts.filter(c => c.type === type);
144
- if (list.length === 0) continue;
145
- body += `## ${header}\n`;
292
+ // Progressive-disclosure index: a link per concept plus its one-line description,
293
+ // grouped by type (TYPE_LAYOUT order first, then any unknown types — lenient).
294
+ const section = (header: string, list: Concept[]): string => {
295
+ let out = `## ${header}\n`;
146
296
  for (const c of list) {
147
- body += `- [${c.title}](/${c.relPath.replace(/\\/g, "/")})\n`;
297
+ out += `- [${c.title}](/${c.relPath})${c.description ? ` — ${c.description}` : ""}\n`;
148
298
  }
149
- body += "\n";
299
+ return out + "\n";
300
+ };
301
+ let body = "# Index\n\n";
302
+ for (const { header, list } of groupByTypeLayout(concepts)) {
303
+ body += section(header, list);
150
304
  }
151
305
 
152
306
  const indexContent = serializeConcept({ okf_version: "0.1" }, body.trim());
@@ -396,7 +396,10 @@ export async function runLaunchCommand(args: string[]): Promise<void> {
396
396
  const protocol = buildToolProtocol(allowedTools);
397
397
  const preamble = flags.systemPrompt ?? "You are the jeo, an interactive coding agent.\nAccomplish the user's request by calling tools and verifying your work.";
398
398
  // Prior-session learnings (B6 경험 증류) — "" when absent or JEO_NO_MEMORY=1.
399
- const memoryBlock = await memoryPromptSection(cwd);
399
+ // The one-shot task text (flags.message) seeds relevance search so the most
400
+ // pertinent concepts win the injection budget; interactive boots with no query
401
+ // (high-confidence core concepts are always prioritized regardless).
402
+ const memoryBlock = await memoryPromptSection(cwd, flags.message || undefined);
400
403
 
401
404
  const baseSystemPrompt =
402
405
  preamble + "\n\n" + protocol + "\n\n" +
@@ -679,7 +682,7 @@ export async function runLaunchCommand(args: string[]): Promise<void> {
679
682
  else console.log(msg);
680
683
  },
681
684
  onHardExit: () => {
682
- if (tui) tui.finish("Cancelled.");
685
+ if (tui) tui.finish("Cancelled.", { ok: false });
683
686
  process.exit(130);
684
687
  },
685
688
  });
@@ -812,7 +815,7 @@ export async function runLaunchCommand(args: string[]): Promise<void> {
812
815
  }
813
816
  } catch (err) {
814
817
  if (tui) {
815
- tui.finish(`! ${friendlyProviderError(err)}`);
818
+ tui.finish(`! ${friendlyProviderError(err)}`, { ok: false });
816
819
  interactiveTurnActive = false;
817
820
  }
818
821
  throw err;
package/src/tui/app.ts CHANGED
@@ -359,12 +359,16 @@ export class LaunchTui {
359
359
  try { this.write(`\x1b]2;jeo: ${this.turnTitle}\x07`); } catch { /* terminal gone */ }
360
360
  }
361
361
 
362
- /** Render the task plan as a status-colored checklist; empty when no plan. */
363
- private renderPlan(color: boolean): string[] {
362
+ /** Render the task plan as a status-colored checklist; empty when no plan. When
363
+ * `complete` (the success-finish receipt), every still-open item is shown done so the
364
+ * checklist agrees with the `done` badge — the model's last `todo` call often forgets
365
+ * to flip the final items, and the once-per-turn done gate can't force it. The LIVE
366
+ * frame never passes `complete`, so in-progress work still renders truthfully. */
367
+ private renderPlan(color: boolean, complete = false): string[] {
364
368
  if (this.todos.length === 0) return [];
365
369
  const steps = this.todos.map(t => ({
366
370
  label: t.title,
367
- state: (t.status === "done" ? "done" : t.status === "in_progress" ? "active" : "pending") as StepState,
371
+ state: (complete || t.status === "done" ? "done" : t.status === "in_progress" ? "active" : "pending") as StepState,
368
372
  }));
369
373
  const header = formatStepHeader(steps, { unicode: this.unicode, color, label: "Todos" });
370
374
  return [header, ...formatStepTimeline(steps, { unicode: this.unicode, color, highlightActive: true, maxRows: 8, badges: false })];
@@ -984,8 +988,11 @@ export class LaunchTui {
984
988
  return this.theme.color ? chalk.bold(accentPaint(this.theme)("jeo")) : "jeo";
985
989
  }
986
990
 
987
- /** Collapse the live region to static final output. */
988
- finish(reply: string): void {
991
+ /** Collapse the live region to static final output. `ok` (default true) marks a
992
+ * SUCCESSFUL turn its Todos receipt is shown fully complete. Cancel/error finishes
993
+ * pass `ok:false` so the checklist truthfully keeps any unfinished items. */
994
+ finish(reply: string, opts: { ok?: boolean } = {}): void {
995
+ const ok = opts.ok !== false;
989
996
  this.finished = true;
990
997
  this.hudPhase = "done";
991
998
  if (this.timer) {
@@ -1014,7 +1021,7 @@ export class LaunchTui {
1014
1021
  const finalLines: string[] = [];
1015
1022
  // jeo-ref final-report order: the ANSWER leads; the Todos checklist follows it
1016
1023
  // (done = checked + struck through), so the plan reads as a completion receipt.
1017
- const planLines = this.renderPlan(this.theme.color);
1024
+ const planLines = this.renderPlan(this.theme.color, ok);
1018
1025
  if (!this.inline) {
1019
1026
  // Inline scrollback already reads as a ✓/✗ checklist; the step timeline +
1020
1027
  // compact strip + flow line would just repeat it (gjc-style slim summary).