@zenera/cli 1.1.23 → 1.1.25

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.
Files changed (184) hide show
  1. package/README.md +88 -2
  2. package/dist/ask.d.ts +51 -0
  3. package/dist/ask.js +166 -0
  4. package/dist/banner.js +2 -2
  5. package/dist/batch.d.ts +83 -0
  6. package/dist/batch.js +413 -0
  7. package/dist/catalog.d.ts +11 -1
  8. package/dist/catalog.js +80 -7
  9. package/dist/command.d.ts +6 -0
  10. package/dist/commands/inspect.d.ts +57 -0
  11. package/dist/commands/inspect.js +539 -91
  12. package/dist/commands/list.js +128 -19
  13. package/dist/commands/memory.js +461 -32
  14. package/dist/commands/meta.js +311 -21
  15. package/dist/commands/models.js +110 -14
  16. package/dist/commands/open.js +4 -4
  17. package/dist/commands/run.js +175 -36
  18. package/dist/commands/sandbox.js +148 -15
  19. package/dist/engine.d.ts +24 -0
  20. package/dist/engine.js +61 -8
  21. package/dist/eventlog.d.ts +59 -0
  22. package/dist/eventlog.js +146 -0
  23. package/dist/liveness.d.ts +7 -0
  24. package/dist/liveness.js +20 -3
  25. package/dist/main.js +5 -2
  26. package/dist/meta/editor.d.ts +9 -0
  27. package/dist/meta/editor.js +60 -0
  28. package/dist/meta/finetune/children.d.ts +8 -0
  29. package/dist/meta/finetune/children.js +76 -0
  30. package/dist/meta/finetune/command.d.ts +30 -0
  31. package/dist/meta/finetune/command.js +338 -0
  32. package/dist/meta/finetune/dataset/anchors.d.ts +41 -0
  33. package/dist/meta/finetune/dataset/anchors.js +239 -0
  34. package/dist/meta/finetune/dataset/changes.d.ts +36 -0
  35. package/dist/meta/finetune/dataset/changes.js +319 -0
  36. package/dist/meta/finetune/dataset/command.d.ts +17 -0
  37. package/dist/meta/finetune/dataset/command.js +1011 -0
  38. package/dist/meta/finetune/dataset/drift.d.ts +33 -0
  39. package/dist/meta/finetune/dataset/drift.js +71 -0
  40. package/dist/meta/finetune/dataset/export.d.ts +26 -0
  41. package/dist/meta/finetune/dataset/export.js +51 -0
  42. package/dist/meta/finetune/dataset/index.d.ts +2 -0
  43. package/dist/meta/finetune/dataset/index.js +2 -0
  44. package/dist/meta/finetune/dataset/sample.d.ts +50 -0
  45. package/dist/meta/finetune/dataset/sample.js +197 -0
  46. package/dist/meta/finetune/dataset/schema.d.ts +33 -0
  47. package/dist/meta/finetune/dataset/schema.js +216 -0
  48. package/dist/meta/finetune/dataset/store.d.ts +35 -0
  49. package/dist/meta/finetune/dataset/store.js +177 -0
  50. package/dist/meta/finetune/dataset/types.d.ts +125 -0
  51. package/dist/meta/finetune/dataset/types.js +39 -0
  52. package/dist/meta/finetune/failure.d.ts +15 -0
  53. package/dist/meta/finetune/failure.js +26 -0
  54. package/dist/meta/finetune/feedback.d.ts +45 -0
  55. package/dist/meta/finetune/feedback.js +85 -0
  56. package/dist/meta/finetune/improvements.d.ts +51 -0
  57. package/dist/meta/finetune/improvements.js +244 -0
  58. package/dist/meta/finetune/index.d.ts +2 -0
  59. package/dist/meta/finetune/index.js +2 -0
  60. package/dist/meta/finetune/journal.d.ts +35 -0
  61. package/dist/meta/finetune/journal.js +135 -0
  62. package/dist/meta/finetune/live.d.ts +74 -0
  63. package/dist/meta/finetune/live.js +226 -0
  64. package/dist/meta/finetune/loop.d.ts +3 -0
  65. package/dist/meta/finetune/loop.js +114 -0
  66. package/dist/meta/finetune/memories.d.ts +47 -0
  67. package/dist/meta/finetune/memories.js +154 -0
  68. package/dist/meta/finetune/report.d.ts +33 -0
  69. package/dist/meta/finetune/report.js +1284 -0
  70. package/dist/meta/finetune/retry.d.ts +24 -0
  71. package/dist/meta/finetune/retry.js +96 -0
  72. package/dist/meta/finetune/sampler.d.ts +18 -0
  73. package/dist/meta/finetune/sampler.js +41 -0
  74. package/dist/meta/finetune/system.d.ts +27 -0
  75. package/dist/meta/finetune/system.js +132 -0
  76. package/dist/meta/finetune/train.d.ts +39 -0
  77. package/dist/meta/finetune/train.js +391 -0
  78. package/dist/meta/finetune/tui.d.ts +16 -0
  79. package/dist/meta/finetune/tui.js +291 -0
  80. package/dist/meta/finetune/tuning.d.ts +167 -0
  81. package/dist/meta/finetune/tuning.js +289 -0
  82. package/dist/meta/finetune/usage.d.ts +62 -0
  83. package/dist/meta/finetune/usage.js +225 -0
  84. package/dist/meta/host.d.ts +14 -0
  85. package/dist/meta/host.js +20 -0
  86. package/dist/meta/index.d.ts +11 -0
  87. package/dist/meta/index.js +11 -0
  88. package/dist/meta/launch.d.ts +81 -0
  89. package/dist/meta/launch.js +286 -0
  90. package/dist/meta/model.d.ts +44 -0
  91. package/dist/meta/model.js +119 -0
  92. package/dist/meta/prompts.d.ts +18 -0
  93. package/dist/meta/prompts.js +61 -0
  94. package/dist/meta/relay.d.ts +20 -0
  95. package/dist/meta/relay.js +123 -0
  96. package/dist/meta/tokens.d.ts +52 -0
  97. package/dist/meta/tokens.js +226 -0
  98. package/dist/meta/window.d.ts +61 -0
  99. package/dist/meta/window.js +198 -0
  100. package/dist/meta/wire.d.ts +42 -0
  101. package/dist/meta/wire.js +129 -0
  102. package/dist/modelref.d.ts +16 -0
  103. package/dist/modelref.js +41 -0
  104. package/dist/narrate.js +5 -2
  105. package/dist/podman.d.ts +42 -0
  106. package/dist/podman.js +198 -5
  107. package/dist/progress.d.ts +33 -0
  108. package/dist/progress.js +402 -0
  109. package/dist/projects.d.ts +0 -5
  110. package/dist/projects.js +2 -15
  111. package/dist/request.d.ts +45 -0
  112. package/dist/request.js +300 -0
  113. package/dist/sandbox.d.ts +2 -0
  114. package/dist/sandbox.js +20 -3
  115. package/dist/scaffold.d.ts +15 -6
  116. package/dist/scaffold.js +5 -60
  117. package/dist/session.d.ts +26 -1
  118. package/dist/session.js +46 -32
  119. package/dist/term.d.ts +5 -0
  120. package/dist/term.js +28 -3
  121. package/dist/trace.d.ts +84 -0
  122. package/dist/trace.js +737 -0
  123. package/dist/tui/models.d.ts +33 -0
  124. package/dist/tui/models.js +389 -0
  125. package/dist/tui/wrap.d.ts +5 -0
  126. package/dist/tui/wrap.js +12 -0
  127. package/dist/usage.d.ts +78 -0
  128. package/dist/usage.js +51 -0
  129. package/dist/validate.js +25 -3
  130. package/package.json +3 -2
  131. package/templates/editor/.github/copilot-instructions.md +41 -107
  132. package/templates/editor/.github/prompts/analyze.prompt.md +31 -0
  133. package/templates/editor/.github/prompts/dataset.prompt.md +108 -0
  134. package/templates/editor/.github/prompts/finetune-apply.prompt.md +91 -0
  135. package/templates/editor/.github/prompts/finetune.prompt.md +744 -0
  136. package/templates/editor/.github/prompts/new-agent.prompt.md +3 -1
  137. package/templates/editor/.github/prompts/new-skill.prompt.md +2 -0
  138. package/templates/editor/.github/prompts/project-review.prompt.md +4 -3
  139. package/templates/editor/.github/skills/zen-analyze-run/SKILL.md +483 -0
  140. package/templates/editor/.github/skills/zen-cli/SKILL.md +18 -4
  141. package/templates/editor/.github/skills/zen-cli/references/check.md +7 -5
  142. package/templates/editor/.github/skills/zen-cli/references/dataset.md +34 -0
  143. package/templates/editor/.github/skills/zen-cli/references/finetune.md +77 -0
  144. package/templates/editor/.github/skills/zen-cli/references/inspect.md +300 -21
  145. package/templates/editor/.github/skills/zen-cli/references/memory.md +121 -28
  146. package/templates/editor/.github/skills/zen-cli/references/meta.md +61 -0
  147. package/templates/editor/.github/skills/zen-cli/references/models.md +6 -2
  148. package/templates/editor/.github/skills/zen-cli/references/projects.md +12 -5
  149. package/templates/editor/.github/skills/zen-cli/references/rag.md +24 -6
  150. package/templates/editor/.github/skills/zen-cli/references/run.md +201 -4
  151. package/templates/editor/.github/skills/zen-cli/references/sandbox.md +10 -1
  152. package/templates/editor/.github/skills/zen-code-python/SKILL.md +123 -0
  153. package/templates/editor/.github/skills/zen-code-python/references/code_python.md +48 -0
  154. package/templates/editor/.github/skills/zen-dataset/SKILL.md +253 -0
  155. package/templates/editor/.github/skills/zen-finetune/SKILL.md +1791 -0
  156. package/templates/editor/.github/skills/zen-finetune/references/readme-template.md +268 -0
  157. package/templates/editor/.github/skills/zen-finetune/scripts/batch.mjs +390 -0
  158. package/templates/editor/.github/skills/zen-finetune/scripts/difficult.mjs +243 -0
  159. package/templates/editor/.github/skills/zen-finetune/scripts/memory.mjs +280 -0
  160. package/templates/editor/.github/skills/zen-finetune/scripts/next.mjs +398 -0
  161. package/templates/editor/.github/skills/zen-finetune/scripts/report.mjs +797 -0
  162. package/templates/editor/.github/skills/zen-finetune/scripts/select.mjs +354 -0
  163. package/templates/editor/.github/skills/zen-finetune/scripts/usage.mjs +722 -0
  164. package/templates/editor/.github/skills/zen-inspect/SKILL.md +431 -0
  165. package/templates/editor/.github/skills/zen-inspect-ask/SKILL.md +270 -0
  166. package/templates/editor/.github/skills/zen-memory/SKILL.md +78 -29
  167. package/templates/editor/.github/skills/zen-memory-warmup/SKILL.md +363 -531
  168. package/templates/editor/.github/skills/zen-rag-docs/SKILL.md +20 -8
  169. package/templates/editor/.github/skills/zen-review/SKILL.md +5 -3
  170. package/templates/editor/.github/skills/zen-review/scripts/check-paths.sh +5 -4
  171. package/templates/editor/.github/skills/zen-sandbox/SKILL.md +25 -2
  172. package/templates/editor/.github/skills/zen-sandbox-capacity/SKILL.md +334 -0
  173. package/templates/editor/.github/skills/zen-sandbox-capacity/references/loadtest.md +181 -0
  174. package/templates/editor/.github/skills/zen-sandbox-capacity/scripts/preflight_sandbox.sh +457 -0
  175. package/templates/editor/.github/skills/zen-topology/SKILL.md +283 -0
  176. package/templates/editor/.vscode/agents.schema.json +1 -1
  177. package/templates/editor/.vscode/settings.json +2 -0
  178. package/templates/project/agents/files-instructions.md +35 -13
  179. package/templates/project/agents/fork-instructions.md +27 -0
  180. package/templates/project/agents/memory-instructions.md +106 -34
  181. package/templates/project/agents/tools-instructions.md +7 -4
  182. package/templates/project/gitignore +5 -0
  183. package/dist/meta.d.ts +0 -221
  184. package/dist/meta.js +0 -684
