jeo-code 0.4.6 → 0.4.7

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.
@@ -1,4 +1,6 @@
1
1
  import chalk from "chalk";
2
+ import { padLineTo } from "./layout";
3
+ import { visibleWidth } from "./color";
2
4
 
3
5
  export interface TodoCardItem {
4
6
  title: string;
@@ -8,40 +10,69 @@ export interface TodoCardItem {
8
10
  export interface TodoCardOptions {
9
11
  unicode?: boolean;
10
12
  color?: boolean;
13
+ /** Faint card background tint painter — gives the card a panel look so it reads
14
+ * as a distinct block. Identity when absent (or colorless). */
15
+ fill?: (s: string) => string;
16
+ /** Muted foreground painter for secondary text (done/pending labels, count,
17
+ * tree connectors). Replaces `chalk.dim`, which washes out on dark terminals. */
18
+ muted?: (s: string) => string;
19
+ /** Accent painter for the in_progress (active) item — the theme's highlight hue,
20
+ * applied bold. Defaults to cyan so the active row matches the rest of the theme
21
+ * instead of a hardcoded color that clashes on warm/green/red palettes. */
22
+ accent?: (s: string) => string;
23
+ /** Panel width: lines pad to this so the fill spans a clean rectangle. Clamped
24
+ * to [20,120]; defaults to the longest content row + 2. */
25
+ width?: number;
11
26
  }
12
27
 
13
28
  /**
14
29
  * jeo-ref "Todo Write" scrollback card: a ✓-led header with a tree-connector
15
30
  * checklist — done items get ☑ + strikethrough, the active item highlights,
16
- * pending stays dim. Pure `string[]`; the caller flushes it into the ledger so
17
- * the plan's evolution (items checking off turn by turn) reads as transcript
18
- * history, exactly like the reference TUI.
31
+ * pending stays muted. A faint background tint (when a `fill` painter is given)
32
+ * makes the whole block read as a panel; secondary text uses a real muted hue
33
+ * instead of ANSI dim so completed rows stay legible. Pure `string[]`; the caller
34
+ * flushes it into the ledger so the plan's evolution reads as transcript history.
19
35
  */
20
36
  export function formatTodoWriteCard(items: TodoCardItem[], opts: TodoCardOptions = {}): string[] {
21
37
  if (items.length === 0) return [];
22
38
  const unicode = opts.unicode !== false;
23
39
  const color = opts.color !== false;
40
+ const fill = opts.fill ?? ((s: string) => s);
41
+ const muted = color ? (opts.muted ?? chalk.dim) : (s: string) => s;
42
+ const active = color ? (opts.accent ? (s: string) => chalk.bold(opts.accent!(s)) : chalk.cyan.bold) : (s: string) => s;
24
43
  const check = unicode ? "✓" : "v";
25
44
  const boxDone = unicode ? "☑" : "[x]";
26
45
  const boxOpen = unicode ? "☐" : "[ ]";
27
46
  const tee = unicode ? "├─" : "|-";
28
47
  const ell = unicode ? "└─" : "`-";
29
48
  const count = `${items.length} task${items.length === 1 ? "" : "s"}`;
30
- const head = color
31
- ? `${chalk.green(check)} ${chalk.bold("Todo Write")} ${chalk.dim(count)}`
32
- : `${check} Todo Write ${count}`;
33
- const lines = [head];
49
+
50
+ const rows: string[] = [];
51
+ rows.push(
52
+ color
53
+ ? `${chalk.green(check)} ${chalk.bold("Todo Write")} ${muted(count)}`
54
+ : `${check} Todo Write ${count}`,
55
+ );
34
56
  items.forEach((item, i) => {
35
- const conn = i === items.length - 1 ? ell : tee;
57
+ const conn = color ? muted(i === items.length - 1 ? ell : tee) : i === items.length - 1 ? ell : tee;
36
58
  if (item.status === "done") {
37
59
  const box = color ? chalk.green(boxDone) : boxDone;
38
- const label = color ? chalk.dim.strikethrough(item.title) : item.title;
39
- lines.push(` ${conn} ${box} ${label}`);
60
+ const label = color ? chalk.strikethrough(muted(item.title)) : item.title;
61
+ rows.push(` ${conn} ${box} ${label}`);
40
62
  } else if (item.status === "in_progress") {
41
- lines.push(` ${conn} ${boxOpen} ${color ? chalk.cyan.bold(item.title) : item.title}`);
63
+ rows.push(` ${conn} ${boxOpen} ${active(item.title)}`);
42
64
  } else {
43
- lines.push(` ${conn} ${boxOpen} ${color ? chalk.dim(item.title) : item.title}`);
65
+ rows.push(` ${conn} ${boxOpen} ${color ? muted(item.title) : item.title}`);
44
66
  }
45
67
  });
46
- return lines;
68
+
69
+ // Panel: pad each row (with a 1-col left gutter) to a common width and tint the
70
+ // whole rectangle — only when the caller opts in via `fill`/`width`; otherwise the
71
+ // bare tree-checklist rows return unchanged (back-compat). visibleWidth ignores
72
+ // ANSI, and every painter above closes with a TARGETED reset (never `\x1b[0m`), so
73
+ // the background spans the full row.
74
+ if (!opts.fill && opts.width === undefined) return rows;
75
+ const contentWidth = rows.reduce((m, r) => Math.max(m, visibleWidth(r)), 0) + 2;
76
+ const panelWidth = Math.max(20, Math.min(120, opts.width ?? contentWidth));
77
+ return rows.map(r => fill(padLineTo(` ${r}`, panelWidth, "left")));
47
78
  }
@@ -1,5 +1,9 @@
1
1
  import pkg from "../../package.json";
2
2
  import { compareVersions } from "../commands/update";
3
+ import * as os from "node:os";
4
+ import * as path from "node:path";
5
+ import { readFile, writeFile, mkdir } from "node:fs/promises";
6
+ import { jeoEnv } from "./env";
3
7
 
4
8
  export interface UpdateCheckResult {
5
9
  current: string;
@@ -62,3 +66,52 @@ export async function checkForUpdate(deps?: UpdateCheckDeps): Promise<UpdateChec
62
66
  return null;
63
67
  }
64
68
  }
69
+
70
+ // ---- Update-check disk cache ------------------------------------------------
71
+ // The live npm check often loses the startup race, so the "New version" banner
72
+ // rarely shows even when an update exists. Persisting the last-known-latest lets
73
+ // the NEXT launch render the banner INSTANTLY from disk (and offline), while a
74
+ // background refresh keeps the cache fresh. Mirrors gjc / npm update notices.
75
+
76
+ interface CachedUpdateCheck {
77
+ latest: string;
78
+ checkedAt: number;
79
+ }
80
+
81
+ function updateCacheDir(): string {
82
+ return jeoEnv("CONFIG_DIR") || path.join(os.homedir(), ".jeo");
83
+ }
84
+
85
+ function updateCachePath(): string {
86
+ return path.join(updateCacheDir(), "update-check.json");
87
+ }
88
+
89
+ /** Last-known-latest from disk, re-evaluated against the CURRENT local version
90
+ * (so an interim upgrade clears the banner). Null when no/invalid cache. */
91
+ export async function readUpdateCache(localVersion: string = pkg.version): Promise<UpdateCheckResult | null> {
92
+ if (typeof localVersion !== "string" || !localVersion) return null;
93
+ try {
94
+ const raw = await readFile(updateCachePath(), "utf-8");
95
+ const data = JSON.parse(raw) as Partial<CachedUpdateCheck>;
96
+ if (!data || typeof data.latest !== "string" || !data.latest) return null;
97
+ return {
98
+ current: localVersion,
99
+ latest: data.latest,
100
+ updateAvailable: compareVersions(localVersion, data.latest) < 0,
101
+ };
102
+ } catch {
103
+ return null;
104
+ }
105
+ }
106
+
107
+ /** Persist the latest version for the next launch (best-effort; never throws). */
108
+ export async function writeUpdateCache(latest: string): Promise<void> {
109
+ if (typeof latest !== "string" || !latest) return;
110
+ try {
111
+ await mkdir(updateCacheDir(), { recursive: true, mode: 0o700 });
112
+ const payload: CachedUpdateCheck = { latest, checkedAt: Date.now() };
113
+ await writeFile(updateCachePath(), JSON.stringify(payload, null, 2), { encoding: "utf-8", mode: 0o600 });
114
+ } catch {
115
+ // Cache is an optimization; a write failure must never break launch.
116
+ }
117
+ }
@@ -1,52 +0,0 @@
1
- import { runAgentLoop, executorSystemPrompt, DEFAULT_TOOLS } from "../agent/engine";
2
- import { loadSkills, buildSkillTask, getSkillFrom } from "../skills/catalog";
3
- import { readGlobalConfig, isDevMode } from "../agent/state";
4
- import { runPostImplementationHooks } from "../agent/hooks";
5
-
6
- export async function runGjcCommand(args: string[]): Promise<void> {
7
- const intent = args.join(" ").trim();
8
- const config = await readGlobalConfig();
9
-
10
- if (intent.toLowerCase().includes("self-improve") && !isDevMode()) {
11
- console.error("Error: Self-improvement tasks are only allowed in JEO_DEV_MODE=1.");
12
- process.exit(1);
13
- }
14
-
15
- const model = config.defaultModel || "fast";
16
- const skills = await loadSkills();
17
- const gjcSkill = getSkillFrom(skills, "gjc");
18
-
19
- if (!gjcSkill) {
20
- console.error("Error: gjc skill not found.");
21
- process.exit(1);
22
- }
23
-
24
- // Correct signature: executorSystemPrompt(role?, protocol?, verificationDirective?)
25
- const systemPrompt = executorSystemPrompt();
26
- const task = buildSkillTask(gjcSkill, intent);
27
-
28
- await runAgentLoop([{ role: "user", content: task }], {
29
- cwd: process.cwd(),
30
- systemPrompt,
31
- model,
32
- tools: DEFAULT_TOOLS,
33
- maxSteps: 50,
34
- });
35
-
36
- console.log("\n[jeo] Verifying implementation...");
37
- const verify = await runPostImplementationHooks(process.cwd(), intent);
38
-
39
- if (!verify.success) {
40
- console.error("\n[jeo] Verification FAILED. Auto-repairing...");
41
- const repairTask = `Previous implementation failed verification.\nErrors:\n${verify.output}\n\nPlease fix.`;
42
- await runAgentLoop([{ role: "user", content: repairTask }], {
43
- cwd: process.cwd(),
44
- systemPrompt,
45
- model,
46
- tools: DEFAULT_TOOLS,
47
- maxSteps: 30,
48
- });
49
- } else {
50
- console.log("\n[jeo] Verification SUCCESSFUL.");
51
- }
52
- }
@@ -1,31 +0,0 @@
1
- <!-- Parent: ../AGENTS.md -->
2
- <!-- Generated: 2026-06-11 | Updated: 2026-06-11 -->
3
-
4
- # gjc
5
-
6
- ## Purpose
7
- Bundled SKILL.md for the `gjc` workflow.
8
-
9
- ## Key Files
10
- | File | Description |
11
- |------|-------------|
12
- | `SKILL.md` | The primary skill definition |
13
-
14
- ## Subdirectories
15
- *(None)*
16
-
17
- ## For AI Agents
18
-
19
- ### Working In This Directory
20
- - Do not modify this without understanding the broader workflow implications.
21
-
22
- ### Testing Requirements
23
- - N/A
24
-
25
- ### Common Patterns
26
- *(None)*
27
-
28
- ## Dependencies
29
- *(None)*
30
-
31
- <!-- MANUAL: -->
@@ -1,15 +0,0 @@
1
- ---
2
- description: Main implementation process using gjc spec-first workflow.
3
- command: jeo gjc "<request>"
4
- when: When you need to perform significant code changes, refactoring, or feature development using the core gjc process.
5
- ---
6
-
7
- # gjc (Gajae-Code Process)
8
-
9
- Executes the primary code implementation workflow by leveraging the underlying `gjc` engine (jeo-claw).
10
- This process manages the heavy lifting of code transformation, while the surrounding `jeo-code` ecosystem handles loop-level orchestration.
11
-
12
- 1. **Mutation Guard**: Ensures safe code writes by blocking operations until ambiguity is low (≤ 20%).
13
- 2. **Role Delegation**: Utilizes specialized subagents (architect, planner, executor, critic) for focused tasks.
14
- 3. **Loop Control**: Maintains a tight feedback loop between planning and execution.
15
- 4. **Verification**: Automatically runs verification steps after implementation to ensure correctness.