@zenera/meta 1.3.27 → 1.3.29
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/chat/index.d.ts +1 -0
- package/dist/chat/index.js +3 -1
- package/dist/dataset/changes.js +12 -5
- package/dist/dataset/export.d.ts +1 -0
- package/dist/dataset/types.d.ts +8 -0
- package/dist/dataset/types.js +2 -0
- package/dist/finetune/command.js +21 -5
- package/dist/finetune/live.d.ts +4 -0
- package/dist/finetune/live.js +8 -3
- package/dist/finetune/memories.js +3 -1
- package/dist/finetune/next-case.d.ts +6 -1
- package/dist/finetune/next-case.js +10 -1
- package/dist/finetune/report.d.ts +26 -0
- package/dist/finetune/report.js +39 -0
- package/dist/prompts.d.ts +17 -0
- package/dist/prompts.js +41 -0
- package/package.json +5 -5
package/dist/chat/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { openMetaChat, type MetaChat, type MetaChatOptions } from './open.ts';
|
|
|
2
2
|
export { EFFORTS, type ChatEvent, type Connect, type TurnResult } from './session.ts';
|
|
3
3
|
export type { Answer, Described } from './permissions.ts';
|
|
4
4
|
export type { MetaCall } from '../tokens.ts';
|
|
5
|
+
export { expandCommand, listCommands, type CommandInfo } from '../prompts.ts';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/chat/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// packages/meta/src/chat/index.ts
|
|
2
2
|
//
|
|
3
3
|
// `@zenera/meta/chat`: the meta agent as a conversation, for a host that draws its own chat (no terminal, no Ink).
|
|
4
|
-
// Main: `openMetaChat`, and the event and permission types it speaks in
|
|
4
|
+
// Main: `openMetaChat`, and the event and permission types it speaks in; `expandCommand` and `listCommands`
|
|
5
|
+
// for a host's `/name` commands.
|
|
5
6
|
// Used by: hosts such as the ZeneraLite project manager; `zen meta chat` itself goes through `chat/run.ts`.
|
|
6
7
|
export { openMetaChat } from "./open.js";
|
|
7
8
|
export { EFFORTS } from "./session.js";
|
|
9
|
+
export { expandCommand, listCommands } from "../prompts.js";
|
|
8
10
|
//# sourceMappingURL=index.js.map
|
package/dist/dataset/changes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { invalidError } from "../host.js";
|
|
2
2
|
import { canonical, Sources } from "./anchors.js";
|
|
3
|
-
import { anchorText, CONTENT_FIELDS, RESTART_FIELDS, sameAnchor, } from "./types.js";
|
|
3
|
+
import { anchorText, CONTENT_FIELDS, questionRev, RESTART_FIELDS, sameAnchor, } from "./types.js";
|
|
4
4
|
const same = (a, b) => canonical(a ?? null) === canonical(b ?? null);
|
|
5
5
|
/**
|
|
6
6
|
* Rubric items keep their ids across edits, so a note saying `r3 failed` still
|
|
@@ -84,6 +84,11 @@ function fieldChanges(before, after) {
|
|
|
84
84
|
}
|
|
85
85
|
return out;
|
|
86
86
|
}
|
|
87
|
+
/** The case with `questionRev` set, or without it when the question is its own revision's. */
|
|
88
|
+
function withQuestion(c, rev) {
|
|
89
|
+
const { questionRev: _, ...rest } = c;
|
|
90
|
+
return rev !== undefined && rev !== c.rev ? { ...rest, questionRev: rev } : rest;
|
|
91
|
+
}
|
|
87
92
|
const restarts = (changes) => changes.some((c) => RESTART_FIELDS.some((f) => c.path === f || c.path.startsWith(`${f}/`)));
|
|
88
93
|
/** Fills in each case's source hash; a source that cannot be found is refused. */
|
|
89
94
|
function hashSources(sources, nexts) {
|
|
@@ -166,7 +171,8 @@ function finish(store, sources, nexts, why, by) {
|
|
|
166
171
|
};
|
|
167
172
|
for (const { before, after } of nexts) {
|
|
168
173
|
if (!before) {
|
|
169
|
-
const
|
|
174
|
+
const { questionRev: _, ...fresh } = after;
|
|
175
|
+
const added = { ...fresh, rev };
|
|
170
176
|
rows.push({ type: 'change', rev, at, op: 'add', changes: [], why, by, case: added });
|
|
171
177
|
revision.added.push(after.id);
|
|
172
178
|
continue;
|
|
@@ -182,14 +188,15 @@ function finish(store, sources, nexts, why, by) {
|
|
|
182
188
|
}
|
|
183
189
|
if (!op) {
|
|
184
190
|
if (before.source?.sha256 !== after.source?.sha256) {
|
|
185
|
-
refreshed.push({ ...after, rev: before.rev });
|
|
191
|
+
refreshed.push(withQuestion({ ...after, rev: before.rev }, before.questionRev));
|
|
186
192
|
}
|
|
187
193
|
else {
|
|
188
194
|
unchanged.push(after.id);
|
|
189
195
|
}
|
|
190
196
|
continue;
|
|
191
197
|
}
|
|
192
|
-
const
|
|
198
|
+
const restarted = op !== 'retire' && restarts(changes);
|
|
199
|
+
const written = withQuestion({ ...after, rev }, restarted ? undefined : questionRev(before));
|
|
193
200
|
rows.push({ type: 'change', rev, at, op, changes, why, by, case: written });
|
|
194
201
|
if (op === 'retire') {
|
|
195
202
|
revision.retired.push(after.id);
|
|
@@ -200,7 +207,7 @@ function finish(store, sources, nexts, why, by) {
|
|
|
200
207
|
else {
|
|
201
208
|
revision.updated.push(after.id);
|
|
202
209
|
}
|
|
203
|
-
if (
|
|
210
|
+
if (restarted) {
|
|
204
211
|
revision.restarted.push(after.id);
|
|
205
212
|
}
|
|
206
213
|
}
|
package/dist/dataset/export.d.ts
CHANGED
package/dist/dataset/types.d.ts
CHANGED
|
@@ -50,7 +50,15 @@ export interface Case {
|
|
|
50
50
|
source?: Source;
|
|
51
51
|
/** fields a re-extraction must not overwrite */
|
|
52
52
|
overrides?: string[];
|
|
53
|
+
/**
|
|
54
|
+
* The revision that last set what the case asks or how it is judged
|
|
55
|
+
* (`RESTART_FIELDS`), when a later one changed only the rest. Absent, it is
|
|
56
|
+
* `rev`. Results kept against it still hold after a change to tags or notes.
|
|
57
|
+
*/
|
|
58
|
+
questionRev?: number;
|
|
53
59
|
}
|
|
60
|
+
/** The revision whose results still hold for the case: the last that restarted it. */
|
|
61
|
+
export declare const questionRev: (c: Pick<Case, "rev" | "questionRev">) => number;
|
|
54
62
|
/** A change to these is a different question: earlier results no longer count. */
|
|
55
63
|
export declare const RESTART_FIELDS: readonly ["input", "rubric", "expected"];
|
|
56
64
|
/** Fields a proposal or `update --set` may write. */
|
package/dist/dataset/types.js
CHANGED
|
@@ -21,6 +21,8 @@ export const VERDICTS = ['right', 'wrong', 'void'];
|
|
|
21
21
|
/** A case id names a directory under a batch dir, so it is one path segment. */
|
|
22
22
|
export const CASE_ID = /^[A-Za-z0-9_.-]+$/;
|
|
23
23
|
export const MEDIA_KINDS = ['image', 'audio', 'video', 'file'];
|
|
24
|
+
/** The revision whose results still hold for the case: the last that restarted it. */
|
|
25
|
+
export const questionRev = (c) => c.questionRev ?? c.rev;
|
|
24
26
|
/** A change to these is a different question: earlier results no longer count. */
|
|
25
27
|
export const RESTART_FIELDS = ['input', 'rubric', 'expected'];
|
|
26
28
|
/** Fields a proposal or `update --set` may write. */
|
package/dist/finetune/command.js
CHANGED
|
@@ -12,9 +12,9 @@ import { costChanges, measure, overLimits } from "./cost.js";
|
|
|
12
12
|
import { drift } from "../dataset/drift.js";
|
|
13
13
|
import { DatasetStore } from "../dataset/store.js";
|
|
14
14
|
import { runLoop } from "./loop.js";
|
|
15
|
-
import { analyzeSession, attemptsOf } from "./report.js";
|
|
15
|
+
import { analyzeSession, attemptsOf, caseRows } from "./report.js";
|
|
16
16
|
import { retry } from "./retry.js";
|
|
17
|
-
import { resultOf, selection } from "./next-case.js";
|
|
17
|
+
import { resultOf, selection, tuned } from "./next-case.js";
|
|
18
18
|
import { DEFAULTS, FAILURES_IN_A_ROW, FINETUNE_DIR, LEGACY_FINETUNE_DIR, readJson, spawnZen, Tuning, } from "./tuning.js";
|
|
19
19
|
import { liveView, startView } from "./view.js";
|
|
20
20
|
// ---------------------------------------------------------------------------
|
|
@@ -287,6 +287,11 @@ async function start(ctx, project, values, options) {
|
|
|
287
287
|
t.stop('interrupted');
|
|
288
288
|
return;
|
|
289
289
|
}
|
|
290
|
+
kill(130);
|
|
291
|
+
};
|
|
292
|
+
// The children are process groups of their own, so a signal to the loop
|
|
293
|
+
// alone leaves them running. SIGTERM - a host stopping the job - takes them down too.
|
|
294
|
+
const kill = (code) => {
|
|
290
295
|
for (const child of children) {
|
|
291
296
|
try {
|
|
292
297
|
process.kill(-child.pid, 'SIGTERM');
|
|
@@ -295,9 +300,13 @@ async function start(ctx, project, values, options) {
|
|
|
295
300
|
// Already gone.
|
|
296
301
|
}
|
|
297
302
|
}
|
|
298
|
-
process.exit(
|
|
303
|
+
process.exit(code);
|
|
304
|
+
};
|
|
305
|
+
const onTerminate = () => {
|
|
306
|
+
kill(143);
|
|
299
307
|
};
|
|
300
308
|
process.on('SIGINT', onInterrupt);
|
|
309
|
+
process.on('SIGTERM', onTerminate);
|
|
301
310
|
note(`${bold('tuning')} ${project.name} · ${config.workers} workers · apply at ${config.applyAt}`);
|
|
302
311
|
const viewing = options.zen ? undefined : await viewOf(project.dir);
|
|
303
312
|
const url = viewing?.url ?? liveView(project.dir);
|
|
@@ -316,6 +325,7 @@ async function start(ctx, project, values, options) {
|
|
|
316
325
|
finally {
|
|
317
326
|
close?.();
|
|
318
327
|
process.off('SIGINT', onInterrupt);
|
|
328
|
+
process.off('SIGTERM', onTerminate);
|
|
319
329
|
await viewing?.close();
|
|
320
330
|
}
|
|
321
331
|
if (!ctx.json) {
|
|
@@ -349,11 +359,16 @@ function status(ctx, project) {
|
|
|
349
359
|
const c = counts(project.dir);
|
|
350
360
|
const url = liveView(project.dir);
|
|
351
361
|
if (ctx.json) {
|
|
362
|
+
const t = new Tuning(project.dir, readConfig(project.dir), async () => ({
|
|
363
|
+
code: 1,
|
|
364
|
+
stdout: '',
|
|
365
|
+
}));
|
|
352
366
|
return json({
|
|
353
367
|
running: Boolean(holder),
|
|
354
368
|
...c,
|
|
355
369
|
status: join(dir, 'STATUS.md'),
|
|
356
370
|
...(url ? { url } : {}),
|
|
371
|
+
cases: caseRows(t),
|
|
357
372
|
});
|
|
358
373
|
}
|
|
359
374
|
write(`${bold(project.name)} ${holder ? green(`running (pid ${holder.pid})`) : dim('not running')}`);
|
|
@@ -439,10 +454,11 @@ function session(project, rest) {
|
|
|
439
454
|
if (!id) {
|
|
440
455
|
throw usageError('session of which case?', 'zen meta finetune session <case>');
|
|
441
456
|
}
|
|
442
|
-
const
|
|
443
|
-
if (!
|
|
457
|
+
const found = DatasetStore.open(project.dir).get(id);
|
|
458
|
+
if (!found) {
|
|
444
459
|
throw invalidError(`no case ${id}`);
|
|
445
460
|
}
|
|
461
|
+
const c = tuned(found);
|
|
446
462
|
const t = new Tuning(project.dir, readConfig(project.dir), async () => ({
|
|
447
463
|
code: 1,
|
|
448
464
|
stdout: '',
|
package/dist/finetune/live.d.ts
CHANGED
|
@@ -33,6 +33,10 @@ export interface NowRow {
|
|
|
33
33
|
now?: string;
|
|
34
34
|
/** the last few such lines, oldest first */
|
|
35
35
|
recent?: string[];
|
|
36
|
+
/** the case a worker holds */
|
|
37
|
+
case?: string;
|
|
38
|
+
/** the step's `--events` JSONL, project-relative, for a viewer that follows it */
|
|
39
|
+
events?: string;
|
|
36
40
|
}
|
|
37
41
|
export interface TokenRow extends ModelSpend {
|
|
38
42
|
stage: Stage;
|
package/dist/finetune/live.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { closeSync, fstatSync, mkdirSync, openSync, readSync, renameSync, writeFileSync, } from 'node:fs';
|
|
2
|
-
import { basename, join } from 'node:path';
|
|
2
|
+
import { basename, join, relative } from 'node:path';
|
|
3
3
|
import { modelName, STAGES } from "./usage.js";
|
|
4
4
|
const KEEP_LINES = 200;
|
|
5
5
|
const KEEP_LOG = 50;
|
|
@@ -146,7 +146,8 @@ export function snapshot(t) {
|
|
|
146
146
|
continue;
|
|
147
147
|
}
|
|
148
148
|
const dir = t.workDir({ ...w, case: w.case });
|
|
149
|
-
const
|
|
149
|
+
const events = join(dir, w.step === 'run' ? 'events.jsonl' : 'analyze.events.jsonl');
|
|
150
|
+
const act = watch(events);
|
|
150
151
|
now.push({
|
|
151
152
|
key: `w${w.slot}`,
|
|
152
153
|
who: `worker ${w.slot}`,
|
|
@@ -156,12 +157,15 @@ export function snapshot(t) {
|
|
|
156
157
|
stage: w.step,
|
|
157
158
|
act,
|
|
158
159
|
...(act.now ? { now: act.now, recent: [...act.recent] } : {}),
|
|
160
|
+
case: w.case.id,
|
|
161
|
+
events: relative(t.root, events),
|
|
159
162
|
});
|
|
160
163
|
}
|
|
161
164
|
const q = t.improvements;
|
|
162
165
|
if (q.current?.dir) {
|
|
163
166
|
const checking = q.current.step === 'check';
|
|
164
|
-
const
|
|
167
|
+
const events = join(q.current.dir, 'apply.events.jsonl');
|
|
168
|
+
const act = watch(events);
|
|
165
169
|
const line = checking ? CHECK_NOW : act.now;
|
|
166
170
|
const recent = checking ? [...act.recent, CHECK_NOW].slice(-KEEP_NOW) : [...act.recent];
|
|
167
171
|
now.push({
|
|
@@ -173,6 +177,7 @@ export function snapshot(t) {
|
|
|
173
177
|
stage: 'apply',
|
|
174
178
|
act,
|
|
175
179
|
...(line ? { now: line, recent } : {}),
|
|
180
|
+
events: relative(t.root, events),
|
|
176
181
|
});
|
|
177
182
|
}
|
|
178
183
|
else if (q.current) {
|
|
@@ -3,6 +3,7 @@ import { appendFileSync, cpSync, mkdirSync, readFileSync, rmSync } from 'node:fs
|
|
|
3
3
|
import { basename, join } from 'node:path';
|
|
4
4
|
import { DatasetStore } from "../dataset/store.js";
|
|
5
5
|
import { errorIn, sizeOf } from "./failure.js";
|
|
6
|
+
import { tuned } from "./next-case.js";
|
|
6
7
|
import { writeFeedback } from "./report.js";
|
|
7
8
|
function rows(file) {
|
|
8
9
|
try {
|
|
@@ -153,7 +154,8 @@ export class Memories {
|
|
|
153
154
|
}
|
|
154
155
|
const store = DatasetStore.open(this.#t.root);
|
|
155
156
|
for (const s of fresh) {
|
|
156
|
-
const
|
|
157
|
+
const found = store.get(s.case);
|
|
158
|
+
const c = found && tuned(found);
|
|
157
159
|
if (c?.rev === s.rev) {
|
|
158
160
|
writeFeedback(this.#t, c);
|
|
159
161
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Case } from '../dataset/types.ts';
|
|
2
2
|
import { type Tuning } from './tuning.ts';
|
|
3
3
|
import type { ByStage } from './usage.ts';
|
|
4
4
|
export interface Result {
|
|
@@ -11,6 +11,11 @@ export interface Result {
|
|
|
11
11
|
/** per stage and model, over every try of the case */
|
|
12
12
|
tokens?: ByStage;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The case as a tuning knows it: at the revision that last changed what it asks
|
|
16
|
+
* or how it is judged. A change to its tags, class or notes keeps its results.
|
|
17
|
+
*/
|
|
18
|
+
export declare function tuned(c: Case): Case;
|
|
14
19
|
/** The cases this tuning covers, in the order they are taken. */
|
|
15
20
|
export declare function selection(t: Tuning): Case[];
|
|
16
21
|
export declare function resultOf(t: Tuning, c: Case): Result | undefined;
|
|
@@ -3,11 +3,20 @@ import { existsSync } from 'node:fs';
|
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { sample } from "../dataset/sample.js";
|
|
5
5
|
import { DatasetStore } from "../dataset/store.js";
|
|
6
|
+
import { questionRev } from "../dataset/types.js";
|
|
6
7
|
import { readJson } from "./tuning.js";
|
|
8
|
+
/**
|
|
9
|
+
* The case as a tuning knows it: at the revision that last changed what it asks
|
|
10
|
+
* or how it is judged. A change to its tags, class or notes keeps its results.
|
|
11
|
+
*/
|
|
12
|
+
export function tuned(c) {
|
|
13
|
+
const rev = questionRev(c);
|
|
14
|
+
return rev === c.rev ? c : { ...c, rev };
|
|
15
|
+
}
|
|
7
16
|
/** The cases this tuning covers, in the order they are taken. */
|
|
8
17
|
export function selection(t) {
|
|
9
18
|
const store = DatasetStore.open(t.root);
|
|
10
|
-
const cases = store.all();
|
|
19
|
+
const cases = store.all().map(tuned);
|
|
11
20
|
const ids = anyOf((t.config.ids ?? []).map((p) => wildcard(p)));
|
|
12
21
|
const drawn = sample(cases, {
|
|
13
22
|
status: 'active',
|
|
@@ -19,6 +19,32 @@ export declare function attemptsOf(t: Tuning, c: Case): Attempt[];
|
|
|
19
19
|
/** Every try of a case, per stage and model. Applies serve many cases at once, so they are not split. */
|
|
20
20
|
export declare function caseTokens(t: Tuning, c: Case): ByStage;
|
|
21
21
|
export declare const rubricScore: (f: Attempt["feedback"]) => string;
|
|
22
|
+
/** One case of the selection as `finetune status --json` lists it: what is on disk, not what a worker holds. */
|
|
23
|
+
export interface CaseRow {
|
|
24
|
+
id: string;
|
|
25
|
+
class?: string;
|
|
26
|
+
/** the revision the tuning knows it at */
|
|
27
|
+
rev: number;
|
|
28
|
+
rubric: number;
|
|
29
|
+
state: 'queued' | 'stopped' | 'completed' | 'difficult' | 'failed';
|
|
30
|
+
/** of the result, or of the latest try */
|
|
31
|
+
phase?: Phase;
|
|
32
|
+
reason?: string;
|
|
33
|
+
tries: Record<Phase, number>;
|
|
34
|
+
verdict?: Feedback['verdict'];
|
|
35
|
+
/** the latest analysis' grade per rubric line */
|
|
36
|
+
grades?: Feedback['rubric'];
|
|
37
|
+
/** rubric lines that analysis graded `invalid`, with what it says is wrong */
|
|
38
|
+
rubricProblems?: {
|
|
39
|
+
lines: string[];
|
|
40
|
+
why: string[];
|
|
41
|
+
};
|
|
42
|
+
summary?: string;
|
|
43
|
+
tokens: ByStage;
|
|
44
|
+
/** project-relative */
|
|
45
|
+
feedback?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function caseRows(t: Tuning): CaseRow[];
|
|
22
48
|
export declare function feedbackPath(t: Tuning, c: {
|
|
23
49
|
id: string;
|
|
24
50
|
}): string;
|
package/dist/finetune/report.js
CHANGED
|
@@ -379,6 +379,45 @@ function stateOf(t, c) {
|
|
|
379
379
|
}
|
|
380
380
|
return attemptsOf(t, c).length > 0 ? 'stopped' : 'queued';
|
|
381
381
|
}
|
|
382
|
+
export function caseRows(t) {
|
|
383
|
+
return selection(t).map((c) => {
|
|
384
|
+
const r = resultOf(t, c);
|
|
385
|
+
const attempts = attemptsOf(t, c);
|
|
386
|
+
const last = [...attempts].reverse().find((a) => a.feedback)?.feedback;
|
|
387
|
+
const invalid = Object.entries(last?.rubric ?? {})
|
|
388
|
+
.filter(([, g]) => g === 'invalid')
|
|
389
|
+
.map(([id]) => id);
|
|
390
|
+
const feedback = feedbackPath(t, c);
|
|
391
|
+
return {
|
|
392
|
+
id: c.id,
|
|
393
|
+
...(c.class ? { class: c.class } : {}),
|
|
394
|
+
rev: c.rev,
|
|
395
|
+
rubric: c.rubric.length,
|
|
396
|
+
state: r?.state ?? (attempts.length > 0 ? 'stopped' : 'queued'),
|
|
397
|
+
...((r?.phase ?? attempts.at(-1)?.phase)
|
|
398
|
+
? { phase: r?.phase ?? attempts.at(-1).phase }
|
|
399
|
+
: {}),
|
|
400
|
+
...(r?.reason ? { reason: r.reason } : {}),
|
|
401
|
+
tries: {
|
|
402
|
+
nomem: attempts.filter((a) => a.phase === 'nomem').length,
|
|
403
|
+
mem: attempts.filter((a) => a.phase === 'mem').length,
|
|
404
|
+
},
|
|
405
|
+
...(last
|
|
406
|
+
? { verdict: last.verdict, grades: last.rubric, summary: lead(last.summary) }
|
|
407
|
+
: {}),
|
|
408
|
+
...(invalid.length > 0
|
|
409
|
+
? {
|
|
410
|
+
rubricProblems: {
|
|
411
|
+
lines: invalid,
|
|
412
|
+
why: (last?.improvements ?? []).filter(forDataset).map((i) => i.change),
|
|
413
|
+
},
|
|
414
|
+
}
|
|
415
|
+
: {}),
|
|
416
|
+
tokens: caseTokens(t, c),
|
|
417
|
+
...(existsSync(feedback) ? { feedback: relative(t.root, feedback) } : {}),
|
|
418
|
+
};
|
|
419
|
+
});
|
|
420
|
+
}
|
|
382
421
|
// ---------------------------------------------------------------------------
|
|
383
422
|
// FEEDBACK.md - one case
|
|
384
423
|
// ---------------------------------------------------------------------------
|
package/dist/prompts.d.ts
CHANGED
|
@@ -20,4 +20,21 @@ export declare function readPrompt(path: string, name: string, text: string): St
|
|
|
20
20
|
export declare function loadPrompt(dir: string, name: string): Promise<StoredPrompt>;
|
|
21
21
|
/** The commands a person may type: every skill not marked for the model only, and any legacy prompt file. */
|
|
22
22
|
export declare function listPrompts(dir: string): Promise<string[]>;
|
|
23
|
+
export interface CommandInfo {
|
|
24
|
+
name: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
/** the frontmatter's `argument-hint` */
|
|
27
|
+
hint?: string;
|
|
28
|
+
}
|
|
29
|
+
/** The commands a person may type, with what an editor shows beside each. */
|
|
30
|
+
export declare function listCommands(dir: string): Promise<CommandInfo[]>;
|
|
31
|
+
/**
|
|
32
|
+
* A chat message as the model should get it: `/name words` becomes the body of
|
|
33
|
+
* the command it names with the words after it, as `zen meta chat` does. Text
|
|
34
|
+
* that names no command a person may type - prose, a path - goes as it is.
|
|
35
|
+
*/
|
|
36
|
+
export declare function expandCommand(dir: string, text: string): Promise<{
|
|
37
|
+
prompt: string;
|
|
38
|
+
command?: string;
|
|
39
|
+
}>;
|
|
23
40
|
//# sourceMappingURL=prompts.d.ts.map
|
package/dist/prompts.js
CHANGED
|
@@ -73,6 +73,47 @@ export async function listPrompts(dir) {
|
|
|
73
73
|
}
|
|
74
74
|
return [...names].sort();
|
|
75
75
|
}
|
|
76
|
+
/** The commands a person may type, with what an editor shows beside each. */
|
|
77
|
+
export async function listCommands(dir) {
|
|
78
|
+
const out = [];
|
|
79
|
+
for (const name of await listPrompts(dir)) {
|
|
80
|
+
const path = promptPath(dir, name);
|
|
81
|
+
let text;
|
|
82
|
+
try {
|
|
83
|
+
text = await readFile(path, 'utf8');
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const { description } = readPrompt(path, name, text);
|
|
89
|
+
const hint = /^argument-hint:\s*(.+)$/m.exec(/^---\r?\n([\s\S]*?)\r?\n---/.exec(text)?.[1] ?? '')?.[1];
|
|
90
|
+
out.push({
|
|
91
|
+
name,
|
|
92
|
+
...(description ? { description } : {}),
|
|
93
|
+
...(hint ? { hint: hint.trim().replace(/^['"]|['"]$/g, '') } : {}),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
const COMMAND = /^\/([a-z0-9][a-z0-9-]*)(?:\s+([\s\S]*))?$/;
|
|
99
|
+
/**
|
|
100
|
+
* A chat message as the model should get it: `/name words` becomes the body of
|
|
101
|
+
* the command it names with the words after it, as `zen meta chat` does. Text
|
|
102
|
+
* that names no command a person may type - prose, a path - goes as it is.
|
|
103
|
+
*/
|
|
104
|
+
export async function expandCommand(dir, text) {
|
|
105
|
+
const match = COMMAND.exec(text.trim());
|
|
106
|
+
if (!match) {
|
|
107
|
+
return { prompt: text };
|
|
108
|
+
}
|
|
109
|
+
const [, name, words = ''] = match;
|
|
110
|
+
if (!(await listPrompts(dir)).includes(name)) {
|
|
111
|
+
return { prompt: text };
|
|
112
|
+
}
|
|
113
|
+
const found = await loadPrompt(dir, name);
|
|
114
|
+
const extra = words.trim();
|
|
115
|
+
return { prompt: extra ? `${found.body}\n\n${extra}` : found.body, command: name };
|
|
116
|
+
}
|
|
76
117
|
function entries(path) {
|
|
77
118
|
try {
|
|
78
119
|
return readdirSync(path);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenera/meta",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.29",
|
|
4
4
|
"description": "The meta agent for zen: GitHub Copilot over a zen project on your own keys, plus the dataset and fine-tuning loop.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@github/copilot-sdk": "^1.0.32",
|
|
51
51
|
"@inkjs/ui": "^2.0.0",
|
|
52
|
-
"@zenera/cli": "^1.3.
|
|
53
|
-
"@zenera/engine": "^1.3.
|
|
54
|
-
"@zenera/neo": "^1.3.
|
|
55
|
-
"@zenera/view": "^1.3.
|
|
52
|
+
"@zenera/cli": "^1.3.29",
|
|
53
|
+
"@zenera/engine": "^1.3.29",
|
|
54
|
+
"@zenera/neo": "^1.3.29",
|
|
55
|
+
"@zenera/view": "^1.3.29",
|
|
56
56
|
"google-auth-library": "^10.0.0",
|
|
57
57
|
"ink": "^7.1.1",
|
|
58
58
|
"react": "^19.2.8",
|