@@ -1,21 +1,38 @@
1
+ import { join } from 'node:path';
1
2
  import { parse } from "../args.js";
2
3
  // Run ids are timestamps by construction, so the newest id *is* the last-run
3
4
  // time — no file has to be opened to learn it.
4
5
  import { stampInstant } from "../ids.js";
5
- import { openDir, Registry, summarize } from "../projects.js";
6
- import { listSessions } from "../session.js";
7
- import { ago, bold, count, dim, json, note, table, write, writeAll, yellow } from "../term.js";
8
- const USAGE = 'zen list [--sessions] [--prune]';
6
+ import { openDir, Registry, runIds, sessionIds, sessionsDir, summarize, } from "../projects.js";
7
+ import { listSessions, readRunMeta, runPaths, sessionPaths } from "../session.js";
8
+ import { ago, bold, count, cyan, dim, json, note, red, table, usageError, write, writeAll, yellow, } from "../term.js";
9
+ const USAGE = 'zen list [--sessions] [--runs] [--limit <n>] [--prune]';
10
+ /** Recent runs shown before `--limit` is asked for. */
11
+ const RECENT = 20;
9
12
  export const list = {
10
13
  summary: 'Every known project: sessions, last run, whether one is live.',
11
14
  usage: USAGE,
12
15
  banner: { head: 'Zenera', accent: 'Projects', subtitle: 'Project Registry', hue: 'sky' },
13
16
  details: [
17
+ " --sessions Also list each project's sessions.",
18
+ ' --runs The most recent runs, newest first, across every project.',
19
+ ' --limit <n> Runs to list. Default 20.',
20
+ ' --prune Forget entries whose directory has gone away.',
21
+ '',
22
+ '--runs answers "what ran last", which is not a question about one',
23
+ 'project, so on its own it replaces the table rather than following it.',
24
+ '',
14
25
  'The registry is an index, not the truth. An entry whose directory has',
15
26
  'gone away is shown dimmed rather than hidden; --prune forgets them.',
16
27
  ],
17
28
  run: async (ctx) => {
18
- const { values } = parse(ctx.args, { sessions: { type: 'boolean' }, prune: { type: 'boolean' } }, USAGE);
29
+ const { values } = parse(ctx.args, {
30
+ sessions: { type: 'boolean' },
31
+ runs: { type: 'boolean' },
32
+ limit: { type: 'string' },
33
+ prune: { type: 'boolean' },
34
+ }, USAGE);
35
+ const limit = number(values.limit, '--limit') ?? RECENT;
19
36
  const registry = await Registry.open();
20
37
  if (values.prune) {
21
38
  const gone = registry.prune();
@@ -29,8 +46,18 @@ export const list = {
29
46
  summaries.push(await summarize(entry));
30
47
  }
31
48
  summaries.sort((a, b) => (b.lastRunAt ?? '').localeCompare(a.lastRunAt ?? ''));
49
+ // `--runs` asks a question about runs, so on its own it *replaces* the
50
+ // project table rather than following thirty rows of it. Asked together
51
+ // with `--sessions`, both are wanted and both are printed.
52
+ const projectTable = !values.runs || values.sessions;
32
53
  if (ctx.json) {
33
- json(values.sessions ? await withSessions(summaries) : summaries);
54
+ const runs = values.runs ? await recent(summaries, limit).runs : undefined;
55
+ if (!projectTable) {
56
+ json(runs);
57
+ return;
58
+ }
59
+ const projects = values.sessions ? await withSessions(summaries) : summaries;
60
+ json(runs ? { projects, runs } : projects);
34
61
  return;
35
62
  }
36
63
  if (summaries.length === 0) {
@@ -38,20 +65,22 @@ export const list = {
38
65
  note(dim('create one: zen init'));
39
66
  return;
40
67
  }
41
- const rows = [
42
- [bold('NAME'), bold('SESSIONS'), bold('RUNS'), bold('LAST'), bold('PATH')],
43
- ];
44
- for (const s of summaries) {
45
- const style = s.present ? (x) => x : dim;
46
- rows.push([
47
- style(s.name) + (s.busy ? yellow(' •') : ''),
48
- style(String(s.sessions)),
49
- style(String(s.runs)),
50
- style(ago(s.lastRunAt ? stampInstant(s.lastRunAt) : undefined)),
51
- dim(s.present ? s.path : `${s.path} (missing)`),
52
- ]);
68
+ if (projectTable) {
69
+ const rows = [
70
+ [bold('NAME'), bold('SESSIONS'), bold('RUNS'), bold('LAST'), bold('PATH')],
71
+ ];
72
+ for (const s of summaries) {
73
+ const style = s.present ? (x) => x : dim;
74
+ rows.push([
75
+ style(s.name) + (s.busy ? yellow(' •') : ''),
76
+ style(String(s.sessions)),
77
+ style(String(s.runs)),
78
+ style(ago(s.lastRunAt ? stampInstant(s.lastRunAt) : undefined)),
79
+ dim(s.present ? s.path : `${s.path} (missing)`),
80
+ ]);
81
+ }
82
+ writeAll(table(rows));
53
83
  }
54
- writeAll(table(rows));
55
84
  if (values.sessions) {
56
85
  for (const s of summaries.filter((p) => p.present)) {
57
86
  write('');
@@ -59,8 +88,88 @@ export const list = {
59
88
  writeAll(await sessionRows(s));
60
89
  }
61
90
  }
91
+ if (values.runs) {
92
+ if (projectTable) {
93
+ write('');
94
+ }
95
+ await writeRuns(summaries, limit);
96
+ }
62
97
  },
63
98
  };
99
+ function keys(summaries) {
100
+ const out = [];
101
+ for (const project of summaries) {
102
+ if (!project.present) {
103
+ continue;
104
+ }
105
+ for (const session of sessionIds(project.path)) {
106
+ for (const id of runIds(join(sessionsDir(project.path), session))) {
107
+ out.push({ project, session, id });
108
+ }
109
+ }
110
+ }
111
+ return out.sort((a, b) => b.id.localeCompare(a.id));
112
+ }
113
+ function recent(summaries, limit) {
114
+ const all = keys(summaries);
115
+ const runs = Promise.all(all.slice(0, limit).map(async (k) => {
116
+ const run = runPaths(sessionPaths(k.project.path, k.session), k.id);
117
+ const meta = await readRunMeta(run);
118
+ return {
119
+ id: k.id,
120
+ project: k.project.name,
121
+ session: k.session,
122
+ dir: run.dir,
123
+ startedAt: meta.startedAt ?? stampInstant(k.id),
124
+ finishedAt: meta.finishedAt,
125
+ agent: meta.agent,
126
+ stopReason: meta.stopReason,
127
+ error: meta.error,
128
+ };
129
+ }));
130
+ return { runs, found: all.length };
131
+ }
132
+ async function writeRuns(summaries, limit) {
133
+ const { runs, found } = recent(summaries, limit);
134
+ const rows = await runs;
135
+ if (rows.length === 0) {
136
+ note('no runs yet');
137
+ note(dim('start one: zen run'));
138
+ return;
139
+ }
140
+ writeAll(table([
141
+ [
142
+ bold('RUN'),
143
+ bold('PROJECT'),
144
+ bold('SESSION'),
145
+ bold('AGENT'),
146
+ bold('OUTCOME'),
147
+ bold('WHEN'),
148
+ ],
149
+ ...rows.map((r) => [
150
+ r.id,
151
+ cyan(r.project),
152
+ dim(r.session),
153
+ r.agent ?? dim('—'),
154
+ r.error ? red('failed') : (r.stopReason ?? dim('—')),
155
+ ago(r.finishedAt ?? r.startedAt),
156
+ ]),
157
+ ]));
158
+ if (found > rows.length) {
159
+ note('');
160
+ note(dim(`${found - rows.length} more — raise --limit to see them`));
161
+ }
162
+ }
163
+ function number(text, flag) {
164
+ if (text === undefined) {
165
+ return undefined;
166
+ }
167
+ const value = Number(text);
168
+ if (!Number.isInteger(value) || value < 1) {
169
+ throw usageError(`${flag} takes a whole number of at least 1`, `got "${text}"`);
170
+ }
171
+ return value;
172
+ }
64
173
  /**
65
174
  * Run ids are timestamps by construction, so the newest id *is* the last-run
66
175
  * time — no file has to be opened to learn it.