sequant 1.1.0 → 1.1.1
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/bin/cli.js +12 -0
- package/dist/bin/cli.js.map +1 -1
- package/dist/src/commands/doctor.d.ts.map +1 -1
- package/dist/src/commands/doctor.js +1 -25
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/doctor.test.js +28 -97
- package/dist/src/commands/doctor.test.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +3 -27
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/init.test.js +32 -75
- package/dist/src/commands/init.test.js.map +1 -1
- package/dist/src/commands/logs.d.ts +18 -0
- package/dist/src/commands/logs.d.ts.map +1 -0
- package/dist/src/commands/logs.js +188 -0
- package/dist/src/commands/logs.js.map +1 -0
- package/dist/src/commands/run.d.ts +2 -0
- package/dist/src/commands/run.d.ts.map +1 -1
- package/dist/src/commands/run.js +114 -29
- package/dist/src/commands/run.js.map +1 -1
- package/dist/src/lib/system.d.ts +16 -0
- package/dist/src/lib/system.d.ts.map +1 -0
- package/dist/src/lib/system.js +52 -0
- package/dist/src/lib/system.js.map +1 -0
- package/dist/src/lib/system.test.d.ts +2 -0
- package/dist/src/lib/system.test.d.ts.map +1 -0
- package/dist/src/lib/system.test.js +80 -0
- package/dist/src/lib/system.test.js.map +1 -0
- package/dist/src/lib/workflow/log-writer.d.ts +83 -0
- package/dist/src/lib/workflow/log-writer.d.ts.map +1 -0
- package/dist/src/lib/workflow/log-writer.js +193 -0
- package/dist/src/lib/workflow/log-writer.js.map +1 -0
- package/dist/src/lib/workflow/run-log-schema.d.ts +261 -0
- package/dist/src/lib/workflow/run-log-schema.d.ts.map +1 -0
- package/dist/src/lib/workflow/run-log-schema.js +234 -0
- package/dist/src/lib/workflow/run-log-schema.js.map +1 -0
- package/package.json +3 -2
- package/templates/skills/assess/SKILL.md +15 -0
- package/templates/skills/clean/SKILL.md +15 -0
- package/templates/skills/docs/SKILL.md +16 -0
- package/templates/skills/exec/SKILL.md +14 -0
- package/templates/skills/fullsolve/SKILL.md +16 -0
- package/templates/skills/loop/SKILL.md +14 -0
- package/templates/skills/qa/SKILL.md +67 -0
- package/templates/skills/reflect/SKILL.md +14 -0
- package/templates/skills/security-review/SKILL.md +15 -0
- package/templates/skills/solve/SKILL.md +44 -0
- package/templates/skills/spec/SKILL.md +59 -0
- package/templates/skills/test/SKILL.md +14 -0
- package/templates/skills/testgen/SKILL.md +15 -0
- package/templates/skills/verify/SKILL.md +15 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log writer for structured workflow run logs
|
|
3
|
+
*
|
|
4
|
+
* Writes JSON logs to disk for analysis and debugging.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { LogWriter } from './log-writer';
|
|
9
|
+
*
|
|
10
|
+
* const writer = new LogWriter({ projectPath: '.sequant/logs' });
|
|
11
|
+
* await writer.initialize(config);
|
|
12
|
+
* await writer.logPhase(phaseLog);
|
|
13
|
+
* await writer.finalize();
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
import * as fs from "fs";
|
|
17
|
+
import * as path from "path";
|
|
18
|
+
import * as os from "os";
|
|
19
|
+
import { createEmptyRunLog, finalizeRunLog, generateLogFilename, LOG_PATHS, } from "./run-log-schema.js";
|
|
20
|
+
/**
|
|
21
|
+
* Manages writing structured run logs to disk
|
|
22
|
+
*/
|
|
23
|
+
export class LogWriter {
|
|
24
|
+
runLog = null;
|
|
25
|
+
currentIssue = null;
|
|
26
|
+
logPath;
|
|
27
|
+
writeToUserLogs;
|
|
28
|
+
verbose;
|
|
29
|
+
constructor(options = {}) {
|
|
30
|
+
this.logPath = options.logPath ?? LOG_PATHS.project;
|
|
31
|
+
this.writeToUserLogs = options.writeToUserLogs ?? false;
|
|
32
|
+
this.verbose = options.verbose ?? false;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Initialize a new run log
|
|
36
|
+
*
|
|
37
|
+
* @param config - Run configuration
|
|
38
|
+
*/
|
|
39
|
+
async initialize(config) {
|
|
40
|
+
this.runLog = createEmptyRunLog(config);
|
|
41
|
+
// Ensure log directory exists
|
|
42
|
+
await this.ensureLogDirectory(this.logPath);
|
|
43
|
+
if (this.writeToUserLogs) {
|
|
44
|
+
const userPath = LOG_PATHS.user.replace("~", os.homedir());
|
|
45
|
+
await this.ensureLogDirectory(userPath);
|
|
46
|
+
}
|
|
47
|
+
if (this.verbose && this.runLog) {
|
|
48
|
+
console.log(`📝 Log initialized: ${this.runLog.runId}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Start logging a new issue
|
|
53
|
+
*
|
|
54
|
+
* @param issueNumber - GitHub issue number
|
|
55
|
+
* @param title - Issue title
|
|
56
|
+
* @param labels - Issue labels
|
|
57
|
+
*/
|
|
58
|
+
startIssue(issueNumber, title, labels) {
|
|
59
|
+
if (!this.runLog) {
|
|
60
|
+
throw new Error("LogWriter not initialized. Call initialize() first.");
|
|
61
|
+
}
|
|
62
|
+
this.currentIssue = {
|
|
63
|
+
issueNumber,
|
|
64
|
+
title,
|
|
65
|
+
labels,
|
|
66
|
+
phases: [],
|
|
67
|
+
status: "success",
|
|
68
|
+
totalDurationSeconds: 0,
|
|
69
|
+
};
|
|
70
|
+
if (this.verbose) {
|
|
71
|
+
console.log(`📝 Started logging issue #${issueNumber}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Log a completed phase
|
|
76
|
+
*
|
|
77
|
+
* @param phaseLog - Complete phase log entry
|
|
78
|
+
*/
|
|
79
|
+
logPhase(phaseLog) {
|
|
80
|
+
if (!this.currentIssue) {
|
|
81
|
+
throw new Error("No current issue. Call startIssue() first.");
|
|
82
|
+
}
|
|
83
|
+
this.currentIssue.phases = [...(this.currentIssue.phases ?? []), phaseLog];
|
|
84
|
+
// Update issue status based on phase result
|
|
85
|
+
if (phaseLog.status === "failure") {
|
|
86
|
+
this.currentIssue.status = "failure";
|
|
87
|
+
}
|
|
88
|
+
else if (phaseLog.status === "timeout" &&
|
|
89
|
+
this.currentIssue.status !== "failure") {
|
|
90
|
+
this.currentIssue.status = "partial";
|
|
91
|
+
}
|
|
92
|
+
if (this.verbose) {
|
|
93
|
+
console.log(`📝 Logged phase: ${phaseLog.phase} (${phaseLog.status}) - ${phaseLog.durationSeconds.toFixed(1)}s`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Complete the current issue and add it to the run log
|
|
98
|
+
*/
|
|
99
|
+
completeIssue() {
|
|
100
|
+
if (!this.runLog || !this.currentIssue) {
|
|
101
|
+
throw new Error("No current issue to complete.");
|
|
102
|
+
}
|
|
103
|
+
// Calculate total duration from phases
|
|
104
|
+
const totalDurationSeconds = this.currentIssue.phases?.reduce((sum, p) => sum + p.durationSeconds, 0) ?? 0;
|
|
105
|
+
const issueLog = {
|
|
106
|
+
issueNumber: this.currentIssue.issueNumber,
|
|
107
|
+
title: this.currentIssue.title,
|
|
108
|
+
labels: this.currentIssue.labels,
|
|
109
|
+
status: this.currentIssue.status,
|
|
110
|
+
phases: this.currentIssue.phases,
|
|
111
|
+
totalDurationSeconds,
|
|
112
|
+
};
|
|
113
|
+
this.runLog.issues.push(issueLog);
|
|
114
|
+
this.currentIssue = null;
|
|
115
|
+
if (this.verbose) {
|
|
116
|
+
console.log(`📝 Completed issue #${issueLog.issueNumber} (${issueLog.status})`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Finalize the run log and write to disk
|
|
121
|
+
*
|
|
122
|
+
* @returns Path to the written log file
|
|
123
|
+
*/
|
|
124
|
+
async finalize() {
|
|
125
|
+
if (!this.runLog) {
|
|
126
|
+
throw new Error("LogWriter not initialized.");
|
|
127
|
+
}
|
|
128
|
+
// Complete any pending issue
|
|
129
|
+
if (this.currentIssue) {
|
|
130
|
+
this.completeIssue();
|
|
131
|
+
}
|
|
132
|
+
const finalLog = finalizeRunLog(this.runLog);
|
|
133
|
+
const filename = generateLogFilename(finalLog.runId, new Date(finalLog.startTime));
|
|
134
|
+
// Write to project logs
|
|
135
|
+
const projectPath = path.join(this.resolvePath(this.logPath), filename);
|
|
136
|
+
await this.writeLogFile(projectPath, finalLog);
|
|
137
|
+
// Optionally write to user logs
|
|
138
|
+
if (this.writeToUserLogs) {
|
|
139
|
+
const userPath = path.join(this.resolvePath(LOG_PATHS.user), filename);
|
|
140
|
+
await this.writeLogFile(userPath, finalLog);
|
|
141
|
+
}
|
|
142
|
+
if (this.verbose) {
|
|
143
|
+
console.log(`📝 Log written: ${projectPath}`);
|
|
144
|
+
}
|
|
145
|
+
return projectPath;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Get the current run log (for inspection)
|
|
149
|
+
*/
|
|
150
|
+
getRunLog() {
|
|
151
|
+
return this.runLog;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get the run ID
|
|
155
|
+
*/
|
|
156
|
+
getRunId() {
|
|
157
|
+
return this.runLog?.runId ?? null;
|
|
158
|
+
}
|
|
159
|
+
resolvePath(logPath) {
|
|
160
|
+
return logPath.replace("~", os.homedir());
|
|
161
|
+
}
|
|
162
|
+
async ensureLogDirectory(logPath) {
|
|
163
|
+
const resolved = this.resolvePath(logPath);
|
|
164
|
+
if (!fs.existsSync(resolved)) {
|
|
165
|
+
fs.mkdirSync(resolved, { recursive: true });
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async writeLogFile(filePath, log) {
|
|
169
|
+
const dir = path.dirname(filePath);
|
|
170
|
+
if (!fs.existsSync(dir)) {
|
|
171
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
172
|
+
}
|
|
173
|
+
fs.writeFileSync(filePath, JSON.stringify(log, null, 2));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Create a simple phase log from timing data
|
|
178
|
+
*
|
|
179
|
+
* Utility function for creating phase logs when you have start/end times.
|
|
180
|
+
*/
|
|
181
|
+
export function createPhaseLogFromTiming(phase, issueNumber, startTime, endTime, status, options) {
|
|
182
|
+
const durationSeconds = (endTime.getTime() - startTime.getTime()) / 1000;
|
|
183
|
+
return {
|
|
184
|
+
phase,
|
|
185
|
+
issueNumber,
|
|
186
|
+
startTime: startTime.toISOString(),
|
|
187
|
+
endTime: endTime.toISOString(),
|
|
188
|
+
durationSeconds,
|
|
189
|
+
status,
|
|
190
|
+
...options,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=log-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-writer.js","sourceRoot":"","sources":["../../../../src/lib/workflow/log-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAOL,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,SAAS,GACV,MAAM,qBAAqB,CAAC;AAW7B;;GAEG;AACH,MAAM,OAAO,SAAS;IACZ,MAAM,GAAmC,IAAI,CAAC;IAC9C,YAAY,GAA6B,IAAI,CAAC;IAC9C,OAAO,CAAS;IAChB,eAAe,CAAU;IACzB,OAAO,CAAU;IAEzB,YAAY,UAA4B,EAAE;QACxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC;QACpD,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,KAAK,CAAC;QACxD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;IAC1C,CAAC;IAED;;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B,EAC1B,OAKC;IAED,MAAM,eAAe,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;IAEzE,OAAO;QACL,KAAK;QACL,WAAW;QACX,SAAS,EAAE,SAAS,CAAC,WAAW,EAAE;QAClC,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE;QAC9B,eAAe;QACf,MAAM;QACN,GAAG,OAAO;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for structured workflow run logs
|
|
3
|
+
*
|
|
4
|
+
* These schemas define the structure of JSON logs produced by `sequant run`
|
|
5
|
+
* for analysis, debugging, and automation purposes.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { RunLogSchema, type RunLog } from './run-log-schema';
|
|
10
|
+
*
|
|
11
|
+
* // Validate a log file
|
|
12
|
+
* const log = RunLogSchema.parse(JSON.parse(logContent));
|
|
13
|
+
*
|
|
14
|
+
* // Type-safe access
|
|
15
|
+
* console.log(log.summary.passed, log.summary.failed);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
/**
|
|
20
|
+
* Available workflow phases
|
|
21
|
+
*/
|
|
22
|
+
export declare const PhaseSchema: z.ZodEnum<{
|
|
23
|
+
loop: "loop";
|
|
24
|
+
spec: "spec";
|
|
25
|
+
exec: "exec";
|
|
26
|
+
qa: "qa";
|
|
27
|
+
testgen: "testgen";
|
|
28
|
+
test: "test";
|
|
29
|
+
}>;
|
|
30
|
+
export type Phase = z.infer<typeof PhaseSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* Phase execution status
|
|
33
|
+
*/
|
|
34
|
+
export declare const PhaseStatusSchema: z.ZodEnum<{
|
|
35
|
+
timeout: "timeout";
|
|
36
|
+
success: "success";
|
|
37
|
+
failure: "failure";
|
|
38
|
+
skipped: "skipped";
|
|
39
|
+
}>;
|
|
40
|
+
export type PhaseStatus = z.infer<typeof PhaseStatusSchema>;
|
|
41
|
+
/**
|
|
42
|
+
* Issue execution status
|
|
43
|
+
*/
|
|
44
|
+
export declare const IssueStatusSchema: z.ZodEnum<{
|
|
45
|
+
success: "success";
|
|
46
|
+
failure: "failure";
|
|
47
|
+
partial: "partial";
|
|
48
|
+
}>;
|
|
49
|
+
export type IssueStatus = z.infer<typeof IssueStatusSchema>;
|
|
50
|
+
/**
|
|
51
|
+
* Log entry for a single phase execution
|
|
52
|
+
*/
|
|
53
|
+
export declare const PhaseLogSchema: z.ZodObject<{
|
|
54
|
+
phase: z.ZodEnum<{
|
|
55
|
+
loop: "loop";
|
|
56
|
+
spec: "spec";
|
|
57
|
+
exec: "exec";
|
|
58
|
+
qa: "qa";
|
|
59
|
+
testgen: "testgen";
|
|
60
|
+
test: "test";
|
|
61
|
+
}>;
|
|
62
|
+
issueNumber: z.ZodNumber;
|
|
63
|
+
startTime: z.ZodString;
|
|
64
|
+
endTime: z.ZodString;
|
|
65
|
+
durationSeconds: z.ZodNumber;
|
|
66
|
+
status: z.ZodEnum<{
|
|
67
|
+
timeout: "timeout";
|
|
68
|
+
success: "success";
|
|
69
|
+
failure: "failure";
|
|
70
|
+
skipped: "skipped";
|
|
71
|
+
}>;
|
|
72
|
+
error: z.ZodOptional<z.ZodString>;
|
|
73
|
+
iterations: z.ZodOptional<z.ZodNumber>;
|
|
74
|
+
filesModified: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
75
|
+
testsRun: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
testsPassed: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
export type PhaseLog = z.infer<typeof PhaseLogSchema>;
|
|
79
|
+
/**
|
|
80
|
+
* Complete execution record for a single issue
|
|
81
|
+
*/
|
|
82
|
+
export declare const IssueLogSchema: z.ZodObject<{
|
|
83
|
+
issueNumber: z.ZodNumber;
|
|
84
|
+
title: z.ZodString;
|
|
85
|
+
labels: z.ZodArray<z.ZodString>;
|
|
86
|
+
status: z.ZodEnum<{
|
|
87
|
+
success: "success";
|
|
88
|
+
failure: "failure";
|
|
89
|
+
partial: "partial";
|
|
90
|
+
}>;
|
|
91
|
+
phases: z.ZodArray<z.ZodObject<{
|
|
92
|
+
phase: z.ZodEnum<{
|
|
93
|
+
loop: "loop";
|
|
94
|
+
spec: "spec";
|
|
95
|
+
exec: "exec";
|
|
96
|
+
qa: "qa";
|
|
97
|
+
testgen: "testgen";
|
|
98
|
+
test: "test";
|
|
99
|
+
}>;
|
|
100
|
+
issueNumber: z.ZodNumber;
|
|
101
|
+
startTime: z.ZodString;
|
|
102
|
+
endTime: z.ZodString;
|
|
103
|
+
durationSeconds: z.ZodNumber;
|
|
104
|
+
status: z.ZodEnum<{
|
|
105
|
+
timeout: "timeout";
|
|
106
|
+
success: "success";
|
|
107
|
+
failure: "failure";
|
|
108
|
+
skipped: "skipped";
|
|
109
|
+
}>;
|
|
110
|
+
error: z.ZodOptional<z.ZodString>;
|
|
111
|
+
iterations: z.ZodOptional<z.ZodNumber>;
|
|
112
|
+
filesModified: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
113
|
+
testsRun: z.ZodOptional<z.ZodNumber>;
|
|
114
|
+
testsPassed: z.ZodOptional<z.ZodNumber>;
|
|
115
|
+
}, z.core.$strip>>;
|
|
116
|
+
totalDurationSeconds: z.ZodNumber;
|
|
117
|
+
}, z.core.$strip>;
|
|
118
|
+
export type IssueLog = z.infer<typeof IssueLogSchema>;
|
|
119
|
+
/**
|
|
120
|
+
* Run configuration
|
|
121
|
+
*/
|
|
122
|
+
export declare const RunConfigSchema: z.ZodObject<{
|
|
123
|
+
phases: z.ZodArray<z.ZodEnum<{
|
|
124
|
+
loop: "loop";
|
|
125
|
+
spec: "spec";
|
|
126
|
+
exec: "exec";
|
|
127
|
+
qa: "qa";
|
|
128
|
+
testgen: "testgen";
|
|
129
|
+
test: "test";
|
|
130
|
+
}>>;
|
|
131
|
+
sequential: z.ZodBoolean;
|
|
132
|
+
qualityLoop: z.ZodBoolean;
|
|
133
|
+
maxIterations: z.ZodNumber;
|
|
134
|
+
}, z.core.$strip>;
|
|
135
|
+
export type RunConfig = z.infer<typeof RunConfigSchema>;
|
|
136
|
+
/**
|
|
137
|
+
* Summary statistics for a run
|
|
138
|
+
*/
|
|
139
|
+
export declare const RunSummarySchema: z.ZodObject<{
|
|
140
|
+
totalIssues: z.ZodNumber;
|
|
141
|
+
passed: z.ZodNumber;
|
|
142
|
+
failed: z.ZodNumber;
|
|
143
|
+
totalDurationSeconds: z.ZodNumber;
|
|
144
|
+
}, z.core.$strip>;
|
|
145
|
+
export type RunSummary = z.infer<typeof RunSummarySchema>;
|
|
146
|
+
/**
|
|
147
|
+
* Complete run log schema
|
|
148
|
+
*
|
|
149
|
+
* This is the top-level schema for a workflow run log file.
|
|
150
|
+
*/
|
|
151
|
+
export declare const RunLogSchema: z.ZodObject<{
|
|
152
|
+
version: z.ZodLiteral<1>;
|
|
153
|
+
runId: z.ZodString;
|
|
154
|
+
startTime: z.ZodString;
|
|
155
|
+
endTime: z.ZodString;
|
|
156
|
+
config: z.ZodObject<{
|
|
157
|
+
phases: z.ZodArray<z.ZodEnum<{
|
|
158
|
+
loop: "loop";
|
|
159
|
+
spec: "spec";
|
|
160
|
+
exec: "exec";
|
|
161
|
+
qa: "qa";
|
|
162
|
+
testgen: "testgen";
|
|
163
|
+
test: "test";
|
|
164
|
+
}>>;
|
|
165
|
+
sequential: z.ZodBoolean;
|
|
166
|
+
qualityLoop: z.ZodBoolean;
|
|
167
|
+
maxIterations: z.ZodNumber;
|
|
168
|
+
}, z.core.$strip>;
|
|
169
|
+
issues: z.ZodArray<z.ZodObject<{
|
|
170
|
+
issueNumber: z.ZodNumber;
|
|
171
|
+
title: z.ZodString;
|
|
172
|
+
labels: z.ZodArray<z.ZodString>;
|
|
173
|
+
status: z.ZodEnum<{
|
|
174
|
+
success: "success";
|
|
175
|
+
failure: "failure";
|
|
176
|
+
partial: "partial";
|
|
177
|
+
}>;
|
|
178
|
+
phases: z.ZodArray<z.ZodObject<{
|
|
179
|
+
phase: z.ZodEnum<{
|
|
180
|
+
loop: "loop";
|
|
181
|
+
spec: "spec";
|
|
182
|
+
exec: "exec";
|
|
183
|
+
qa: "qa";
|
|
184
|
+
testgen: "testgen";
|
|
185
|
+
test: "test";
|
|
186
|
+
}>;
|
|
187
|
+
issueNumber: z.ZodNumber;
|
|
188
|
+
startTime: z.ZodString;
|
|
189
|
+
endTime: z.ZodString;
|
|
190
|
+
durationSeconds: z.ZodNumber;
|
|
191
|
+
status: z.ZodEnum<{
|
|
192
|
+
timeout: "timeout";
|
|
193
|
+
success: "success";
|
|
194
|
+
failure: "failure";
|
|
195
|
+
skipped: "skipped";
|
|
196
|
+
}>;
|
|
197
|
+
error: z.ZodOptional<z.ZodString>;
|
|
198
|
+
iterations: z.ZodOptional<z.ZodNumber>;
|
|
199
|
+
filesModified: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
200
|
+
testsRun: z.ZodOptional<z.ZodNumber>;
|
|
201
|
+
testsPassed: z.ZodOptional<z.ZodNumber>;
|
|
202
|
+
}, z.core.$strip>>;
|
|
203
|
+
totalDurationSeconds: z.ZodNumber;
|
|
204
|
+
}, z.core.$strip>>;
|
|
205
|
+
summary: z.ZodObject<{
|
|
206
|
+
totalIssues: z.ZodNumber;
|
|
207
|
+
passed: z.ZodNumber;
|
|
208
|
+
failed: z.ZodNumber;
|
|
209
|
+
totalDurationSeconds: z.ZodNumber;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
}, z.core.$strip>;
|
|
212
|
+
export type RunLog = z.infer<typeof RunLogSchema>;
|
|
213
|
+
/**
|
|
214
|
+
* Default log directory paths
|
|
215
|
+
*/
|
|
216
|
+
export declare const LOG_PATHS: {
|
|
217
|
+
/** User-level logs */
|
|
218
|
+
readonly user: "~/.sequant/logs";
|
|
219
|
+
/** Project-level logs */
|
|
220
|
+
readonly project: ".sequant/logs";
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Generate a log filename from run metadata
|
|
224
|
+
*
|
|
225
|
+
* @param runId - Unique run identifier
|
|
226
|
+
* @param startTime - Run start time
|
|
227
|
+
* @returns Filename in format: run-<timestamp>-<runId>.json
|
|
228
|
+
*/
|
|
229
|
+
export declare function generateLogFilename(runId: string, startTime: Date): string;
|
|
230
|
+
/**
|
|
231
|
+
* Create an empty run log with initial values
|
|
232
|
+
*
|
|
233
|
+
* @param config - Run configuration
|
|
234
|
+
* @returns Initial RunLog structure
|
|
235
|
+
*/
|
|
236
|
+
export declare function createEmptyRunLog(config: RunConfig): Omit<RunLog, "endTime">;
|
|
237
|
+
/**
|
|
238
|
+
* Create a phase log entry
|
|
239
|
+
*
|
|
240
|
+
* @param phase - Phase being executed
|
|
241
|
+
* @param issueNumber - GitHub issue number
|
|
242
|
+
* @returns PhaseLog with start time set
|
|
243
|
+
*/
|
|
244
|
+
export declare function createPhaseLog(phase: Phase, issueNumber: number): Omit<PhaseLog, "endTime" | "durationSeconds" | "status">;
|
|
245
|
+
/**
|
|
246
|
+
* Complete a phase log entry
|
|
247
|
+
*
|
|
248
|
+
* @param phaseLog - Partial phase log
|
|
249
|
+
* @param status - Final status
|
|
250
|
+
* @param options - Additional fields (error, filesModified, etc.)
|
|
251
|
+
* @returns Complete PhaseLog
|
|
252
|
+
*/
|
|
253
|
+
export declare function completePhaseLog(phaseLog: Omit<PhaseLog, "endTime" | "durationSeconds" | "status">, status: PhaseStatus, options?: Partial<Pick<PhaseLog, "error" | "iterations" | "filesModified" | "testsRun" | "testsPassed">>): PhaseLog;
|
|
254
|
+
/**
|
|
255
|
+
* Finalize a run log with summary statistics
|
|
256
|
+
*
|
|
257
|
+
* @param runLog - Partial run log
|
|
258
|
+
* @returns Complete RunLog with endTime and summary
|
|
259
|
+
*/
|
|
260
|
+
export declare function finalizeRunLog(runLog: Omit<RunLog, "endTime">): RunLog;
|
|
261
|
+
//# sourceMappingURL=run-log-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-log-schema.d.ts","sourceRoot":"","sources":["../../../../src/lib/workflow/run-log-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;EAOtB,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;EAK5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;EAA4C,CAAC;AAE3E,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;iBAuBzB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAazB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;iBAS1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;iBAS3B,CAAC;AAEH,MAAM,MAAM,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* These schemas define the structure of JSON logs produced by `sequant run`
|
|
5
|
+
* for analysis, debugging, and automation purposes.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { RunLogSchema, type RunLog } from './run-log-schema';
|
|
10
|
+
*
|
|
11
|
+
* // Validate a log file
|
|
12
|
+
* const log = RunLogSchema.parse(JSON.parse(logContent));
|
|
13
|
+
*
|
|
14
|
+
* // Type-safe access
|
|
15
|
+
* console.log(log.summary.passed, log.summary.failed);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
/**
|
|
20
|
+
* Available workflow phases
|
|
21
|
+
*/
|
|
22
|
+
export const PhaseSchema = z.enum([
|
|
23
|
+
"spec",
|
|
24
|
+
"testgen",
|
|
25
|
+
"exec",
|
|
26
|
+
"test",
|
|
27
|
+
"qa",
|
|
28
|
+
"loop",
|
|
29
|
+
]);
|
|
30
|
+
/**
|
|
31
|
+
* Phase execution status
|
|
32
|
+
*/
|
|
33
|
+
export const PhaseStatusSchema = z.enum([
|
|
34
|
+
"success",
|
|
35
|
+
"failure",
|
|
36
|
+
"timeout",
|
|
37
|
+
"skipped",
|
|
38
|
+
]);
|
|
39
|
+
/**
|
|
40
|
+
* Issue execution status
|
|
41
|
+
*/
|
|
42
|
+
export const IssueStatusSchema = z.enum(["success", "failure", "partial"]);
|
|
43
|
+
/**
|
|
44
|
+
* Log entry for a single phase execution
|
|
45
|
+
*/
|
|
46
|
+
export const PhaseLogSchema = z.object({
|
|
47
|
+
/** Phase that was executed */
|
|
48
|
+
phase: PhaseSchema,
|
|
49
|
+
/** GitHub issue number */
|
|
50
|
+
issueNumber: z.number().int().positive(),
|
|
51
|
+
/** When the phase started */
|
|
52
|
+
startTime: z.string().datetime(),
|
|
53
|
+
/** When the phase ended */
|
|
54
|
+
endTime: z.string().datetime(),
|
|
55
|
+
/** Duration in seconds */
|
|
56
|
+
durationSeconds: z.number().nonnegative(),
|
|
57
|
+
/** Execution result */
|
|
58
|
+
status: PhaseStatusSchema,
|
|
59
|
+
/** Error message if failed */
|
|
60
|
+
error: z.string().optional(),
|
|
61
|
+
/** Number of iterations (for loop phase) */
|
|
62
|
+
iterations: z.number().int().nonnegative().optional(),
|
|
63
|
+
/** Files modified during this phase */
|
|
64
|
+
filesModified: z.array(z.string()).optional(),
|
|
65
|
+
/** Number of tests run (for test/qa phases) */
|
|
66
|
+
testsRun: z.number().int().nonnegative().optional(),
|
|
67
|
+
/** Number of tests passed */
|
|
68
|
+
testsPassed: z.number().int().nonnegative().optional(),
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* Complete execution record for a single issue
|
|
72
|
+
*/
|
|
73
|
+
export const IssueLogSchema = z.object({
|
|
74
|
+
/** GitHub issue number */
|
|
75
|
+
issueNumber: z.number().int().positive(),
|
|
76
|
+
/** Issue title */
|
|
77
|
+
title: z.string(),
|
|
78
|
+
/** Issue labels */
|
|
79
|
+
labels: z.array(z.string()),
|
|
80
|
+
/** Overall execution result */
|
|
81
|
+
status: IssueStatusSchema,
|
|
82
|
+
/** Log entries for each phase executed */
|
|
83
|
+
phases: z.array(PhaseLogSchema),
|
|
84
|
+
/** Total execution time in seconds */
|
|
85
|
+
totalDurationSeconds: z.number().nonnegative(),
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* Run configuration
|
|
89
|
+
*/
|
|
90
|
+
export const RunConfigSchema = z.object({
|
|
91
|
+
/** Phases that were configured to run */
|
|
92
|
+
phases: z.array(PhaseSchema),
|
|
93
|
+
/** Whether issues were run sequentially */
|
|
94
|
+
sequential: z.boolean(),
|
|
95
|
+
/** Whether quality loop was enabled */
|
|
96
|
+
qualityLoop: z.boolean(),
|
|
97
|
+
/** Maximum iterations for fix loops */
|
|
98
|
+
maxIterations: z.number().int().positive(),
|
|
99
|
+
});
|
|
100
|
+
/**
|
|
101
|
+
* Summary statistics for a run
|
|
102
|
+
*/
|
|
103
|
+
export const RunSummarySchema = z.object({
|
|
104
|
+
/** Total number of issues processed */
|
|
105
|
+
totalIssues: z.number().int().nonnegative(),
|
|
106
|
+
/** Number of issues that passed */
|
|
107
|
+
passed: z.number().int().nonnegative(),
|
|
108
|
+
/** Number of issues that failed */
|
|
109
|
+
failed: z.number().int().nonnegative(),
|
|
110
|
+
/** Total execution time in seconds */
|
|
111
|
+
totalDurationSeconds: z.number().nonnegative(),
|
|
112
|
+
});
|
|
113
|
+
/**
|
|
114
|
+
* Complete run log schema
|
|
115
|
+
*
|
|
116
|
+
* This is the top-level schema for a workflow run log file.
|
|
117
|
+
*/
|
|
118
|
+
export const RunLogSchema = z.object({
|
|
119
|
+
/** Schema version for backwards compatibility */
|
|
120
|
+
version: z.literal(1),
|
|
121
|
+
/** Unique identifier for this run */
|
|
122
|
+
runId: z.string().uuid(),
|
|
123
|
+
/** When the run started */
|
|
124
|
+
startTime: z.string().datetime(),
|
|
125
|
+
/** When the run ended */
|
|
126
|
+
endTime: z.string().datetime(),
|
|
127
|
+
/** Run configuration */
|
|
128
|
+
config: RunConfigSchema,
|
|
129
|
+
/** Execution logs for each issue */
|
|
130
|
+
issues: z.array(IssueLogSchema),
|
|
131
|
+
/** Summary statistics */
|
|
132
|
+
summary: RunSummarySchema,
|
|
133
|
+
});
|
|
134
|
+
/**
|
|
135
|
+
* Default log directory paths
|
|
136
|
+
*/
|
|
137
|
+
export const LOG_PATHS = {
|
|
138
|
+
/** User-level logs */
|
|
139
|
+
user: "~/.sequant/logs",
|
|
140
|
+
/** Project-level logs */
|
|
141
|
+
project: ".sequant/logs",
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Generate a log filename from run metadata
|
|
145
|
+
*
|
|
146
|
+
* @param runId - Unique run identifier
|
|
147
|
+
* @param startTime - Run start time
|
|
148
|
+
* @returns Filename in format: run-<timestamp>-<runId>.json
|
|
149
|
+
*/
|
|
150
|
+
export function generateLogFilename(runId, startTime) {
|
|
151
|
+
const timestamp = startTime.toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
152
|
+
return `run-${timestamp}-${runId}.json`;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Create an empty run log with initial values
|
|
156
|
+
*
|
|
157
|
+
* @param config - Run configuration
|
|
158
|
+
* @returns Initial RunLog structure
|
|
159
|
+
*/
|
|
160
|
+
export function createEmptyRunLog(config) {
|
|
161
|
+
const runId = crypto.randomUUID();
|
|
162
|
+
const startTime = new Date().toISOString();
|
|
163
|
+
return {
|
|
164
|
+
version: 1,
|
|
165
|
+
runId,
|
|
166
|
+
startTime,
|
|
167
|
+
config,
|
|
168
|
+
issues: [],
|
|
169
|
+
summary: {
|
|
170
|
+
totalIssues: 0,
|
|
171
|
+
passed: 0,
|
|
172
|
+
failed: 0,
|
|
173
|
+
totalDurationSeconds: 0,
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Create a phase log entry
|
|
179
|
+
*
|
|
180
|
+
* @param phase - Phase being executed
|
|
181
|
+
* @param issueNumber - GitHub issue number
|
|
182
|
+
* @returns PhaseLog with start time set
|
|
183
|
+
*/
|
|
184
|
+
export function createPhaseLog(phase, issueNumber) {
|
|
185
|
+
return {
|
|
186
|
+
phase,
|
|
187
|
+
issueNumber,
|
|
188
|
+
startTime: new Date().toISOString(),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Complete a phase log entry
|
|
193
|
+
*
|
|
194
|
+
* @param phaseLog - Partial phase log
|
|
195
|
+
* @param status - Final status
|
|
196
|
+
* @param options - Additional fields (error, filesModified, etc.)
|
|
197
|
+
* @returns Complete PhaseLog
|
|
198
|
+
*/
|
|
199
|
+
export function completePhaseLog(phaseLog, status, options) {
|
|
200
|
+
const endTime = new Date();
|
|
201
|
+
const startTime = new Date(phaseLog.startTime);
|
|
202
|
+
const durationSeconds = (endTime.getTime() - startTime.getTime()) / 1000;
|
|
203
|
+
return {
|
|
204
|
+
...phaseLog,
|
|
205
|
+
endTime: endTime.toISOString(),
|
|
206
|
+
durationSeconds,
|
|
207
|
+
status,
|
|
208
|
+
...options,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Finalize a run log with summary statistics
|
|
213
|
+
*
|
|
214
|
+
* @param runLog - Partial run log
|
|
215
|
+
* @returns Complete RunLog with endTime and summary
|
|
216
|
+
*/
|
|
217
|
+
export function finalizeRunLog(runLog) {
|
|
218
|
+
const endTime = new Date();
|
|
219
|
+
const startTime = new Date(runLog.startTime);
|
|
220
|
+
const totalDurationSeconds = (endTime.getTime() - startTime.getTime()) / 1000;
|
|
221
|
+
const passed = runLog.issues.filter((i) => i.status === "success").length;
|
|
222
|
+
const failed = runLog.issues.filter((i) => i.status === "failure").length;
|
|
223
|
+
return {
|
|
224
|
+
...runLog,
|
|
225
|
+
endTime: endTime.toISOString(),
|
|
226
|
+
summary: {
|
|
227
|
+
totalIssues: runLog.issues.length,
|
|
228
|
+
passed,
|
|
229
|
+
failed,
|
|
230
|
+
totalDurationSeconds,
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=run-log-schema.js.map
|