@neonwatty/limner 0.1.5 → 0.1.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.
- package/README.md +27 -1
- package/dist/commands/compare-image-reference.d.ts +3 -0
- package/dist/commands/compare-image-reference.js +16 -1
- package/dist/commands/compare-image-reference.js.map +1 -1
- package/dist/commands/compare-output.d.ts +2 -0
- package/dist/commands/compare-output.js +20 -0
- package/dist/commands/compare-output.js.map +1 -0
- package/dist/commands/compare.d.ts +3 -0
- package/dist/commands/compare.js +10 -19
- package/dist/commands/compare.js.map +1 -1
- package/dist/commands/ledger.d.ts +4 -1
- package/dist/commands/loop-actions.d.ts +22 -0
- package/dist/commands/loop-actions.js +54 -0
- package/dist/commands/loop-actions.js.map +1 -0
- package/dist/commands/loop-cli.js +96 -2
- package/dist/commands/loop-cli.js.map +1 -1
- package/dist/commands/loop-comparison-adapters.d.ts +3 -0
- package/dist/commands/loop-comparison-adapters.js +15 -1
- package/dist/commands/loop-comparison-adapters.js.map +1 -1
- package/dist/commands/loop-task.d.ts +17 -0
- package/dist/commands/loop-task.js +95 -0
- package/dist/commands/loop-task.js.map +1 -0
- package/dist/commands/loop.d.ts +3 -1
- package/dist/commands/loop.js +31 -14
- package/dist/commands/loop.js.map +1 -1
- package/dist/core/agent-comparison-pack.d.ts +13 -0
- package/dist/core/agent-comparison-pack.js +27 -21
- package/dist/core/agent-comparison-pack.js.map +1 -1
- package/dist/core/agent-comparison-response.d.ts +19 -0
- package/dist/core/agent-comparison-response.js +34 -0
- package/dist/core/agent-comparison-response.js.map +1 -0
- package/dist/core/agent-task-brief.d.ts +30 -0
- package/dist/core/agent-task-brief.js +158 -0
- package/dist/core/agent-task-brief.js.map +1 -0
- package/dist/core/comparison-artifacts.d.ts +12 -0
- package/dist/core/comparison-artifacts.js +50 -0
- package/dist/core/comparison-artifacts.js.map +1 -0
- package/dist/core/current-artifacts.d.ts +14 -0
- package/dist/core/current-artifacts.js +16 -0
- package/dist/core/current-artifacts.js.map +1 -0
- package/dist/core/ledger-agent-responses.d.ts +21 -0
- package/dist/core/ledger-agent-responses.js +13 -0
- package/dist/core/ledger-agent-responses.js.map +1 -0
- package/dist/core/ledger-db.js +28 -0
- package/dist/core/ledger-db.js.map +1 -1
- package/dist/core/ledger-events.js +46 -7
- package/dist/core/ledger-events.js.map +1 -1
- package/dist/core/ledger-markdown.d.ts +23 -4
- package/dist/core/ledger-markdown.js +133 -4
- package/dist/core/ledger-markdown.js.map +1 -1
- package/dist/core/ledger-queries.d.ts +5 -1
- package/dist/core/ledger-queries.js +14 -4
- package/dist/core/ledger-queries.js.map +1 -1
- package/dist/core/ledger-store.d.ts +11 -3
- package/dist/core/ledger-store.js +4 -0
- package/dist/core/ledger-store.js.map +1 -1
- package/dist/core/loop-rerun-command.d.ts +4 -0
- package/dist/core/loop-rerun-command.js +36 -0
- package/dist/core/loop-rerun-command.js.map +1 -0
- package/dist/core/runtime-context.d.ts +1 -0
- package/dist/core/runtime-context.js +18 -0
- package/dist/core/runtime-context.js.map +1 -0
- package/dist/schemas/ledger.d.ts +33 -0
- package/dist/schemas/ledger.js +13 -0
- package/dist/schemas/ledger.js.map +1 -1
- package/docs/agent-workflow.md +31 -1
- package/docs/superpowers/plans/2026-06-13-agent-response-sqlite.md +70 -0
- package/docs/superpowers/plans/2026-06-13-loop-action-ledger.md +257 -0
- package/package.json +1 -1
- package/skills/limner/SKILL.md +15 -4
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { agentComparisonBundleSchema } from '../schemas/comparison.js';
|
|
4
|
+
export async function buildAgentTaskBrief(input) {
|
|
5
|
+
const raw = await readFile(input.comparisonSummaryPath, 'utf8');
|
|
6
|
+
const bundle = agentComparisonBundleSchema.parse(JSON.parse(raw));
|
|
7
|
+
const diffs = [
|
|
8
|
+
...bundle.imageComparison.majorDiffAreas,
|
|
9
|
+
...(bundle.structureComparison?.majorDiffAreas ?? []),
|
|
10
|
+
].sort((left, right) => left.priority - right.priority);
|
|
11
|
+
const topFix = bundle.recommendation.topFix ?? diffs[0]?.recommendedChange;
|
|
12
|
+
const editableFiles = unique(diffs.flatMap((diff) => diff.fixTarget?.likelyFiles ?? []));
|
|
13
|
+
const selectors = unique(diffs.flatMap((diff) => diff.fixTarget?.selectors ?? []));
|
|
14
|
+
const actionStartCommand = buildActionStartCommand(input, topFix);
|
|
15
|
+
const actionCompleteCommandExample = buildActionCompleteCommand(input, editableFiles);
|
|
16
|
+
const json = {
|
|
17
|
+
trajectoryId: input.trajectoryId,
|
|
18
|
+
target: input.target,
|
|
19
|
+
mode: input.mode,
|
|
20
|
+
profile: bundle.profile,
|
|
21
|
+
topFix,
|
|
22
|
+
editableFiles,
|
|
23
|
+
selectors,
|
|
24
|
+
sourceRunId: input.sourceRunId,
|
|
25
|
+
desiredExecutor: input.desiredExecutor,
|
|
26
|
+
actionStartCommand,
|
|
27
|
+
actionCompleteCommandExample,
|
|
28
|
+
rerunCommand: input.rerunCommand,
|
|
29
|
+
};
|
|
30
|
+
return { json, markdown: formatMarkdown(input, bundle, diffs, topFix, editableFiles, selectors, actionStartCommand, actionCompleteCommandExample) };
|
|
31
|
+
}
|
|
32
|
+
function formatMarkdown(input, bundle, diffs, topFix, editableFiles, selectors, actionStartCommand, actionCompleteCommandExample) {
|
|
33
|
+
const actionSkipCommand = buildActionSkipCommand(input);
|
|
34
|
+
const lines = [
|
|
35
|
+
'# Limner Agent Task',
|
|
36
|
+
'',
|
|
37
|
+
`Trajectory: \`${input.trajectoryId}\``,
|
|
38
|
+
`Target: \`${input.target}\``,
|
|
39
|
+
`Mode: \`${input.mode}\``,
|
|
40
|
+
`Profile: \`${bundle.profile}\``,
|
|
41
|
+
`Overall score: \`${bundle.imageComparison.score.overall}\``,
|
|
42
|
+
`Comparison summary: \`${relative(input.workspaceRoot, input.comparisonSummaryPath)}\``,
|
|
43
|
+
'',
|
|
44
|
+
'## Recommended Fix',
|
|
45
|
+
'',
|
|
46
|
+
topFix ? `Top fix: ${topFix}` : 'Top fix: none provided.',
|
|
47
|
+
...recommendationLines(bundle),
|
|
48
|
+
'',
|
|
49
|
+
'## Editable Files',
|
|
50
|
+
'',
|
|
51
|
+
...listOrNone(editableFiles),
|
|
52
|
+
'',
|
|
53
|
+
'## Selectors',
|
|
54
|
+
'',
|
|
55
|
+
...listOrNone(selectors),
|
|
56
|
+
'',
|
|
57
|
+
'## Priority Diffs',
|
|
58
|
+
'',
|
|
59
|
+
...diffLines(diffs),
|
|
60
|
+
'',
|
|
61
|
+
'## Next Iteration',
|
|
62
|
+
'',
|
|
63
|
+
`Focus: ${bundle.imageComparison.nextIteration.focus}`,
|
|
64
|
+
...bundle.imageComparison.nextIteration.steps.map((step) => `- ${step}`),
|
|
65
|
+
'',
|
|
66
|
+
'## Action Logging',
|
|
67
|
+
'',
|
|
68
|
+
`Start: \`${actionStartCommand}\``,
|
|
69
|
+
`Complete: \`${actionCompleteCommandExample}\``,
|
|
70
|
+
`Skip: \`${actionSkipCommand}\``,
|
|
71
|
+
'',
|
|
72
|
+
'## Verify',
|
|
73
|
+
'',
|
|
74
|
+
`Run: \`${input.rerunCommand}\``,
|
|
75
|
+
];
|
|
76
|
+
return `${lines.join('\n')}\n`;
|
|
77
|
+
}
|
|
78
|
+
function recommendationLines(bundle) {
|
|
79
|
+
const lines = [];
|
|
80
|
+
if (bundle.recommendation.why)
|
|
81
|
+
lines.push(`Why: ${bundle.recommendation.why}`);
|
|
82
|
+
if (bundle.recommendation.expectedScoreLift !== undefined) {
|
|
83
|
+
lines.push(`Expected lift: \`${bundle.recommendation.expectedScoreLift}\``);
|
|
84
|
+
}
|
|
85
|
+
return lines;
|
|
86
|
+
}
|
|
87
|
+
function diffLines(diffs) {
|
|
88
|
+
if (diffs.length === 0)
|
|
89
|
+
return ['- None reported.'];
|
|
90
|
+
return diffs.flatMap((diff) => [
|
|
91
|
+
`- P${diff.priority} ${diff.title}`,
|
|
92
|
+
` - Severity: \`${diff.severity}\``,
|
|
93
|
+
` - Category: \`${diff.category}\``,
|
|
94
|
+
` - Expected: ${diff.expected}`,
|
|
95
|
+
` - Actual: ${diff.actual}`,
|
|
96
|
+
` - Recommended change: ${diff.recommendedChange}`,
|
|
97
|
+
]);
|
|
98
|
+
}
|
|
99
|
+
function listOrNone(values) {
|
|
100
|
+
return values.length > 0 ? values.map((value) => `- \`${value}\``) : ['- None provided.'];
|
|
101
|
+
}
|
|
102
|
+
function unique(values) {
|
|
103
|
+
return [...new Set(values)];
|
|
104
|
+
}
|
|
105
|
+
function buildActionStartCommand(input, topFix) {
|
|
106
|
+
return [
|
|
107
|
+
'limner loop action start',
|
|
108
|
+
'--trajectory',
|
|
109
|
+
input.trajectoryId,
|
|
110
|
+
'--from-run',
|
|
111
|
+
input.sourceRunId,
|
|
112
|
+
'--kind polish',
|
|
113
|
+
'--executor',
|
|
114
|
+
input.desiredExecutor,
|
|
115
|
+
'--summary',
|
|
116
|
+
shellQuote(summaryText(topFix)),
|
|
117
|
+
].join(' ');
|
|
118
|
+
}
|
|
119
|
+
function buildActionCompleteCommand(input, editableFiles) {
|
|
120
|
+
const files = editableFiles.length > 0 ? editableFiles.join(',') : '<edited-files>';
|
|
121
|
+
return [
|
|
122
|
+
'limner loop action complete',
|
|
123
|
+
'--trajectory',
|
|
124
|
+
input.trajectoryId,
|
|
125
|
+
'--action <action-id>',
|
|
126
|
+
'--executor',
|
|
127
|
+
input.desiredExecutor,
|
|
128
|
+
'--summary',
|
|
129
|
+
shellQuote('Describe completed changes'),
|
|
130
|
+
'--files',
|
|
131
|
+
shellQuote(files),
|
|
132
|
+
].join(' ');
|
|
133
|
+
}
|
|
134
|
+
function buildActionSkipCommand(input) {
|
|
135
|
+
return [
|
|
136
|
+
'limner loop action skip',
|
|
137
|
+
'--trajectory',
|
|
138
|
+
input.trajectoryId,
|
|
139
|
+
'--from-run',
|
|
140
|
+
input.sourceRunId,
|
|
141
|
+
'--executor',
|
|
142
|
+
input.desiredExecutor,
|
|
143
|
+
'--summary',
|
|
144
|
+
shellQuote('No edits needed after review'),
|
|
145
|
+
].join(' ');
|
|
146
|
+
}
|
|
147
|
+
function summaryText(topFix) {
|
|
148
|
+
const summary = topFix ?? 'Polish visual fidelity from validated comparison';
|
|
149
|
+
return summary.length <= 255 ? summary : summary.slice(0, 252).trimEnd() + '...';
|
|
150
|
+
}
|
|
151
|
+
function shellQuote(value) {
|
|
152
|
+
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
153
|
+
}
|
|
154
|
+
function relative(root, filePath) {
|
|
155
|
+
const relativePath = path.relative(root, filePath);
|
|
156
|
+
return relativePath.startsWith('..') ? filePath : relativePath;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=agent-task-brief.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-task-brief.js","sourceRoot":"","sources":["../../src/core/agent-task-brief.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,2BAA2B,EAA8B,MAAM,0BAA0B,CAAC;AAkCnG,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,KAA0B;IAClE,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,2BAA2B,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAClE,MAAM,KAAK,GAAG;QACZ,GAAG,MAAM,CAAC,eAAe,CAAC,cAAc;QACxC,GAAG,CAAC,MAAM,CAAC,mBAAmB,EAAE,cAAc,IAAI,EAAE,CAAC;KACtD,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK,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AC,OAAO,EAAE,GAAG,KAAK,CAAC;AACnF,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC;AAC/C,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,QAAgB;IAC9C,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnD,OAAO,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentComparisonPackResult } from './agent-comparison-pack.js';
|
|
2
|
+
import type { LedgerArtifactRef } from '../schemas/ledger.js';
|
|
3
|
+
export declare function artifact(path: string | undefined, kind: string): LedgerArtifactRef[];
|
|
4
|
+
export declare function agentComparisonArtifacts(agentComparison: AgentComparisonPackResult | undefined): LedgerArtifactRef[];
|
|
5
|
+
export declare function referenceImplementationArtifacts(input: {
|
|
6
|
+
referencePath: string;
|
|
7
|
+
implementationPath: string;
|
|
8
|
+
sideBySidePath: string;
|
|
9
|
+
metricsPath: string;
|
|
10
|
+
reportPath: string;
|
|
11
|
+
agentComparison?: AgentComparisonPackResult;
|
|
12
|
+
}): LedgerArtifactRef[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
export function artifact(path, kind) {
|
|
3
|
+
return path ? [{ path, kind, role: 'artifact' }] : [];
|
|
4
|
+
}
|
|
5
|
+
function expectedOutput(path, kind, exists = false) {
|
|
6
|
+
return path ? [{ path, kind, role: 'expected-output', exists }] : [];
|
|
7
|
+
}
|
|
8
|
+
export function agentComparisonArtifacts(agentComparison) {
|
|
9
|
+
if (!agentComparison)
|
|
10
|
+
return [];
|
|
11
|
+
return [
|
|
12
|
+
...artifact(agentComparison.promptPath, 'agent-comparison-prompt'),
|
|
13
|
+
...artifact(agentComparison.codexPromptPath, 'agent-comparison-prompt-codex'),
|
|
14
|
+
...artifact(agentComparison.claudePromptPath, 'agent-comparison-prompt-claude'),
|
|
15
|
+
...artifact(agentComparison.schemaPath, 'agent-comparison-schema'),
|
|
16
|
+
...artifact(agentComparison.examplePath, 'agent-comparison-example'),
|
|
17
|
+
...expectedOutput(agentComparison.responsePath, 'agent-response-target', agentComparison.status !== 'awaiting-agent'),
|
|
18
|
+
...agentComparisonOutputArtifacts(agentComparison),
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
function agentComparisonOutputArtifacts(agentComparison) {
|
|
22
|
+
if (agentComparison.status === 'validated') {
|
|
23
|
+
return [
|
|
24
|
+
...artifact(agentComparison.imageComparisonPath, 'image-comparison'),
|
|
25
|
+
...artifact(agentComparison.structureComparisonPath, 'structure-comparison'),
|
|
26
|
+
...artifact(agentComparison.summaryPath, 'comparison-summary'),
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
const captureDir = path.dirname(path.dirname(agentComparison.responsePath));
|
|
30
|
+
return [
|
|
31
|
+
{ path: path.join(captureDir, 'image-comparison.json'), kind: 'image-comparison', role: 'artifact', exists: false },
|
|
32
|
+
{ path: path.join(captureDir, 'structure-comparison.json'), kind: 'structure-comparison', role: 'artifact', exists: false },
|
|
33
|
+
{ path: path.join(captureDir, 'comparison-summary.json'), kind: 'comparison-summary', role: 'artifact', exists: false },
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
export function referenceImplementationArtifacts(input) {
|
|
37
|
+
return [
|
|
38
|
+
...artifact(input.referencePath, 'reference-screenshot'),
|
|
39
|
+
...artifact(`${input.referencePath}.console.json`, 'reference-console-log'),
|
|
40
|
+
...artifact(`${input.referencePath}.metrics.json`, 'reference-dom-metrics'),
|
|
41
|
+
...artifact(input.implementationPath, 'implementation-screenshot'),
|
|
42
|
+
...artifact(`${input.implementationPath}.console.json`, 'implementation-console-log'),
|
|
43
|
+
...artifact(`${input.implementationPath}.metrics.json`, 'implementation-dom-metrics'),
|
|
44
|
+
...artifact(input.sideBySidePath, 'side-by-side'),
|
|
45
|
+
...artifact(input.metricsPath, 'dom-metrics'),
|
|
46
|
+
...artifact(input.reportPath, 'report'),
|
|
47
|
+
...agentComparisonArtifacts(input.agentComparison),
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=comparison-artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comparison-artifacts.js","sourceRoot":"","sources":["../../src/core/comparison-artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAK7B,MAAM,UAAU,QAAQ,CAAC,IAAwB,EAAE,IAAY;IAC7D,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACxD,CAAC;AAED,SAAS,cAAc,CAAC,IAAwB,EAAE,IAAY,EAAE,MAAM,GAAG,KAAK;IAC5E,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,eAAsD;IAC7F,IAAI,CAAC,eAAe;QAAE,OAAO,EAAE,CAAC;IAChC,OAAO;QACL,GAAG,QAAQ,CAAC,eAAe,CAAC,UAAU,EAAE,yBAAyB,CAAC;QAClE,GAAG,QAAQ,CAAC,eAAe,CAAC,eAAe,EAAE,+BAA+B,CAAC;QAC7E,GAAG,QAAQ,CAAC,eAAe,CAAC,gBAAgB,EAAE,gCAAgC,CAAC;QAC/E,GAAG,QAAQ,CAAC,eAAe,CAAC,UAAU,EAAE,yBAAyB,CAAC;QAClE,GAAG,QAAQ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EAAE,sBAAsB,CAAC;QACxD,GAAG,QAAQ,CAAC,GAAG,KAAK,CAAC,aAAa,eAAe,EAAE,uBAAuB,CAAC;QAC3E,GAAG,QAAQ,CAAC,GAAG,KAAK,CAAC,aAAa,eAAe,EAAE,uBAAuB,CAAC;QAC3E,GAAG,QAAQ,CAAC,KAAK,CAAC,kBAAkB,EAAE,2BAA2B,CAAC;QAClE,GAAG,QAAQ,CAAC,GAAG,KAAK,CAAC,kBAAkB,eAAe,EAAE,4BAA4B,CAAC;QACrF,GAAG,QAAQ,CAAC,GAAG,KAAK,CAAC,kBAAkB,eAAe,EAAE,4BAA4B,CAAC;QACrF,GAAG,QAAQ,CAAC,KAAK,CAAC,cAAc,EAAE,cAAc,CAAC;QACjD,GAAG,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE,aAAa,CAAC;QAC7C,GAAG,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC;QACvC,GAAG,wBAAwB,CAAC,KAAK,CAAC,eAAe,CAAC;KACnD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type LedgerArtifactRow = {
|
|
2
|
+
artifactId?: string;
|
|
3
|
+
kind: string;
|
|
4
|
+
path: string;
|
|
5
|
+
role?: string | null;
|
|
6
|
+
existsOnDisk?: number | null;
|
|
7
|
+
snapshotPath?: string | null;
|
|
8
|
+
};
|
|
9
|
+
export type CurrentArtifacts = {
|
|
10
|
+
all: LedgerArtifactRow[];
|
|
11
|
+
writtenArtifacts: LedgerArtifactRow[];
|
|
12
|
+
expectedOutputs: LedgerArtifactRow[];
|
|
13
|
+
};
|
|
14
|
+
export declare function getCurrentArtifacts(artifacts: LedgerArtifactRow[]): CurrentArtifacts;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function getCurrentArtifacts(artifacts) {
|
|
2
|
+
const byKey = new Map();
|
|
3
|
+
for (const artifact of artifacts) {
|
|
4
|
+
byKey.set(artifactKey(artifact), artifact);
|
|
5
|
+
}
|
|
6
|
+
const all = [...byKey.values()];
|
|
7
|
+
return {
|
|
8
|
+
all,
|
|
9
|
+
writtenArtifacts: all.filter((artifact) => artifact.role !== 'expected-output'),
|
|
10
|
+
expectedOutputs: all.filter((artifact) => artifact.role === 'expected-output'),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function artifactKey(artifact) {
|
|
14
|
+
return [artifact.role ?? 'artifact', artifact.kind, artifact.path].join('\0');
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=current-artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-artifacts.js","sourceRoot":"","sources":["../../src/core/current-artifacts.ts"],"names":[],"mappings":"AAeA,MAAM,UAAU,mBAAmB,CAAC,SAA8B;IAChE,MAAM,KAAK,GAAG,IAAI,GAAG,EAA6B,CAAC;IACnD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IACD,MAAM,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAChC,OAAO;QACL,GAAG;QACH,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,iBAAiB,CAAC;QAC/E,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,iBAAiB,CAAC;KAC/E,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,QAA2B;IAC9C,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,UAAU,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AgentResponseFreshness } from './agent-comparison-response.js';
|
|
2
|
+
import type { LedgerDatabase } from './ledger-db.js';
|
|
3
|
+
import type { LedgerMode } from '../schemas/ledger.js';
|
|
4
|
+
export type RecordAgentResponseInput = {
|
|
5
|
+
trajectoryId: string;
|
|
6
|
+
iterationId?: string;
|
|
7
|
+
runId?: string;
|
|
8
|
+
mode: LedgerMode;
|
|
9
|
+
profile?: string;
|
|
10
|
+
responsePath: string;
|
|
11
|
+
responseHash?: string;
|
|
12
|
+
freshness: AgentResponseFreshness;
|
|
13
|
+
validationStatus: string;
|
|
14
|
+
inputFingerprint?: unknown;
|
|
15
|
+
responseJson?: string;
|
|
16
|
+
score?: unknown;
|
|
17
|
+
topFix?: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function insertAgentResponse(db: LedgerDatabase, input: RecordAgentResponseInput, now: string): {
|
|
20
|
+
responseId: string;
|
|
21
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createLedgerId } from './ledger-ids.js';
|
|
2
|
+
export function insertAgentResponse(db, input, now) {
|
|
3
|
+
const responseId = createLedgerId('resp');
|
|
4
|
+
db.prepare(`
|
|
5
|
+
insert into agent_responses (
|
|
6
|
+
response_id, trajectory_id, iteration_id, run_id, mode, profile, response_path,
|
|
7
|
+
response_hash, freshness, validation_status, input_fingerprint_json,
|
|
8
|
+
response_json, score_json, top_fix, created_at
|
|
9
|
+
) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
10
|
+
`).run(responseId, input.trajectoryId, input.iterationId ?? null, input.runId ?? null, input.mode, input.profile ?? null, input.responsePath, input.responseHash ?? null, input.freshness, input.validationStatus, input.inputFingerprint === undefined ? null : JSON.stringify(input.inputFingerprint), input.responseJson ?? null, input.score === undefined ? null : JSON.stringify(input.score), input.topFix ?? null, now);
|
|
11
|
+
return { responseId };
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=ledger-agent-responses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger-agent-responses.js","sourceRoot":"","sources":["../../src/core/ledger-agent-responses.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAmBjD,MAAM,UAAU,mBAAmB,CAAC,EAAkB,EAAE,KAA+B,EAAE,GAAW;IAClG,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAC1C,EAAE,CAAC,OAAO,CAAC;;;;;;GAMV,CAAC,CAAC,GAAG,CACJ,UAAU,EACV,KAAK,CAAC,YAAY,EAClB,KAAK,CAAC,WAAW,IAAI,IAAI,EACzB,KAAK,CAAC,KAAK,IAAI,IAAI,EACnB,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,OAAO,IAAI,IAAI,EACrB,KAAK,CAAC,YAAY,EAClB,KAAK,CAAC,YAAY,IAAI,IAAI,EAC1B,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,gBAAgB,EACtB,KAAK,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,gBAAgB,CAAC,EACpF,KAAK,CAAC,YAAY,IAAI,IAAI,EAC1B,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,EAC9D,KAAK,CAAC,MAAM,IAAI,IAAI,EACpB,GAAG,CACJ,CAAC;IACF,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC"}
|
package/dist/core/ledger-db.js
CHANGED
|
@@ -61,6 +61,8 @@ function migrate(db) {
|
|
|
61
61
|
run_id text,
|
|
62
62
|
kind text not null,
|
|
63
63
|
path text not null,
|
|
64
|
+
role text not null default 'artifact',
|
|
65
|
+
exists_on_disk integer,
|
|
64
66
|
hash text,
|
|
65
67
|
snapshot_path text,
|
|
66
68
|
created_at text not null
|
|
@@ -98,9 +100,35 @@ function migrate(db) {
|
|
|
98
100
|
created_at text not null
|
|
99
101
|
);
|
|
100
102
|
|
|
103
|
+
create table if not exists agent_responses (
|
|
104
|
+
response_id text primary key,
|
|
105
|
+
trajectory_id text not null references trajectories(trajectory_id) on delete cascade,
|
|
106
|
+
iteration_id text,
|
|
107
|
+
run_id text,
|
|
108
|
+
mode text not null,
|
|
109
|
+
profile text,
|
|
110
|
+
response_path text not null,
|
|
111
|
+
response_hash text,
|
|
112
|
+
freshness text not null,
|
|
113
|
+
validation_status text not null,
|
|
114
|
+
input_fingerprint_json text,
|
|
115
|
+
response_json text,
|
|
116
|
+
score_json text,
|
|
117
|
+
top_fix text,
|
|
118
|
+
created_at text not null
|
|
119
|
+
);
|
|
120
|
+
|
|
101
121
|
insert into schema_meta (key, value)
|
|
102
122
|
values ('schemaVersion', '${schemaVersion}')
|
|
103
123
|
on conflict(key) do update set value = excluded.value;
|
|
104
124
|
`);
|
|
125
|
+
ensureColumn(db, 'artifacts', 'role', "text not null default 'artifact'");
|
|
126
|
+
ensureColumn(db, 'artifacts', 'exists_on_disk', 'integer');
|
|
127
|
+
}
|
|
128
|
+
function ensureColumn(db, tableName, columnName, definition) {
|
|
129
|
+
const columns = db.prepare(`pragma table_info(${tableName})`).all();
|
|
130
|
+
if (!columns.some((column) => column.name === columnName)) {
|
|
131
|
+
db.exec(`alter table ${tableName} add column ${columnName} ${definition}`);
|
|
132
|
+
}
|
|
105
133
|
}
|
|
106
134
|
//# sourceMappingURL=ledger-db.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger-db.js","sourceRoot":"","sources":["../../src/core/ledger-db.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,IAAI,MAAM,WAAW,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;;;;;;;;;;;;gCA6GsB,aAAa;;GAE1C,CAAC,CAAC;IACH,YAAY,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,kCAAkC,CAAC,CAAC;IAC1E,YAAY,CAAC,EAAE,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,YAAY,CAAC,EAAkB,EAAE,SAAiB,EAAE,UAAkB,EAAE,UAAkB;IACjG,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,qBAAqB,SAAS,GAAG,CAAC,CAAC,GAAG,EAAwB,CAAC;IAC1F,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,EAAE,CAAC;QAC1D,EAAE,CAAC,IAAI,CAAC,eAAe,SAAS,eAAe,UAAU,IAAI,UAAU,EAAE,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC"}
|
|
@@ -1,23 +1,62 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { agentFeedbackSchema, ledgerActionSummarySchema, ledgerArtifactRefSchema } from '../schemas/ledger.js';
|
|
2
3
|
import { createLedgerId } from './ledger-ids.js';
|
|
4
|
+
const actionInputsSummaryMessage = 'loop.action inputsSummary must be valid JSON object with a summary';
|
|
3
5
|
export function insertLedgerEvent(db, input, now) {
|
|
4
6
|
const feedback = agentFeedbackSchema.parse(input.agentFeedback);
|
|
7
|
+
validateActionSummary(input);
|
|
5
8
|
db.prepare(`
|
|
6
9
|
insert into ledger_events (
|
|
7
10
|
event_id, trajectory_id, iteration_id, run_id, event_type, actor, command,
|
|
8
11
|
inputs_summary, result_status, artifact_refs_json, agent_feedback, notes, created_at
|
|
9
12
|
) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
10
13
|
`).run(createLedgerId('evt'), input.trajectoryId ?? null, input.iterationId ?? null, input.runId ?? null, input.eventType, input.actor ?? 'cli', input.command ?? null, input.inputsSummary ?? null, input.resultStatus ?? null, JSON.stringify(input.artifactRefs ?? []), feedback ?? null, input.notes ?? null, now);
|
|
14
|
+
if (input.trajectoryId && input.iterationId && input.runId) {
|
|
15
|
+
db.prepare(`
|
|
16
|
+
insert into runs (run_id, trajectory_id, iteration_id, command, status, started_at, completed_at)
|
|
17
|
+
values (?, ?, ?, ?, ?, ?, ?)
|
|
18
|
+
on conflict(run_id) do update set status = excluded.status, completed_at = excluded.completed_at
|
|
19
|
+
`).run(input.runId, input.trajectoryId, input.iterationId, input.command ?? 'unknown', input.resultStatus ?? 'unknown', now, now);
|
|
20
|
+
}
|
|
11
21
|
if (input.trajectoryId) {
|
|
12
|
-
for (const
|
|
13
|
-
|
|
14
|
-
continue;
|
|
22
|
+
for (const ref of input.artifactRefs ?? []) {
|
|
23
|
+
const artifact = normalizeArtifactRef(ref);
|
|
15
24
|
db.prepare(`
|
|
16
25
|
insert into artifacts (
|
|
17
|
-
artifact_id, trajectory_id, iteration_id, run_id, kind, path, hash, snapshot_path, created_at
|
|
18
|
-
) values (?, ?, ?, ?,
|
|
19
|
-
`).run(createLedgerId('art'), input.trajectoryId, input.iterationId ?? null, input.runId ?? null,
|
|
26
|
+
artifact_id, trajectory_id, iteration_id, run_id, kind, path, role, exists_on_disk, hash, snapshot_path, created_at
|
|
27
|
+
) values (?, ?, ?, ?, ?, ?, ?, ?, null, null, ?)
|
|
28
|
+
`).run(createLedgerId('art'), input.trajectoryId, input.iterationId ?? null, input.runId ?? null, artifact.kind, artifact.path, artifact.role, artifact.exists ? 1 : 0, now);
|
|
20
29
|
}
|
|
21
30
|
}
|
|
22
31
|
}
|
|
32
|
+
function validateActionSummary(input) {
|
|
33
|
+
if (!input.eventType.startsWith('loop.action.')) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const parsed = parseActionInputsSummary(input.inputsSummary);
|
|
37
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed) || !('summary' in parsed)) {
|
|
38
|
+
throw new Error(actionInputsSummaryMessage);
|
|
39
|
+
}
|
|
40
|
+
ledgerActionSummarySchema.parse(parsed.summary);
|
|
41
|
+
}
|
|
42
|
+
function parseActionInputsSummary(inputsSummary) {
|
|
43
|
+
try {
|
|
44
|
+
return JSON.parse(inputsSummary ?? 'null');
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
throw new Error(actionInputsSummaryMessage);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function normalizeArtifactRef(ref) {
|
|
51
|
+
const parsed = ledgerArtifactRefSchema.parse(ref);
|
|
52
|
+
if (typeof parsed === 'string') {
|
|
53
|
+
return { path: parsed, kind: 'event-artifact', role: 'artifact', exists: existsSync(parsed) };
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
path: parsed.path,
|
|
57
|
+
kind: parsed.kind,
|
|
58
|
+
role: parsed.role,
|
|
59
|
+
exists: parsed.exists ?? existsSync(parsed.path),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
23
62
|
//# sourceMappingURL=ledger-events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger-events.js","sourceRoot":"","sources":["../../src/core/ledger-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ledger-events.js","sourceRoot":"","sources":["../../src/core/ledger-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,uBAAuB,EAA0B,MAAM,sBAAsB,CAAC;AAGvI,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,0BAA0B,GAAG,oEAAoE,CAAC;AAExG,MAAM,UAAU,iBAAiB,CAAC,EAAkB,EAAE,KAAuB,EA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AAE,gBAAgB,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;IAChG,CAAC;IACD,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC;KACjD,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
type ArtifactRow = {
|
|
2
|
+
kind: string;
|
|
3
|
+
path: string;
|
|
4
|
+
role?: string;
|
|
5
|
+
existsOnDisk?: number | null;
|
|
6
|
+
snapshotPath?: string | null;
|
|
7
|
+
};
|
|
1
8
|
type ExportedTrajectory = {
|
|
2
9
|
trajectory: {
|
|
3
10
|
trajectoryId: string;
|
|
@@ -15,17 +22,29 @@ type ExportedTrajectory = {
|
|
|
15
22
|
eventType: string;
|
|
16
23
|
actor?: string;
|
|
17
24
|
command?: string;
|
|
25
|
+
runId?: string;
|
|
26
|
+
inputsSummary?: string;
|
|
18
27
|
resultStatus?: string;
|
|
19
28
|
artifactRefsJson?: string;
|
|
20
29
|
agentFeedback?: string;
|
|
21
30
|
notes?: string;
|
|
22
31
|
createdAt?: string;
|
|
23
32
|
}>;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
agentResponses?: Array<{
|
|
34
|
+
responseId: string;
|
|
35
|
+
runId?: string;
|
|
36
|
+
responsePath: string;
|
|
37
|
+
responseHash?: string;
|
|
38
|
+
freshness: string;
|
|
39
|
+
validationStatus: string;
|
|
40
|
+
scoreJson?: string;
|
|
41
|
+
topFix?: string;
|
|
28
42
|
}>;
|
|
43
|
+
artifacts: ArtifactRow[];
|
|
44
|
+
currentArtifacts?: {
|
|
45
|
+
writtenArtifacts: ArtifactRow[];
|
|
46
|
+
expectedOutputs: ArtifactRow[];
|
|
47
|
+
};
|
|
29
48
|
};
|
|
30
49
|
export declare function formatLedgerMarkdown(exported: ExportedTrajectory): string;
|
|
31
50
|
export {};
|