seance-cli 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +40 -2
- package/dist/commands/init.d.ts +29 -0
- package/dist/commands/init.js +310 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mcp.d.ts +19 -0
- package/dist/commands/mcp.js +38 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/quiz.d.ts +23 -0
- package/dist/commands/quiz.js +187 -0
- package/dist/commands/quiz.js.map +1 -0
- package/dist/commands/review.d.ts +4 -0
- package/dist/commands/review.js +115 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/sync.d.ts +17 -0
- package/dist/commands/sync.js +367 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/git.d.ts +33 -0
- package/dist/git.js +103 -0
- package/dist/git.js.map +1 -0
- package/dist/hosted-api.d.ts +24 -0
- package/dist/hosted-api.js +85 -0
- package/dist/hosted-api.js.map +1 -0
- package/dist/hosted-consent.d.ts +8 -0
- package/dist/hosted-consent.js +37 -0
- package/dist/hosted-consent.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +108 -0
- package/dist/index.js.map +1 -0
- package/dist/init-fs.d.ts +51 -0
- package/dist/init-fs.js +220 -0
- package/dist/init-fs.js.map +1 -0
- package/dist/init-questions.d.ts +21 -0
- package/dist/init-questions.js +161 -0
- package/dist/init-questions.js.map +1 -0
- package/dist/mcp-handlers.d.ts +22 -0
- package/dist/mcp-handlers.js +185 -0
- package/dist/mcp-handlers.js.map +1 -0
- package/dist/mcp-server.d.ts +4 -0
- package/dist/mcp-server.js +39 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/prompter.d.ts +29 -0
- package/dist/prompter.js +42 -0
- package/dist/prompter.js.map +1 -0
- package/dist/quiz-backend.d.ts +40 -0
- package/dist/quiz-backend.js +116 -0
- package/dist/quiz-backend.js.map +1 -0
- package/dist/quiz-input.d.ts +12 -0
- package/dist/quiz-input.js +52 -0
- package/dist/quiz-input.js.map +1 -0
- package/dist/quiz-io.d.ts +30 -0
- package/dist/quiz-io.js +83 -0
- package/dist/quiz-io.js.map +1 -0
- package/dist/quiz-ui.d.ts +18 -0
- package/dist/quiz-ui.js +51 -0
- package/dist/quiz-ui.js.map +1 -0
- package/node_modules/@seance/ai/LICENSE +21 -0
- package/node_modules/@seance/ai/dist/chain.d.ts +31 -0
- package/node_modules/@seance/ai/dist/chain.js +114 -0
- package/node_modules/@seance/ai/dist/chain.js.map +1 -0
- package/node_modules/@seance/ai/dist/grade.d.ts +14 -0
- package/node_modules/@seance/ai/dist/grade.js +44 -0
- package/node_modules/@seance/ai/dist/grade.js.map +1 -0
- package/node_modules/@seance/ai/dist/hosted-config.d.ts +9 -0
- package/node_modules/@seance/ai/dist/hosted-config.js +27 -0
- package/node_modules/@seance/ai/dist/hosted-config.js.map +1 -0
- package/node_modules/@seance/ai/dist/index.d.ts +9 -0
- package/node_modules/@seance/ai/dist/index.js +9 -0
- package/node_modules/@seance/ai/dist/index.js.map +1 -0
- package/node_modules/@seance/ai/dist/providers.d.ts +54 -0
- package/node_modules/@seance/ai/dist/providers.js +149 -0
- package/node_modules/@seance/ai/dist/providers.js.map +1 -0
- package/node_modules/@seance/ai/dist/quiz.d.ts +26 -0
- package/node_modules/@seance/ai/dist/quiz.js +41 -0
- package/node_modules/@seance/ai/dist/quiz.js.map +1 -0
- package/node_modules/@seance/ai/package.json +25 -0
- package/node_modules/@seance/core/LICENSE +21 -0
- package/node_modules/@seance/core/dist/ai-check.d.ts +58 -0
- package/node_modules/@seance/core/dist/ai-check.js +460 -0
- package/node_modules/@seance/core/dist/ai-check.js.map +1 -0
- package/node_modules/@seance/core/dist/ai-prompts.d.ts +29 -0
- package/node_modules/@seance/core/dist/ai-prompts.js +221 -0
- package/node_modules/@seance/core/dist/ai-prompts.js.map +1 -0
- package/node_modules/@seance/core/dist/ai-schemas.d.ts +155 -0
- package/node_modules/@seance/core/dist/ai-schemas.js +92 -0
- package/node_modules/@seance/core/dist/ai-schemas.js.map +1 -0
- package/node_modules/@seance/core/dist/api-client.d.ts +26 -0
- package/node_modules/@seance/core/dist/api-client.js +71 -0
- package/node_modules/@seance/core/dist/api-client.js.map +1 -0
- package/node_modules/@seance/core/dist/api-errors.d.ts +37 -0
- package/node_modules/@seance/core/dist/api-errors.js +66 -0
- package/node_modules/@seance/core/dist/api-errors.js.map +1 -0
- package/node_modules/@seance/core/dist/api-schemas.d.ts +284 -0
- package/node_modules/@seance/core/dist/api-schemas.js +67 -0
- package/node_modules/@seance/core/dist/api-schemas.js.map +1 -0
- package/node_modules/@seance/core/dist/decision-log.d.ts +73 -0
- package/node_modules/@seance/core/dist/decision-log.js +239 -0
- package/node_modules/@seance/core/dist/decision-log.js.map +1 -0
- package/node_modules/@seance/core/dist/dependency-guard.d.ts +20 -0
- package/node_modules/@seance/core/dist/dependency-guard.js +732 -0
- package/node_modules/@seance/core/dist/dependency-guard.js.map +1 -0
- package/node_modules/@seance/core/dist/gate.d.ts +11 -0
- package/node_modules/@seance/core/dist/gate.js +26 -0
- package/node_modules/@seance/core/dist/gate.js.map +1 -0
- package/node_modules/@seance/core/dist/git-parse.d.ts +11 -0
- package/node_modules/@seance/core/dist/git-parse.js +23 -0
- package/node_modules/@seance/core/dist/git-parse.js.map +1 -0
- package/node_modules/@seance/core/dist/index.d.ts +65 -0
- package/node_modules/@seance/core/dist/index.js +47 -0
- package/node_modules/@seance/core/dist/index.js.map +1 -0
- package/node_modules/@seance/core/dist/init-checklist.d.ts +153 -0
- package/node_modules/@seance/core/dist/init-checklist.js +200 -0
- package/node_modules/@seance/core/dist/init-checklist.js.map +1 -0
- package/node_modules/@seance/core/dist/init-detect.d.ts +9 -0
- package/node_modules/@seance/core/dist/init-detect.js +84 -0
- package/node_modules/@seance/core/dist/init-detect.js.map +1 -0
- package/node_modules/@seance/core/dist/init-templates.d.ts +36 -0
- package/node_modules/@seance/core/dist/init-templates.js +257 -0
- package/node_modules/@seance/core/dist/init-templates.js.map +1 -0
- package/node_modules/@seance/core/dist/map-basics.d.ts +13 -0
- package/node_modules/@seance/core/dist/map-basics.js +19 -0
- package/node_modules/@seance/core/dist/map-basics.js.map +1 -0
- package/node_modules/@seance/core/dist/map-summary.d.ts +5 -0
- package/node_modules/@seance/core/dist/map-summary.js +50 -0
- package/node_modules/@seance/core/dist/map-summary.js.map +1 -0
- package/node_modules/@seance/core/dist/markers.d.ts +51 -0
- package/node_modules/@seance/core/dist/markers.js +84 -0
- package/node_modules/@seance/core/dist/markers.js.map +1 -0
- package/node_modules/@seance/core/dist/mcp-quiz.d.ts +94 -0
- package/node_modules/@seance/core/dist/mcp-quiz.js +130 -0
- package/node_modules/@seance/core/dist/mcp-quiz.js.map +1 -0
- package/node_modules/@seance/core/dist/mcp-tools.d.ts +82 -0
- package/node_modules/@seance/core/dist/mcp-tools.js +136 -0
- package/node_modules/@seance/core/dist/mcp-tools.js.map +1 -0
- package/node_modules/@seance/core/dist/mcp-views.d.ts +21 -0
- package/node_modules/@seance/core/dist/mcp-views.js +83 -0
- package/node_modules/@seance/core/dist/mcp-views.js.map +1 -0
- package/node_modules/@seance/core/dist/quiz-assembly.d.ts +21 -0
- package/node_modules/@seance/core/dist/quiz-assembly.js +43 -0
- package/node_modules/@seance/core/dist/quiz-assembly.js.map +1 -0
- package/node_modules/@seance/core/dist/quiz-cards.d.ts +183 -0
- package/node_modules/@seance/core/dist/quiz-cards.js +215 -0
- package/node_modules/@seance/core/dist/quiz-cards.js.map +1 -0
- package/node_modules/@seance/core/dist/quiz-session.d.ts +67 -0
- package/node_modules/@seance/core/dist/quiz-session.js +141 -0
- package/node_modules/@seance/core/dist/quiz-session.js.map +1 -0
- package/node_modules/@seance/core/dist/quiz-subjects.d.ts +13 -0
- package/node_modules/@seance/core/dist/quiz-subjects.js +63 -0
- package/node_modules/@seance/core/dist/quiz-subjects.js.map +1 -0
- package/node_modules/@seance/core/dist/rate-limit.d.ts +33 -0
- package/node_modules/@seance/core/dist/rate-limit.js +114 -0
- package/node_modules/@seance/core/dist/rate-limit.js.map +1 -0
- package/node_modules/@seance/core/dist/scoring.d.ts +48 -0
- package/node_modules/@seance/core/dist/scoring.js +95 -0
- package/node_modules/@seance/core/dist/scoring.js.map +1 -0
- package/node_modules/@seance/core/dist/seance-config.d.ts +177 -0
- package/node_modules/@seance/core/dist/seance-config.js +43 -0
- package/node_modules/@seance/core/dist/seance-config.js.map +1 -0
- package/node_modules/@seance/core/dist/seance-state.d.ts +125 -0
- package/node_modules/@seance/core/dist/seance-state.js +61 -0
- package/node_modules/@seance/core/dist/seance-state.js.map +1 -0
- package/node_modules/@seance/core/dist/sm2.d.ts +18 -0
- package/node_modules/@seance/core/dist/sm2.js +87 -0
- package/node_modules/@seance/core/dist/sm2.js.map +1 -0
- package/node_modules/@seance/core/dist/stored-schemas.d.ts +29 -0
- package/node_modules/@seance/core/dist/stored-schemas.js +29 -0
- package/node_modules/@seance/core/dist/stored-schemas.js.map +1 -0
- package/node_modules/@seance/core/dist/structural-questions.d.ts +31 -0
- package/node_modules/@seance/core/dist/structural-questions.js +575 -0
- package/node_modules/@seance/core/dist/structural-questions.js.map +1 -0
- package/node_modules/@seance/core/dist/structure-map-schema.d.ts +84 -0
- package/node_modules/@seance/core/dist/structure-map-schema.js +73 -0
- package/node_modules/@seance/core/dist/structure-map-schema.js.map +1 -0
- package/node_modules/@seance/core/dist/structure-map.d.ts +78 -0
- package/node_modules/@seance/core/dist/structure-map.js +750 -0
- package/node_modules/@seance/core/dist/structure-map.js.map +1 -0
- package/node_modules/@seance/core/dist/sync-changes.d.ts +38 -0
- package/node_modules/@seance/core/dist/sync-changes.js +89 -0
- package/node_modules/@seance/core/dist/sync-changes.js.map +1 -0
- package/node_modules/@seance/core/dist/sync-render.d.ts +28 -0
- package/node_modules/@seance/core/dist/sync-render.js +113 -0
- package/node_modules/@seance/core/dist/sync-render.js.map +1 -0
- package/node_modules/@seance/core/dist/terminal-text.d.ts +8 -0
- package/node_modules/@seance/core/dist/terminal-text.js +33 -0
- package/node_modules/@seance/core/dist/terminal-text.js.map +1 -0
- package/node_modules/@seance/core/dist/write-plan.d.ts +51 -0
- package/node_modules/@seance/core/dist/write-plan.js +173 -0
- package/node_modules/@seance/core/dist/write-plan.js.map +1 -0
- package/node_modules/@seance/core/package.json +26 -0
- package/package.json +42 -6
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// The error responses of the hosted API (Task 8): code -> HTTP status, headers and a fixed friendly message.
|
|
2
|
+
// Pure: the Netlify handlers turn an ApiErrorResponse into a Response.
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
export const API_ERROR_CODES = [
|
|
5
|
+
"method_not_allowed",
|
|
6
|
+
"rate_limited",
|
|
7
|
+
"unsupported_media_type",
|
|
8
|
+
"payload_too_large",
|
|
9
|
+
"invalid_json",
|
|
10
|
+
"invalid_body",
|
|
11
|
+
"map_too_large",
|
|
12
|
+
"internal",
|
|
13
|
+
];
|
|
14
|
+
/** The JSON body of every error response. */
|
|
15
|
+
export const ApiErrorSchema = z.strictObject({
|
|
16
|
+
error: z.strictObject({
|
|
17
|
+
code: z.enum(API_ERROR_CODES),
|
|
18
|
+
message: z.string().min(1).max(200),
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
const MAX_PATH_CHARS = 120;
|
|
22
|
+
const STATUS = {
|
|
23
|
+
method_not_allowed: 405,
|
|
24
|
+
rate_limited: 429,
|
|
25
|
+
unsupported_media_type: 415,
|
|
26
|
+
payload_too_large: 413,
|
|
27
|
+
invalid_json: 400,
|
|
28
|
+
invalid_body: 400,
|
|
29
|
+
map_too_large: 422,
|
|
30
|
+
internal: 500,
|
|
31
|
+
};
|
|
32
|
+
const MESSAGE = {
|
|
33
|
+
method_not_allowed: "Use POST for this endpoint.",
|
|
34
|
+
unsupported_media_type: "Send the body as JSON (Content-Type: application/json).",
|
|
35
|
+
payload_too_large: "The request is larger than 100 KB. Send fewer or smaller files.",
|
|
36
|
+
invalid_json: "The body is not valid JSON.",
|
|
37
|
+
map_too_large: "This code is too large or unusual to map. Try fewer or smaller files.",
|
|
38
|
+
internal: "Something went wrong on our side. Try again later.",
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Builds the error response for a code. `rate_limited` needs `retryAfterSec` (a whole number of at least 1), else it throws a RangeError.
|
|
42
|
+
* `path` (for `invalid_body`) is cut to 120 characters and is never user text: it comes from our own schemas.
|
|
43
|
+
*/
|
|
44
|
+
export function apiError(code, detail = {}) {
|
|
45
|
+
const headers = {};
|
|
46
|
+
let message;
|
|
47
|
+
if (code === "rate_limited") {
|
|
48
|
+
const seconds = detail.retryAfterSec;
|
|
49
|
+
if (typeof seconds !== "number" || !Number.isInteger(seconds) || seconds < 1) {
|
|
50
|
+
throw new RangeError("rate_limited needs retryAfterSec, a whole number of at least 1");
|
|
51
|
+
}
|
|
52
|
+
headers["Retry-After"] = String(seconds);
|
|
53
|
+
message = `Too many requests. Try again in ${seconds} ${seconds === 1 ? "second" : "seconds"}.`;
|
|
54
|
+
}
|
|
55
|
+
else if (code === "invalid_body") {
|
|
56
|
+
const path = (detail.path ?? "(root)").slice(0, MAX_PATH_CHARS);
|
|
57
|
+
message = `The request body is not valid at ${path === "" ? "(root)" : path}.`;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
message = MESSAGE[code];
|
|
61
|
+
if (code === "method_not_allowed")
|
|
62
|
+
headers.Allow = "POST";
|
|
63
|
+
}
|
|
64
|
+
return { status: STATUS[code], headers, body: { error: { code, message } } };
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=api-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-errors.js","sourceRoot":"","sources":["../src/api-errors.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAC7G,uEAAuE;AACvE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CA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CAAC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YAC7E,MAAM,IAAI,UAAU,CAAC,gEAAgE,CAAC,CAAC;QACzF,CAAC;QACD,OAAO,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QACzC,OAAO,GAAG,mCAAmC,OAAO,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC;IAClG,CAAC;SAAM,IAAI,IAAI,KAAK,cAAc,EAAE,CAAC;QACnC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAChE,OAAO,GAAG,oCAAoC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;IACjF,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,IAAI,KAAK,oBAAoB;YAAE,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC;IAC5D,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type QuizItem } from "./ai-schemas.js";
|
|
3
|
+
/** Every size limit of the API in one place. */
|
|
4
|
+
export declare const API_LIMITS: {
|
|
5
|
+
readonly maxBodyBytes: 102400;
|
|
6
|
+
readonly maxFiles: 50;
|
|
7
|
+
readonly maxPathChars: 300;
|
|
8
|
+
readonly maxContentChars: 102400;
|
|
9
|
+
readonly maxSeed: 4294967295;
|
|
10
|
+
readonly maxAttempt: 1000;
|
|
11
|
+
readonly maxResponseBytes: 262144;
|
|
12
|
+
readonly maxQuestions: 10;
|
|
13
|
+
};
|
|
14
|
+
/** 1..50 files; no path may be empty after `normalisePath`, and no two may be the same after it. */
|
|
15
|
+
export declare const SourceFilesSchema: z.ZodArray<z.ZodObject<{
|
|
16
|
+
path: z.ZodString;
|
|
17
|
+
content: z.ZodString;
|
|
18
|
+
}, z.core.$strict>>;
|
|
19
|
+
export declare const StructureRequestSchema: z.ZodObject<{
|
|
20
|
+
files: z.ZodArray<z.ZodObject<{
|
|
21
|
+
path: z.ZodString;
|
|
22
|
+
content: z.ZodString;
|
|
23
|
+
}, z.core.$strict>>;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
export declare const QuizRequestSchema: z.ZodObject<{
|
|
26
|
+
files: z.ZodArray<z.ZodObject<{
|
|
27
|
+
path: z.ZodString;
|
|
28
|
+
content: z.ZodString;
|
|
29
|
+
}, z.core.$strict>>;
|
|
30
|
+
seed: z.ZodOptional<z.ZodInt>;
|
|
31
|
+
attempt: z.ZodOptional<z.ZodInt>;
|
|
32
|
+
decision: z.ZodOptional<z.ZodString>;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
export declare const GradeRequestSchema: z.ZodObject<{
|
|
35
|
+
item: z.ZodUnion<readonly [z.ZodObject<{
|
|
36
|
+
id: z.ZodString;
|
|
37
|
+
concept: z.ZodEnum<{
|
|
38
|
+
"async-functions": "async-functions";
|
|
39
|
+
"call-graph": "call-graph";
|
|
40
|
+
classes: "classes";
|
|
41
|
+
"data-flow": "data-flow";
|
|
42
|
+
decision: "decision";
|
|
43
|
+
"error-handling": "error-handling";
|
|
44
|
+
exports: "exports";
|
|
45
|
+
imports: "imports";
|
|
46
|
+
parameters: "parameters";
|
|
47
|
+
"side-effects": "side-effects";
|
|
48
|
+
state: "state";
|
|
49
|
+
}>;
|
|
50
|
+
prompt: z.ZodString;
|
|
51
|
+
source: z.ZodObject<{
|
|
52
|
+
path: z.ZodString;
|
|
53
|
+
line: z.ZodOptional<z.ZodInt>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
origin: z.ZodEnum<{
|
|
56
|
+
ai: "ai";
|
|
57
|
+
structural: "structural";
|
|
58
|
+
}>;
|
|
59
|
+
kind: z.ZodEnum<{
|
|
60
|
+
mcq: "mcq";
|
|
61
|
+
"what-if": "what-if";
|
|
62
|
+
}>;
|
|
63
|
+
choices: z.ZodArray<z.ZodString>;
|
|
64
|
+
answerIndex: z.ZodInt;
|
|
65
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
66
|
+
id: z.ZodString;
|
|
67
|
+
concept: z.ZodEnum<{
|
|
68
|
+
"async-functions": "async-functions";
|
|
69
|
+
"call-graph": "call-graph";
|
|
70
|
+
classes: "classes";
|
|
71
|
+
"data-flow": "data-flow";
|
|
72
|
+
decision: "decision";
|
|
73
|
+
"error-handling": "error-handling";
|
|
74
|
+
exports: "exports";
|
|
75
|
+
imports: "imports";
|
|
76
|
+
parameters: "parameters";
|
|
77
|
+
"side-effects": "side-effects";
|
|
78
|
+
state: "state";
|
|
79
|
+
}>;
|
|
80
|
+
prompt: z.ZodString;
|
|
81
|
+
source: z.ZodObject<{
|
|
82
|
+
path: z.ZodString;
|
|
83
|
+
line: z.ZodOptional<z.ZodInt>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
origin: z.ZodEnum<{
|
|
86
|
+
ai: "ai";
|
|
87
|
+
structural: "structural";
|
|
88
|
+
}>;
|
|
89
|
+
kind: z.ZodLiteral<"explain">;
|
|
90
|
+
rubric: z.ZodObject<{
|
|
91
|
+
keyPoints: z.ZodArray<z.ZodString>;
|
|
92
|
+
modelAnswer: z.ZodOptional<z.ZodString>;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
}, z.core.$strip>]> & z.ZodType<{
|
|
95
|
+
id: string;
|
|
96
|
+
concept: "async-functions" | "call-graph" | "classes" | "data-flow" | "decision" | "error-handling" | "exports" | "imports" | "parameters" | "side-effects" | "state";
|
|
97
|
+
prompt: string;
|
|
98
|
+
source: {
|
|
99
|
+
path: string;
|
|
100
|
+
line?: number | undefined;
|
|
101
|
+
};
|
|
102
|
+
origin: "ai" | "structural";
|
|
103
|
+
kind: "explain";
|
|
104
|
+
rubric: {
|
|
105
|
+
keyPoints: string[];
|
|
106
|
+
modelAnswer?: string | undefined;
|
|
107
|
+
};
|
|
108
|
+
}, {
|
|
109
|
+
id: string;
|
|
110
|
+
concept: "async-functions" | "call-graph" | "classes" | "data-flow" | "decision" | "error-handling" | "exports" | "imports" | "parameters" | "side-effects" | "state";
|
|
111
|
+
prompt: string;
|
|
112
|
+
source: {
|
|
113
|
+
path: string;
|
|
114
|
+
line?: number | undefined;
|
|
115
|
+
};
|
|
116
|
+
origin: "ai" | "structural";
|
|
117
|
+
kind: "mcq" | "what-if";
|
|
118
|
+
choices: string[];
|
|
119
|
+
answerIndex: number;
|
|
120
|
+
} | {
|
|
121
|
+
id: string;
|
|
122
|
+
concept: "async-functions" | "call-graph" | "classes" | "data-flow" | "decision" | "error-handling" | "exports" | "imports" | "parameters" | "side-effects" | "state";
|
|
123
|
+
prompt: string;
|
|
124
|
+
source: {
|
|
125
|
+
path: string;
|
|
126
|
+
line?: number | undefined;
|
|
127
|
+
};
|
|
128
|
+
origin: "ai" | "structural";
|
|
129
|
+
kind: "explain";
|
|
130
|
+
rubric: {
|
|
131
|
+
keyPoints: string[];
|
|
132
|
+
modelAnswer?: string | undefined;
|
|
133
|
+
};
|
|
134
|
+
}, z.core.$ZodTypeInternals<{
|
|
135
|
+
id: string;
|
|
136
|
+
concept: "async-functions" | "call-graph" | "classes" | "data-flow" | "decision" | "error-handling" | "exports" | "imports" | "parameters" | "side-effects" | "state";
|
|
137
|
+
prompt: string;
|
|
138
|
+
source: {
|
|
139
|
+
path: string;
|
|
140
|
+
line?: number | undefined;
|
|
141
|
+
};
|
|
142
|
+
origin: "ai" | "structural";
|
|
143
|
+
kind: "explain";
|
|
144
|
+
rubric: {
|
|
145
|
+
keyPoints: string[];
|
|
146
|
+
modelAnswer?: string | undefined;
|
|
147
|
+
};
|
|
148
|
+
}, {
|
|
149
|
+
id: string;
|
|
150
|
+
concept: "async-functions" | "call-graph" | "classes" | "data-flow" | "decision" | "error-handling" | "exports" | "imports" | "parameters" | "side-effects" | "state";
|
|
151
|
+
prompt: string;
|
|
152
|
+
source: {
|
|
153
|
+
path: string;
|
|
154
|
+
line?: number | undefined;
|
|
155
|
+
};
|
|
156
|
+
origin: "ai" | "structural";
|
|
157
|
+
kind: "mcq" | "what-if";
|
|
158
|
+
choices: string[];
|
|
159
|
+
answerIndex: number;
|
|
160
|
+
} | {
|
|
161
|
+
id: string;
|
|
162
|
+
concept: "async-functions" | "call-graph" | "classes" | "data-flow" | "decision" | "error-handling" | "exports" | "imports" | "parameters" | "side-effects" | "state";
|
|
163
|
+
prompt: string;
|
|
164
|
+
source: {
|
|
165
|
+
path: string;
|
|
166
|
+
line?: number | undefined;
|
|
167
|
+
};
|
|
168
|
+
origin: "ai" | "structural";
|
|
169
|
+
kind: "explain";
|
|
170
|
+
rubric: {
|
|
171
|
+
keyPoints: string[];
|
|
172
|
+
modelAnswer?: string | undefined;
|
|
173
|
+
};
|
|
174
|
+
}>>;
|
|
175
|
+
answer: z.ZodString;
|
|
176
|
+
}, z.core.$strict>;
|
|
177
|
+
export declare const SERVED_BY_QUIZ: readonly ["gemini", "nvidia", "openrouter", "structural"];
|
|
178
|
+
export declare const SERVED_BY_GRADE: readonly ["gemini", "nvidia", "openrouter", "keyword"];
|
|
179
|
+
export declare const StructureResponseSchema: z.ZodObject<{
|
|
180
|
+
map: z.ZodObject<{
|
|
181
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
182
|
+
files: z.ZodArray<z.ZodObject<{
|
|
183
|
+
path: z.ZodString;
|
|
184
|
+
language: z.ZodEnum<{
|
|
185
|
+
css: "css";
|
|
186
|
+
html: "html";
|
|
187
|
+
javascript: "javascript";
|
|
188
|
+
json: "json";
|
|
189
|
+
markdown: "markdown";
|
|
190
|
+
other: "other";
|
|
191
|
+
python: "python";
|
|
192
|
+
typescript: "typescript";
|
|
193
|
+
}>;
|
|
194
|
+
lines: z.ZodInt;
|
|
195
|
+
parsed: z.ZodBoolean;
|
|
196
|
+
errors: z.ZodArray<z.ZodObject<{
|
|
197
|
+
message: z.ZodString;
|
|
198
|
+
line: z.ZodInt;
|
|
199
|
+
}, z.core.$strip>>;
|
|
200
|
+
imports: z.ZodArray<z.ZodObject<{
|
|
201
|
+
source: z.ZodString;
|
|
202
|
+
kind: z.ZodEnum<{
|
|
203
|
+
import: "import";
|
|
204
|
+
require: "require";
|
|
205
|
+
}>;
|
|
206
|
+
defaultName: z.ZodOptional<z.ZodString>;
|
|
207
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
208
|
+
names: z.ZodArray<z.ZodString>;
|
|
209
|
+
typeOnly: z.ZodBoolean;
|
|
210
|
+
line: z.ZodInt;
|
|
211
|
+
}, z.core.$strip>>;
|
|
212
|
+
exports: z.ZodArray<z.ZodObject<{
|
|
213
|
+
name: z.ZodString;
|
|
214
|
+
kind: z.ZodEnum<{
|
|
215
|
+
default: "default";
|
|
216
|
+
named: "named";
|
|
217
|
+
reexport: "reexport";
|
|
218
|
+
}>;
|
|
219
|
+
from: z.ZodOptional<z.ZodString>;
|
|
220
|
+
line: z.ZodInt;
|
|
221
|
+
}, z.core.$strip>>;
|
|
222
|
+
functions: z.ZodArray<z.ZodObject<{
|
|
223
|
+
name: z.ZodString;
|
|
224
|
+
params: z.ZodInt;
|
|
225
|
+
plainParams: z.ZodBoolean;
|
|
226
|
+
async: z.ZodBoolean;
|
|
227
|
+
line: z.ZodInt;
|
|
228
|
+
calls: z.ZodArray<z.ZodString>;
|
|
229
|
+
calledNames: z.ZodArray<z.ZodString>;
|
|
230
|
+
mentionedNames: z.ZodArray<z.ZodString>;
|
|
231
|
+
exported: z.ZodBoolean;
|
|
232
|
+
}, z.core.$strip>>;
|
|
233
|
+
classes: z.ZodArray<z.ZodObject<{
|
|
234
|
+
name: z.ZodString;
|
|
235
|
+
exported: z.ZodBoolean;
|
|
236
|
+
line: z.ZodInt;
|
|
237
|
+
superClass: z.ZodOptional<z.ZodString>;
|
|
238
|
+
accessors: z.ZodArray<z.ZodString>;
|
|
239
|
+
methods: z.ZodArray<z.ZodObject<{
|
|
240
|
+
name: z.ZodString;
|
|
241
|
+
params: z.ZodInt;
|
|
242
|
+
plainParams: z.ZodBoolean;
|
|
243
|
+
async: z.ZodBoolean;
|
|
244
|
+
line: z.ZodInt;
|
|
245
|
+
calls: z.ZodArray<z.ZodString>;
|
|
246
|
+
calledNames: z.ZodArray<z.ZodString>;
|
|
247
|
+
mentionedNames: z.ZodArray<z.ZodString>;
|
|
248
|
+
static: z.ZodBoolean;
|
|
249
|
+
}, z.core.$strip>>;
|
|
250
|
+
}, z.core.$strip>>;
|
|
251
|
+
commonjsExports: z.ZodArray<z.ZodString>;
|
|
252
|
+
hasUnknownExports: z.ZodBoolean;
|
|
253
|
+
}, z.core.$strip>>;
|
|
254
|
+
}, z.core.$strip>;
|
|
255
|
+
}, z.core.$strip>;
|
|
256
|
+
/** `questions` are checked one by one by `parseQuizResponse`, so one bad question does not sink the rest. */
|
|
257
|
+
export declare const QuizResponseSchema: z.ZodObject<{
|
|
258
|
+
questions: z.ZodArray<z.ZodUnknown>;
|
|
259
|
+
servedBy: z.ZodEnum<{
|
|
260
|
+
gemini: "gemini";
|
|
261
|
+
nvidia: "nvidia";
|
|
262
|
+
openrouter: "openrouter";
|
|
263
|
+
structural: "structural";
|
|
264
|
+
}>;
|
|
265
|
+
model: z.ZodOptional<z.ZodString>;
|
|
266
|
+
}, z.core.$strip>;
|
|
267
|
+
export declare const GradeResponseSchema: z.ZodObject<{
|
|
268
|
+
score: z.ZodNumber;
|
|
269
|
+
feedback: z.ZodString;
|
|
270
|
+
rough: z.ZodBoolean;
|
|
271
|
+
servedBy: z.ZodEnum<{
|
|
272
|
+
gemini: "gemini";
|
|
273
|
+
keyword: "keyword";
|
|
274
|
+
nvidia: "nvidia";
|
|
275
|
+
openrouter: "openrouter";
|
|
276
|
+
}>;
|
|
277
|
+
model: z.ZodOptional<z.ZodString>;
|
|
278
|
+
}, z.core.$strip>;
|
|
279
|
+
export type QuizResponse = {
|
|
280
|
+
questions: QuizItem[];
|
|
281
|
+
servedBy: (typeof SERVED_BY_QUIZ)[number];
|
|
282
|
+
model?: string;
|
|
283
|
+
};
|
|
284
|
+
export type GradeResponse = z.infer<typeof GradeResponseSchema>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Request and response schemas of the hosted API (Task 8) with their size caps. Used by the Netlify functions
|
|
2
|
+
// (to check what clients send) and by the CLI and web app (to check what the API sends back). Pure: no I/O.
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { QuizItemSchema, AI_LIMITS } from "./ai-schemas.js";
|
|
5
|
+
import { DECISION_LIMITS } from "./decision-log.js";
|
|
6
|
+
import { normalisePath } from "./map-basics.js";
|
|
7
|
+
import { StructureMapSchema } from "./structure-map-schema.js";
|
|
8
|
+
/** Every size limit of the API in one place. */
|
|
9
|
+
export const API_LIMITS = {
|
|
10
|
+
maxBodyBytes: 102_400, // raw request body
|
|
11
|
+
maxFiles: 50,
|
|
12
|
+
maxPathChars: 300,
|
|
13
|
+
maxContentChars: 102_400,
|
|
14
|
+
maxSeed: 4_294_967_295,
|
|
15
|
+
maxAttempt: 1_000,
|
|
16
|
+
maxResponseBytes: 262_144, // largest reply the CLI reads
|
|
17
|
+
maxQuestions: 10,
|
|
18
|
+
};
|
|
19
|
+
// A path has no control characters (C0, DEL and C1).
|
|
20
|
+
const PATH_TEXT = /^[^\x00-\x1f\x7f-\x9f]+$/;
|
|
21
|
+
const sourceFileSchema = z.strictObject({
|
|
22
|
+
path: z.string().min(1).max(API_LIMITS.maxPathChars).regex(PATH_TEXT),
|
|
23
|
+
content: z.string().max(API_LIMITS.maxContentChars),
|
|
24
|
+
});
|
|
25
|
+
/** 1..50 files; no path may be empty after `normalisePath`, and no two may be the same after it. */
|
|
26
|
+
export const SourceFilesSchema = z
|
|
27
|
+
.array(sourceFileSchema)
|
|
28
|
+
.min(1)
|
|
29
|
+
.max(API_LIMITS.maxFiles)
|
|
30
|
+
.superRefine((files, ctx) => {
|
|
31
|
+
const seen = new Set();
|
|
32
|
+
files.forEach((file, index) => {
|
|
33
|
+
const path = normalisePath(file.path);
|
|
34
|
+
if (path === "" || seen.has(path))
|
|
35
|
+
ctx.addIssue({ code: "custom", message: "bad or repeated path", path: [index, "path"] });
|
|
36
|
+
seen.add(path);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
export const StructureRequestSchema = z.strictObject({ files: SourceFilesSchema });
|
|
40
|
+
export const QuizRequestSchema = z.strictObject({
|
|
41
|
+
files: SourceFilesSchema,
|
|
42
|
+
seed: z.int().min(0).max(API_LIMITS.maxSeed).optional(),
|
|
43
|
+
attempt: z.int().min(0).max(API_LIMITS.maxAttempt).optional(),
|
|
44
|
+
decision: z.string().min(1).max(DECISION_LIMITS.maxPromptChars).optional(), // the latest DECISIONS.md entry (Task 13)
|
|
45
|
+
});
|
|
46
|
+
export const GradeRequestSchema = z.strictObject({
|
|
47
|
+
item: QuizItemSchema.refine((item) => item.kind === "explain", { message: "item must be an explain question", path: ["kind"] }),
|
|
48
|
+
answer: z.string().max(AI_LIMITS.maxAnswerChars),
|
|
49
|
+
});
|
|
50
|
+
export const SERVED_BY_QUIZ = ["gemini", "nvidia", "openrouter", "structural"];
|
|
51
|
+
export const SERVED_BY_GRADE = ["gemini", "nvidia", "openrouter", "keyword"];
|
|
52
|
+
const modelSchema = z.string().min(1).max(200);
|
|
53
|
+
export const StructureResponseSchema = z.object({ map: StructureMapSchema });
|
|
54
|
+
/** `questions` are checked one by one by `parseQuizResponse`, so one bad question does not sink the rest. */
|
|
55
|
+
export const QuizResponseSchema = z.object({
|
|
56
|
+
questions: z.array(z.unknown()).max(API_LIMITS.maxQuestions),
|
|
57
|
+
servedBy: z.enum(SERVED_BY_QUIZ),
|
|
58
|
+
model: modelSchema.optional(),
|
|
59
|
+
});
|
|
60
|
+
export const GradeResponseSchema = z.object({
|
|
61
|
+
score: z.number().min(0).max(1),
|
|
62
|
+
feedback: z.string().max(AI_LIMITS.maxFeedbackChars),
|
|
63
|
+
rough: z.boolean(),
|
|
64
|
+
servedBy: z.enum(SERVED_BY_GRADE),
|
|
65
|
+
model: modelSchema.optional(),
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=api-schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-schemas.js","sourceRoot":"","sources":["../src/api-schemas.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,4GAA4G;AAC5G,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,gDAAgD;AAChD,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,YAAY,EAAE,OAAO,EAAE,mBAAmB;IAC1C,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,GAAG;IACjB,eAAe,EAAE,OAAO;IACxB,OAAO,EAAE,aAAa;IACtB,UAAU,EAAE,KAAK;IACjB,gBAAgB,EAAE,OAAO,EAAE,8BAA8B;IACzD,YAAY,EAAE,EAAE;CACR,CAAC;AAEX,qDAAqD;AACrD,MAAM,SAAS,GAAG,0BAA0B,CAAC;AAE7C,MAAM,gBAAgB,GAAG,CAAC,CAAC,YAAY,CAAC;IACtC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC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AE,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;IAChC,KAAK,EAAE,WAAW,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC;IACpD,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE;IAClB,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC;IACjC,KAAK,EAAE,WAAW,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const DECISIONS_PATH = "DECISIONS.md";
|
|
3
|
+
export declare const DECISION_LIMITS: {
|
|
4
|
+
readonly maxFileBytes: 262144;
|
|
5
|
+
readonly maxEntries: 200;
|
|
6
|
+
readonly maxTitleChars: 200;
|
|
7
|
+
readonly maxFieldChars: 1000;
|
|
8
|
+
readonly maxPromptChars: 4096;
|
|
9
|
+
};
|
|
10
|
+
export declare const DECISION_FIELDS: readonly ["built", "stuck", "options", "chose", "why", "openQuestions"];
|
|
11
|
+
export type DecisionField = (typeof DECISION_FIELDS)[number];
|
|
12
|
+
export declare const DECISION_LABELS: Record<DecisionField, string>;
|
|
13
|
+
export interface DecisionEntry {
|
|
14
|
+
date: string;
|
|
15
|
+
task: string;
|
|
16
|
+
title: string;
|
|
17
|
+
fields: Partial<Record<DecisionField, string>>;
|
|
18
|
+
line: number;
|
|
19
|
+
}
|
|
20
|
+
/** `entries` holds the last 200 entries in file order; `total` counts every entry heading. */
|
|
21
|
+
export interface DecisionLog {
|
|
22
|
+
entries: DecisionEntry[];
|
|
23
|
+
total: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Reads the entries of a DECISIONS.md text. One pass over the lines, never throws.
|
|
27
|
+
* Lines inside HTML comments and fenced code blocks are ignored; any other line outside an entry is ignored.
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseDecisionLog(text: string): DecisionLog;
|
|
30
|
+
/** The last entry by position (not by date). */
|
|
31
|
+
export declare function latestDecision(log: DecisionLog): DecisionEntry | undefined;
|
|
32
|
+
/** True when the entry says what was chosen and why (both present and not `none`). */
|
|
33
|
+
export declare function hasChoice(entry: DecisionEntry): boolean;
|
|
34
|
+
/** The heading and the six bullets of an entry, one line each, ending with a line break. */
|
|
35
|
+
export declare function renderDecisionEntry(entry: Omit<DecisionEntry, "line">): string;
|
|
36
|
+
/** The only form of an entry an AI prompt may contain: plain text, line breaks kept, at most 4 096 characters. */
|
|
37
|
+
export declare function decisionPromptText(entry: DecisionEntry): string;
|
|
38
|
+
/** A short hash of the heading (date, task, title). Used to notice that the latest entry changed. */
|
|
39
|
+
export declare function decisionKey(entry: DecisionEntry): string;
|
|
40
|
+
export declare const DecisionLogStateSchema: z.ZodObject<{
|
|
41
|
+
count: z.ZodInt;
|
|
42
|
+
latestKey: z.ZodNullable<z.ZodString>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export type DecisionLogState = {
|
|
45
|
+
count: number;
|
|
46
|
+
latestKey: string | null;
|
|
47
|
+
};
|
|
48
|
+
export declare function decisionLogState(log: DecisionLog): DecisionLogState;
|
|
49
|
+
export type DecisionCompare = "baseline" | "new-entry" | "no-new-entry";
|
|
50
|
+
/** `baseline` without a stored state; `new-entry` when the count grew or the latest heading changed. */
|
|
51
|
+
export declare function compareDecisionLog(stored: DecisionLogState | undefined, log: DecisionLog): DecisionCompare;
|
|
52
|
+
/** What `seance sync` found when it tried to read DECISIONS.md. */
|
|
53
|
+
export type DecisionRead = {
|
|
54
|
+
type: "missing";
|
|
55
|
+
} | {
|
|
56
|
+
type: "other";
|
|
57
|
+
} | {
|
|
58
|
+
type: "file";
|
|
59
|
+
text: string;
|
|
60
|
+
};
|
|
61
|
+
export declare const DECISION_LINES: {
|
|
62
|
+
readonly missing: "DECISIONS.md not found; run seance init to create it";
|
|
63
|
+
readonly other: "DECISIONS.md skipped (not a regular UTF-8 file under 256 KB)";
|
|
64
|
+
readonly none: "no new entry in DECISIONS.md since the last sync; the agent should add one after each task";
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* The decision check of `seance sync`: the one line to print (without the `seance sync: ` prefix) and the state to store.
|
|
68
|
+
* `next` undefined means keep the stored value. `stored` is the raw `decisionLog` of the state file; a bad value is a baseline.
|
|
69
|
+
*/
|
|
70
|
+
export declare function decisionCheck(read: DecisionRead, stored: unknown): {
|
|
71
|
+
line?: string;
|
|
72
|
+
next?: DecisionLogState;
|
|
73
|
+
};
|