fito-tui 0.2.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/README.md +88 -0
- package/agents/fito-case-source-planner.md +265 -0
- package/agents/fito-performance-reviewer.md +231 -0
- package/agents/fito-practice-concept-content-generator.md +318 -0
- package/agents/fito-practice-concept-identifier.md +482 -0
- package/agents/fito-practice-execution-fact-content-generator.md +299 -0
- package/agents/fito-practice-execution-fact-identifier.md +367 -0
- package/agents/fito-practice-usage-scenario-content-generator.md +331 -0
- package/agents/fito-practice-usage-scenario-identifier.md +397 -0
- package/agents/fito-subagent-selftest.md +27 -0
- package/agents/fito-technology-generator.md +207 -0
- package/agents/fito-tool-concept-content-generator.md +282 -0
- package/agents/fito-tool-concept-identifier.md +384 -0
- package/agents/fito-tool-execution-fact-content-generator.md +382 -0
- package/agents/fito-tool-execution-fact-identifier.md +360 -0
- package/agents/fito-tool-usage-scenario-content-generator.md +381 -0
- package/agents/fito-tool-usage-scenario-identifier.md +432 -0
- package/agents/fito-tutor.md +185 -0
- package/extensions/fito-delegate.js +539 -0
- package/extensions/fito-delegate.ts +691 -0
- package/extensions/fito-fetch-tools.js +380 -0
- package/extensions/fito-fetch-tools.ts +419 -0
- package/extensions/fito-startup.js +166 -0
- package/extensions/fito-startup.ts +188 -0
- package/package.json +56 -0
- package/prompts/fito-auth-refresh.md +15 -0
- package/prompts/fito-case-design.md +506 -0
- package/prompts/fito-case-edit.md +91 -0
- package/prompts/fito-case-generate.md +222 -0
- package/prompts/fito-case-open.md +124 -0
- package/prompts/fito-case-plan-source.md +114 -0
- package/prompts/fito-create-or-update-competence.md +261 -0
- package/prompts/fito-create-or-update-technology.md +199 -0
- package/prompts/fito-delete-competence.md +147 -0
- package/prompts/fito-evaluate.md +148 -0
- package/prompts/fito-fetch-urls-content.md +35 -0
- package/prompts/fito-generate-domain-concepts.md +85 -0
- package/prompts/fito-generate-execution-facts.md +85 -0
- package/prompts/fito-generate-usage-scenarios.md +85 -0
- package/prompts/fito-identify-domain-concepts.md +49 -0
- package/prompts/fito-identify-execution-facts.md +49 -0
- package/prompts/fito-identify-usage-scenarios.md +49 -0
- package/prompts/fito-login.md +21 -0
- package/prompts/fito-logout.md +14 -0
- package/prompts/fito-publish-case.md +266 -0
- package/prompts/fito-push-knowledge.md +84 -0
- package/prompts/fito-submit.md +208 -0
- package/prompts/fito-tutor.md +120 -0
- package/shared/case-briefing/briefing.js +221 -0
- package/shared/case-briefing/briefing.ts +261 -0
- package/shared/case-quiz/scoring.js +16 -0
- package/shared/case-quiz/scoring.ts +61 -0
- package/shared/case-validation/case-loader.js +88 -0
- package/shared/case-validation/case-loader.ts +106 -0
- package/shared/case-validation/case-schema.js +716 -0
- package/shared/case-validation/case-schema.ts +895 -0
- package/shared/competences/competence-list.js +29 -0
- package/shared/competences/competence-list.ts +32 -0
- package/shared/fito-api/README.md +192 -0
- package/shared/fito-api/client.js +731 -0
- package/shared/fito-api/client.ts +1426 -0
- package/shared/fito-session/credentials.js +79 -0
- package/shared/fito-session/credentials.ts +88 -0
- package/shared/fito-session/session.js +16 -0
- package/shared/fito-session/session.ts +35 -0
- package/shared/github-url/parse.js +26 -0
- package/shared/github-url/parse.ts +35 -0
- package/shared/knowledge-components/component-names.js +35 -0
- package/shared/knowledge-components/component-names.ts +39 -0
- package/shared/knowledge-components/knowledge-fetch.js +46 -0
- package/shared/knowledge-components/knowledge-fetch.ts +57 -0
- package/shared/knowledge-components/knowledge-search.js +101 -0
- package/shared/knowledge-components/knowledge-search.ts +144 -0
- package/shared/knowledge-components/push-payload.js +104 -0
- package/shared/knowledge-components/push-payload.ts +129 -0
- package/shared/knowledge-components/reference.js +24 -0
- package/shared/knowledge-components/reference.ts +43 -0
- package/shared/knowledge-components/technology-fetch.js +30 -0
- package/shared/knowledge-components/technology-fetch.ts +38 -0
- package/shared/shell-exec/exec.js +22 -0
- package/shared/shell-exec/exec.ts +46 -0
- package/skills/fito-auth/SKILL.md +68 -0
- package/skills/fito-auth/auth-refresh.js +23 -0
- package/skills/fito-auth/auth-refresh.ts +25 -0
- package/skills/fito-auth/browser.js +35 -0
- package/skills/fito-auth/browser.ts +57 -0
- package/skills/fito-auth/callback-server.js +152 -0
- package/skills/fito-auth/callback-server.ts +189 -0
- package/skills/fito-auth/login.js +37 -0
- package/skills/fito-auth/login.ts +42 -0
- package/skills/fito-auth/logout.js +24 -0
- package/skills/fito-auth/logout.ts +25 -0
- package/skills/fito-case-author/SKILL.md +179 -0
- package/skills/fito-case-author/checkout.js +222 -0
- package/skills/fito-case-author/checkout.ts +281 -0
- package/skills/fito-case-author/github-publish.js +218 -0
- package/skills/fito-case-author/github-publish.ts +251 -0
- package/skills/fito-case-author/publish-payload.js +108 -0
- package/skills/fito-case-author/publish-payload.ts +186 -0
- package/skills/fito-case-author/publish-state.js +72 -0
- package/skills/fito-case-author/publish-state.ts +87 -0
- package/skills/fito-case-author/publish-version.js +364 -0
- package/skills/fito-case-author/publish-version.ts +495 -0
- package/skills/fito-case-author/publish.js +284 -0
- package/skills/fito-case-author/publish.ts +394 -0
- package/skills/fito-case-author/semver.js +55 -0
- package/skills/fito-case-author/semver.ts +63 -0
- package/skills/fito-case-author/status-gate.js +34 -0
- package/skills/fito-case-author/status-gate.ts +54 -0
- package/skills/fito-case-author/validate.js +62 -0
- package/skills/fito-case-author/validate.ts +64 -0
- package/skills/fito-case-runner/SKILL.md +119 -0
- package/skills/fito-case-runner/case-component-names.js +45 -0
- package/skills/fito-case-runner/case-component-names.ts +65 -0
- package/skills/fito-case-runner/case-detail.js +20 -0
- package/skills/fito-case-runner/case-detail.ts +20 -0
- package/skills/fito-case-runner/github.js +234 -0
- package/skills/fito-case-runner/github.ts +287 -0
- package/skills/fito-case-runner/manifest.js +56 -0
- package/skills/fito-case-runner/manifest.ts +73 -0
- package/skills/fito-case-runner/open.js +175 -0
- package/skills/fito-case-runner/open.ts +241 -0
- package/skills/fito-case-runner/report.js +22 -0
- package/skills/fito-case-runner/report.ts +24 -0
- package/skills/fito-case-runner/runner.js +158 -0
- package/skills/fito-case-runner/runner.ts +304 -0
- package/skills/fito-case-runner/score-quiz-mc.js +85 -0
- package/skills/fito-case-runner/score-quiz-mc.ts +99 -0
- package/skills/fito-case-runner/submit-evaluation.js +73 -0
- package/skills/fito-case-runner/submit-evaluation.ts +98 -0
- package/skills/fito-case-runner/submit-quiz-result.js +75 -0
- package/skills/fito-case-runner/submit-quiz-result.ts +100 -0
- package/skills/fito-case-runner/submit.js +85 -0
- package/skills/fito-case-runner/submit.ts +111 -0
- package/skills/fito-case-runner/workdir.js +10 -0
- package/skills/fito-case-runner/workdir.ts +11 -0
- package/skills/fito-competence-write/SKILL.md +155 -0
- package/skills/fito-competence-write/create.js +64 -0
- package/skills/fito-competence-write/create.ts +80 -0
- package/skills/fito-competence-write/delete.js +136 -0
- package/skills/fito-competence-write/delete.ts +166 -0
- package/skills/fito-competence-write/display.js +20 -0
- package/skills/fito-competence-write/display.ts +21 -0
- package/skills/fito-competence-write/payload.js +96 -0
- package/skills/fito-competence-write/payload.ts +115 -0
- package/skills/fito-competence-write/update.js +155 -0
- package/skills/fito-competence-write/update.ts +206 -0
- package/skills/fito-evaluator/SKILL.md +73 -0
- package/skills/fito-evaluator/criterion-exec.js +64 -0
- package/skills/fito-evaluator/criterion-exec.ts +73 -0
- package/skills/fito-evaluator/evaluate-automated.js +57 -0
- package/skills/fito-evaluator/evaluate-automated.ts +84 -0
- package/skills/fito-evaluator/evaluate.js +28 -0
- package/skills/fito-evaluator/evaluate.ts +86 -0
- package/skills/fito-evaluator/report.js +112 -0
- package/skills/fito-evaluator/report.ts +128 -0
- package/skills/fito-evaluator/rubric.js +90 -0
- package/skills/fito-evaluator/rubric.ts +170 -0
- package/skills/fito-knowledge-push/SKILL.md +114 -0
- package/skills/fito-knowledge-push/push.js +282 -0
- package/skills/fito-knowledge-push/push.ts +360 -0
- package/skills/fito-source-ingestion/SKILL.md +77 -0
- package/skills/fito-source-ingestion/authoring-check.js +128 -0
- package/skills/fito-source-ingestion/authoring-check.ts +155 -0
- package/skills/fito-source-ingestion/bundle.js +198 -0
- package/skills/fito-source-ingestion/bundle.ts +246 -0
- package/skills/fito-technology-write/SKILL.md +108 -0
- package/skills/fito-technology-write/create.js +134 -0
- package/skills/fito-technology-write/create.ts +161 -0
- package/skills/fito-technology-write/payload.js +64 -0
- package/skills/fito-technology-write/payload.ts +70 -0
- package/skills/fito-technology-write/update.js +122 -0
- package/skills/fito-technology-write/update.ts +171 -0
- package/skills/fito-url-content-fetcher/SKILL.md +213 -0
- package/templates/concept-practice-content-template.md +281 -0
- package/templates/concept-tool-content-template.md +207 -0
- package/templates/execution-fact-practice-content-template.md +372 -0
- package/templates/execution-fact-tool-content-template.md +307 -0
- package/templates/usage-scenario-content-template.md +248 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `node evaluate-automated.js <case-id>` — the `fito-performance-reviewer` automated-criteria
|
|
3
|
+
* entrypoint (Task 6.1). Resolves the learner's per-case checkout (`~/.fito/cases/<case-id>/`, the
|
|
4
|
+
* same location `/fito-case-open` writes), loads its `rubric.yaml`, runs every `automated` criterion's
|
|
5
|
+
* command, and prints the captured-evidence report. The `/fito-evaluate` prompt runs this, then hands
|
|
6
|
+
* the report to the reviewer subagent for scoring.
|
|
7
|
+
*
|
|
8
|
+
* `runEvaluate` is the testable core (deps injectable); `main` is the thin CLI wrapper (argv + real
|
|
9
|
+
* deps + printing). It performs no submission and writes nothing to the backend — evaluation on submit
|
|
10
|
+
* is the `/fito-submit` round-trip (Task 6.3).
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync } from "node:fs";
|
|
13
|
+
import * as os from "node:os";
|
|
14
|
+
import * as path from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
|
|
17
|
+
import { caseWorkDir } from "../fito-case-runner/workdir.ts";
|
|
18
|
+
import type { AutomatedExecutor } from "./evaluate.ts";
|
|
19
|
+
import { evaluateAutomatedCriteria, evaluateHybridGates } from "./evaluate.ts";
|
|
20
|
+
import { shellExec } from "./criterion-exec.ts";
|
|
21
|
+
import { renderReport } from "./report.ts";
|
|
22
|
+
import type { Rubric } from "./rubric.ts";
|
|
23
|
+
import {
|
|
24
|
+
loadRubric,
|
|
25
|
+
selectAICriteria,
|
|
26
|
+
selectAutomatedCriteria,
|
|
27
|
+
selectHybridCriteria,
|
|
28
|
+
selectSkippedCriteria,
|
|
29
|
+
} from "./rubric.ts";
|
|
30
|
+
|
|
31
|
+
export interface RunEvaluateOptions {
|
|
32
|
+
caseId: string;
|
|
33
|
+
home?: string;
|
|
34
|
+
/** Runs a criterion's command; defaults to the real `sh -c` executor. Injected for tests. */
|
|
35
|
+
exec?: AutomatedExecutor;
|
|
36
|
+
/** Reads + validates the checkout's rubric; defaults to {@link loadRubric}. Injected for tests. */
|
|
37
|
+
load?: (repoRoot: string) => Rubric;
|
|
38
|
+
/** Optional progress sink (per criterion); the CLI wires this to stderr so it never pollutes the report. */
|
|
39
|
+
onProgress?: (message: string) => void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Resolve the checkout → load the rubric → run the automated criteria → return the rendered report. */
|
|
43
|
+
export async function runEvaluate(options: RunEvaluateOptions): Promise<string> {
|
|
44
|
+
const home = options.home ?? os.homedir();
|
|
45
|
+
const dir = caseWorkDir(options.caseId, home);
|
|
46
|
+
|
|
47
|
+
if (!existsSync(dir)) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`No open case at:\n ${dir}\n` +
|
|
50
|
+
`Open it first with: /fito-case-open ${options.caseId}`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const load = options.load ?? loadRubric;
|
|
55
|
+
const rubric = load(dir);
|
|
56
|
+
const exec = options.exec ?? shellExec;
|
|
57
|
+
const runs = await evaluateAutomatedCriteria(selectAutomatedCriteria(rubric), exec, dir, options.onProgress);
|
|
58
|
+
// Hybrid gates run deterministically here (inheriting the 5-min timeout); the pass/fail judgment
|
|
59
|
+
// against `passingCondition` and the AI fallback are the reviewer subagent's job (Task 6.2).
|
|
60
|
+
const hybridRuns = await evaluateHybridGates(selectHybridCriteria(rubric), exec, dir, options.onProgress);
|
|
61
|
+
return renderReport(runs, selectSkippedCriteria(rubric), selectAICriteria(rubric), hybridRuns);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function main(): Promise<void> {
|
|
65
|
+
const caseId = process.argv[2];
|
|
66
|
+
if (!caseId) {
|
|
67
|
+
console.error("Usage: node evaluate-automated.js <case-id>");
|
|
68
|
+
process.exitCode = 1;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// Progress → stderr so it never mixes into the report on stdout (which the reviewer scores).
|
|
72
|
+
const report = await runEvaluate({ caseId, onProgress: (message) => console.error(message) });
|
|
73
|
+
console.log(report);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Only auto-invoke the CLI when run directly (`node evaluate-automated.js …`), not when imported. */
|
|
77
|
+
const entry = process.argv[1];
|
|
78
|
+
const isMainModule = !!entry && path.resolve(entry) === fileURLToPath(import.meta.url);
|
|
79
|
+
if (isMainModule) {
|
|
80
|
+
main().catch((error: unknown) => {
|
|
81
|
+
console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
|
|
82
|
+
process.exitCode = 1;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Run each criterion's `command` in `cwd`, in rubric order, capturing the evidence for scoring. */
|
|
2
|
+
export async function evaluateAutomatedCriteria(criteria, exec, cwd, onProgress) {
|
|
3
|
+
const runs = [];
|
|
4
|
+
for (const criterion of criteria) {
|
|
5
|
+
// Commands can be slow (builds/tests) — announce each before it runs so the learner isn't blind.
|
|
6
|
+
onProgress?.(`Running ${criterion.id}: ${criterion.command}`);
|
|
7
|
+
const result = await exec(criterion.command, { cwd });
|
|
8
|
+
onProgress?.(` → ${criterion.id} exited ${result.exitCode}`);
|
|
9
|
+
runs.push({ criterion, stdout: result.stdout, stderr: result.stderr, exitCode: result.exitCode });
|
|
10
|
+
}
|
|
11
|
+
return runs;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Run each hybrid criterion's automated **gate** `command` in `cwd`, in rubric order, capturing the
|
|
15
|
+
* evidence the reviewer judges against `passingCondition`. The pass→`onPass` / fail→`onFail` branch is
|
|
16
|
+
* the reviewer's judgment (Task 6.2), made over this evidence — not here. Runs over the same injectable
|
|
17
|
+
* executor (and its 15-minute timeout) as automated criteria, so a hung gate can't stall the rest.
|
|
18
|
+
*/
|
|
19
|
+
export async function evaluateHybridGates(criteria, exec, cwd, onProgress) {
|
|
20
|
+
const runs = [];
|
|
21
|
+
for (const criterion of criteria) {
|
|
22
|
+
onProgress?.(`Running hybrid gate ${criterion.id}: ${criterion.gateCommand}`);
|
|
23
|
+
const result = await exec(criterion.gateCommand, { cwd });
|
|
24
|
+
onProgress?.(` → ${criterion.id} gate exited ${result.exitCode}`);
|
|
25
|
+
runs.push({ criterion, stdout: result.stdout, stderr: result.stderr, exitCode: result.exitCode });
|
|
26
|
+
}
|
|
27
|
+
return runs;
|
|
28
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { AutomatedCriterion, HybridCriterion } from "./rubric.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Run a case's automated rubric criteria — and hybrid criteria's automated gates — collecting the
|
|
5
|
+
* captured evidence the reviewer scores (Tasks 6.1 + 6.2).
|
|
6
|
+
*
|
|
7
|
+
* Pure sequencing over an injectable `exec` (the real `sh -c` spawner is wired by the entrypoint
|
|
8
|
+
* `evaluate-automated.ts`), so command ordering + evidence assembly are unit-tested against a fake —
|
|
9
|
+
* no shell, no checkout. A command exiting non-zero is **evidence the reviewer judges**, not an error,
|
|
10
|
+
* so the executor returns the exit code instead of throwing.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export interface CommandResult {
|
|
14
|
+
stdout: string;
|
|
15
|
+
stderr: string;
|
|
16
|
+
exitCode: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Runs a free-form shell command in `cwd`, capturing output + exit code (never throws on non-zero).
|
|
21
|
+
* `timeoutMs` caps the run before the command is terminated and reported as evidence; omit it to use
|
|
22
|
+
* the executor's default.
|
|
23
|
+
*/
|
|
24
|
+
export type AutomatedExecutor = (
|
|
25
|
+
command: string,
|
|
26
|
+
options: { cwd: string; timeoutMs?: number },
|
|
27
|
+
) => Promise<CommandResult>;
|
|
28
|
+
|
|
29
|
+
/** A criterion's command run + its captured output — the evidence the reviewer scores against. */
|
|
30
|
+
export interface AutomatedCriterionRun {
|
|
31
|
+
criterion: AutomatedCriterion;
|
|
32
|
+
stdout: string;
|
|
33
|
+
stderr: string;
|
|
34
|
+
exitCode: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Optional sink for human-readable progress lines (the CLI sends these to stderr). */
|
|
38
|
+
export type ProgressReporter = (message: string) => void;
|
|
39
|
+
|
|
40
|
+
/** Run each criterion's `command` in `cwd`, in rubric order, capturing the evidence for scoring. */
|
|
41
|
+
export async function evaluateAutomatedCriteria(
|
|
42
|
+
criteria: AutomatedCriterion[],
|
|
43
|
+
exec: AutomatedExecutor,
|
|
44
|
+
cwd: string,
|
|
45
|
+
onProgress?: ProgressReporter,
|
|
46
|
+
): Promise<AutomatedCriterionRun[]> {
|
|
47
|
+
const runs: AutomatedCriterionRun[] = [];
|
|
48
|
+
for (const criterion of criteria) {
|
|
49
|
+
// Commands can be slow (builds/tests) — announce each before it runs so the learner isn't blind.
|
|
50
|
+
onProgress?.(`Running ${criterion.id}: ${criterion.command}`);
|
|
51
|
+
const result = await exec(criterion.command, { cwd });
|
|
52
|
+
onProgress?.(` → ${criterion.id} exited ${result.exitCode}`);
|
|
53
|
+
runs.push({ criterion, stdout: result.stdout, stderr: result.stderr, exitCode: result.exitCode });
|
|
54
|
+
}
|
|
55
|
+
return runs;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** A hybrid criterion's automated-gate run + its captured output — the evidence the reviewer judges. */
|
|
59
|
+
export interface HybridCriterionRun {
|
|
60
|
+
criterion: HybridCriterion;
|
|
61
|
+
stdout: string;
|
|
62
|
+
stderr: string;
|
|
63
|
+
exitCode: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Run each hybrid criterion's automated **gate** `command` in `cwd`, in rubric order, capturing the
|
|
68
|
+
* evidence the reviewer judges against `passingCondition`. The pass→`onPass` / fail→`onFail` branch is
|
|
69
|
+
* the reviewer's judgment (Task 6.2), made over this evidence — not here. Runs over the same injectable
|
|
70
|
+
* executor (and its 15-minute timeout) as automated criteria, so a hung gate can't stall the rest.
|
|
71
|
+
*/
|
|
72
|
+
export async function evaluateHybridGates(
|
|
73
|
+
criteria: HybridCriterion[],
|
|
74
|
+
exec: AutomatedExecutor,
|
|
75
|
+
cwd: string,
|
|
76
|
+
onProgress?: ProgressReporter,
|
|
77
|
+
): Promise<HybridCriterionRun[]> {
|
|
78
|
+
const runs: HybridCriterionRun[] = [];
|
|
79
|
+
for (const criterion of criteria) {
|
|
80
|
+
onProgress?.(`Running hybrid gate ${criterion.id}: ${criterion.gateCommand}`);
|
|
81
|
+
const result = await exec(criterion.gateCommand, { cwd });
|
|
82
|
+
onProgress?.(` → ${criterion.id} gate exited ${result.exitCode}`);
|
|
83
|
+
runs.push({ criterion, stdout: result.stdout, stderr: result.stderr, exitCode: result.exitCode });
|
|
84
|
+
}
|
|
85
|
+
return runs;
|
|
86
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render the rubric evaluation into one self-contained text report (Tasks 6.1 + 6.2).
|
|
3
|
+
*
|
|
4
|
+
* This is what `evaluate-automated.ts` prints and what the `/fito-evaluate` prompt hands to the
|
|
5
|
+
* `fito-performance-reviewer` subagent. It carries the deterministic, rubric-derived material the
|
|
6
|
+
* reviewer needs to score: the automated criteria's captured evidence (command + exit + stdout/stderr),
|
|
7
|
+
* the `ai` criteria's prompt hints + scoring bands, and the `hybrid` criteria's gate evidence + branch
|
|
8
|
+
* config. The reviewer reads the learner's artifacts/diff from the checkout itself; this report does
|
|
9
|
+
* not embed them. Pure (returns the text); the entrypoint prints it.
|
|
10
|
+
*/
|
|
11
|
+
/** Fence-free delimiters so embedded stdout/stderr never collides with surrounding markdown fences. */
|
|
12
|
+
function block(label, content) {
|
|
13
|
+
const body = content.trim().length > 0 ? content.replace(/\s+$/, "") : "(empty)";
|
|
14
|
+
return [`--- ${label} ---`, body, `--- end ${label} ---`].join("\n");
|
|
15
|
+
}
|
|
16
|
+
function renderLevels(levels) {
|
|
17
|
+
return ["Scoring levels:", ...levels.map((l) => ` - score ${l.score} (${l.label}): ${l.description}`)].join("\n");
|
|
18
|
+
}
|
|
19
|
+
function renderRun(run) {
|
|
20
|
+
const { criterion } = run;
|
|
21
|
+
return [
|
|
22
|
+
`## Criterion: ${criterion.id} — ${criterion.title}`,
|
|
23
|
+
`- Knowledge component: ${criterion.knowledgeComponent}`,
|
|
24
|
+
`- Bloom level: ${criterion.bloomLevel}`,
|
|
25
|
+
`- Command: ${criterion.command}`,
|
|
26
|
+
`- Exit code: ${run.exitCode}`,
|
|
27
|
+
`- Passing condition: ${criterion.passingCondition}`,
|
|
28
|
+
"",
|
|
29
|
+
renderLevels(criterion.levels),
|
|
30
|
+
"",
|
|
31
|
+
block("stdout", run.stdout),
|
|
32
|
+
"",
|
|
33
|
+
block("stderr", run.stderr),
|
|
34
|
+
].join("\n");
|
|
35
|
+
}
|
|
36
|
+
function renderAICriterion(criterion) {
|
|
37
|
+
return [
|
|
38
|
+
`## AI criterion: ${criterion.id} — ${criterion.title}`,
|
|
39
|
+
`- Knowledge component: ${criterion.knowledgeComponent}`,
|
|
40
|
+
`- Bloom level: ${criterion.bloomLevel}`,
|
|
41
|
+
`- Prompt hint: ${criterion.promptHint}`,
|
|
42
|
+
"",
|
|
43
|
+
renderLevels(criterion.levels),
|
|
44
|
+
].join("\n");
|
|
45
|
+
}
|
|
46
|
+
function renderHybridRun(run) {
|
|
47
|
+
const { criterion } = run;
|
|
48
|
+
const lines = [
|
|
49
|
+
`## Hybrid criterion: ${criterion.id} — ${criterion.title}`,
|
|
50
|
+
`- Knowledge component: ${criterion.knowledgeComponent}`,
|
|
51
|
+
`- Bloom level: ${criterion.bloomLevel}`,
|
|
52
|
+
`- Gate command: ${criterion.gateCommand}`,
|
|
53
|
+
`- Gate exit code: ${run.exitCode}`,
|
|
54
|
+
`- Passing condition: ${criterion.passingCondition}`,
|
|
55
|
+
`- On pass: assign level "${criterion.onPass}"`,
|
|
56
|
+
`- On fail: ${criterion.onFail}`,
|
|
57
|
+
];
|
|
58
|
+
if (criterion.fallbackPromptHint)
|
|
59
|
+
lines.push(`- Fallback prompt hint: ${criterion.fallbackPromptHint}`);
|
|
60
|
+
return [
|
|
61
|
+
...lines,
|
|
62
|
+
"",
|
|
63
|
+
renderLevels(criterion.levels),
|
|
64
|
+
"",
|
|
65
|
+
block("gate stdout", run.stdout),
|
|
66
|
+
"",
|
|
67
|
+
block("gate stderr", run.stderr),
|
|
68
|
+
].join("\n");
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The `ai` and `hybrid` criteria the reviewer scores from the learner's work in the checkout. AI
|
|
72
|
+
* criteria carry their prompt hint; hybrid criteria carry their gate evidence (judged against the
|
|
73
|
+
* passing condition first, then `onPass`/`onFail`). Empty when the case has neither.
|
|
74
|
+
*/
|
|
75
|
+
function renderAiAndHybrid(aiCriteria, hybridRuns) {
|
|
76
|
+
const total = aiCriteria.length + hybridRuns.length;
|
|
77
|
+
const header = `# AI- and hybrid-scored criteria — ${total} criteri${total === 1 ? "on" : "a"}`;
|
|
78
|
+
return [header, ...aiCriteria.map(renderAICriterion), ...hybridRuns.map(renderHybridRun)].join("\n\n");
|
|
79
|
+
}
|
|
80
|
+
/** A "## Needs human review" section listing the `human` criteria neither automated nor AI scoring covers. */
|
|
81
|
+
function renderSkipped(skipped) {
|
|
82
|
+
const one = skipped.length === 1;
|
|
83
|
+
const lines = skipped.map((s) => `- ${s.id} — ${s.title}`);
|
|
84
|
+
return [
|
|
85
|
+
`## Needs human review — ${skipped.length} criteri${one ? "on" : "a"}`,
|
|
86
|
+
...lines,
|
|
87
|
+
"",
|
|
88
|
+
"These have a `human` evaluation method and can only be scored by a person — not in this preview.",
|
|
89
|
+
].join("\n");
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Render the full report: the automated criteria's captured evidence, the `ai`/`hybrid` criteria the
|
|
93
|
+
* reviewer scores from the checkout, and a "needs human review" list of any `human` criteria. With no
|
|
94
|
+
* automated criteria, says so explicitly (and still renders the other sections).
|
|
95
|
+
*/
|
|
96
|
+
export function renderReport(runs, skipped = [], aiCriteria = [], hybridRuns = []) {
|
|
97
|
+
const sections = [];
|
|
98
|
+
if (runs.length === 0) {
|
|
99
|
+
sections.push(["# Automated rubric evaluation", "", "No automated rubric criteria in this case."].join("\n"));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
const header = `# Automated rubric evaluation — ${runs.length} criteri${runs.length === 1 ? "on" : "a"}`;
|
|
103
|
+
sections.push(header, ...runs.map(renderRun));
|
|
104
|
+
}
|
|
105
|
+
if (aiCriteria.length > 0 || hybridRuns.length > 0) {
|
|
106
|
+
sections.push(renderAiAndHybrid(aiCriteria, hybridRuns));
|
|
107
|
+
}
|
|
108
|
+
if (skipped.length > 0) {
|
|
109
|
+
sections.push(renderSkipped(skipped));
|
|
110
|
+
}
|
|
111
|
+
return sections.join("\n\n");
|
|
112
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { AutomatedCriterionRun, HybridCriterionRun } from "./evaluate.ts";
|
|
2
|
+
import type { AICriterion, RubricLevel, SkippedCriterion } from "./rubric.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Render the rubric evaluation into one self-contained text report (Tasks 6.1 + 6.2).
|
|
6
|
+
*
|
|
7
|
+
* This is what `evaluate-automated.ts` prints and what the `/fito-evaluate` prompt hands to the
|
|
8
|
+
* `fito-performance-reviewer` subagent. It carries the deterministic, rubric-derived material the
|
|
9
|
+
* reviewer needs to score: the automated criteria's captured evidence (command + exit + stdout/stderr),
|
|
10
|
+
* the `ai` criteria's prompt hints + scoring bands, and the `hybrid` criteria's gate evidence + branch
|
|
11
|
+
* config. The reviewer reads the learner's artifacts/diff from the checkout itself; this report does
|
|
12
|
+
* not embed them. Pure (returns the text); the entrypoint prints it.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** Fence-free delimiters so embedded stdout/stderr never collides with surrounding markdown fences. */
|
|
16
|
+
function block(label: string, content: string): string {
|
|
17
|
+
const body = content.trim().length > 0 ? content.replace(/\s+$/, "") : "(empty)";
|
|
18
|
+
return [`--- ${label} ---`, body, `--- end ${label} ---`].join("\n");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function renderLevels(levels: RubricLevel[]): string {
|
|
22
|
+
return ["Scoring levels:", ...levels.map((l) => ` - score ${l.score} (${l.label}): ${l.description}`)].join("\n");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function renderRun(run: AutomatedCriterionRun): string {
|
|
26
|
+
const { criterion } = run;
|
|
27
|
+
return [
|
|
28
|
+
`## Criterion: ${criterion.id} — ${criterion.title}`,
|
|
29
|
+
`- Knowledge component: ${criterion.knowledgeComponent}`,
|
|
30
|
+
`- Bloom level: ${criterion.bloomLevel}`,
|
|
31
|
+
`- Command: ${criterion.command}`,
|
|
32
|
+
`- Exit code: ${run.exitCode}`,
|
|
33
|
+
`- Passing condition: ${criterion.passingCondition}`,
|
|
34
|
+
"",
|
|
35
|
+
renderLevels(criterion.levels),
|
|
36
|
+
"",
|
|
37
|
+
block("stdout", run.stdout),
|
|
38
|
+
"",
|
|
39
|
+
block("stderr", run.stderr),
|
|
40
|
+
].join("\n");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function renderAICriterion(criterion: AICriterion): string {
|
|
44
|
+
return [
|
|
45
|
+
`## AI criterion: ${criterion.id} — ${criterion.title}`,
|
|
46
|
+
`- Knowledge component: ${criterion.knowledgeComponent}`,
|
|
47
|
+
`- Bloom level: ${criterion.bloomLevel}`,
|
|
48
|
+
`- Prompt hint: ${criterion.promptHint}`,
|
|
49
|
+
"",
|
|
50
|
+
renderLevels(criterion.levels),
|
|
51
|
+
].join("\n");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function renderHybridRun(run: HybridCriterionRun): string {
|
|
55
|
+
const { criterion } = run;
|
|
56
|
+
const lines = [
|
|
57
|
+
`## Hybrid criterion: ${criterion.id} — ${criterion.title}`,
|
|
58
|
+
`- Knowledge component: ${criterion.knowledgeComponent}`,
|
|
59
|
+
`- Bloom level: ${criterion.bloomLevel}`,
|
|
60
|
+
`- Gate command: ${criterion.gateCommand}`,
|
|
61
|
+
`- Gate exit code: ${run.exitCode}`,
|
|
62
|
+
`- Passing condition: ${criterion.passingCondition}`,
|
|
63
|
+
`- On pass: assign level "${criterion.onPass}"`,
|
|
64
|
+
`- On fail: ${criterion.onFail}`,
|
|
65
|
+
];
|
|
66
|
+
if (criterion.fallbackPromptHint) lines.push(`- Fallback prompt hint: ${criterion.fallbackPromptHint}`);
|
|
67
|
+
return [
|
|
68
|
+
...lines,
|
|
69
|
+
"",
|
|
70
|
+
renderLevels(criterion.levels),
|
|
71
|
+
"",
|
|
72
|
+
block("gate stdout", run.stdout),
|
|
73
|
+
"",
|
|
74
|
+
block("gate stderr", run.stderr),
|
|
75
|
+
].join("\n");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The `ai` and `hybrid` criteria the reviewer scores from the learner's work in the checkout. AI
|
|
80
|
+
* criteria carry their prompt hint; hybrid criteria carry their gate evidence (judged against the
|
|
81
|
+
* passing condition first, then `onPass`/`onFail`). Empty when the case has neither.
|
|
82
|
+
*/
|
|
83
|
+
function renderAiAndHybrid(aiCriteria: AICriterion[], hybridRuns: HybridCriterionRun[]): string {
|
|
84
|
+
const total = aiCriteria.length + hybridRuns.length;
|
|
85
|
+
const header = `# AI- and hybrid-scored criteria — ${total} criteri${total === 1 ? "on" : "a"}`;
|
|
86
|
+
return [header, ...aiCriteria.map(renderAICriterion), ...hybridRuns.map(renderHybridRun)].join("\n\n");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** A "## Needs human review" section listing the `human` criteria neither automated nor AI scoring covers. */
|
|
90
|
+
function renderSkipped(skipped: SkippedCriterion[]): string {
|
|
91
|
+
const one = skipped.length === 1;
|
|
92
|
+
const lines = skipped.map((s) => `- ${s.id} — ${s.title}`);
|
|
93
|
+
return [
|
|
94
|
+
`## Needs human review — ${skipped.length} criteri${one ? "on" : "a"}`,
|
|
95
|
+
...lines,
|
|
96
|
+
"",
|
|
97
|
+
"These have a `human` evaluation method and can only be scored by a person — not in this preview.",
|
|
98
|
+
].join("\n");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Render the full report: the automated criteria's captured evidence, the `ai`/`hybrid` criteria the
|
|
103
|
+
* reviewer scores from the checkout, and a "needs human review" list of any `human` criteria. With no
|
|
104
|
+
* automated criteria, says so explicitly (and still renders the other sections).
|
|
105
|
+
*/
|
|
106
|
+
export function renderReport(
|
|
107
|
+
runs: AutomatedCriterionRun[],
|
|
108
|
+
skipped: SkippedCriterion[] = [],
|
|
109
|
+
aiCriteria: AICriterion[] = [],
|
|
110
|
+
hybridRuns: HybridCriterionRun[] = [],
|
|
111
|
+
): string {
|
|
112
|
+
const sections: string[] = [];
|
|
113
|
+
if (runs.length === 0) {
|
|
114
|
+
sections.push(
|
|
115
|
+
["# Automated rubric evaluation", "", "No automated rubric criteria in this case."].join("\n"),
|
|
116
|
+
);
|
|
117
|
+
} else {
|
|
118
|
+
const header = `# Automated rubric evaluation — ${runs.length} criteri${runs.length === 1 ? "on" : "a"}`;
|
|
119
|
+
sections.push(header, ...runs.map(renderRun));
|
|
120
|
+
}
|
|
121
|
+
if (aiCriteria.length > 0 || hybridRuns.length > 0) {
|
|
122
|
+
sections.push(renderAiAndHybrid(aiCriteria, hybridRuns));
|
|
123
|
+
}
|
|
124
|
+
if (skipped.length > 0) {
|
|
125
|
+
sections.push(renderSkipped(skipped));
|
|
126
|
+
}
|
|
127
|
+
return sections.join("\n\n");
|
|
128
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { loadCaseDir } from "../../shared/case-validation/case-loader.js";
|
|
2
|
+
import { rubricSchema } from "../../shared/case-validation/case-schema.js";
|
|
3
|
+
/** Keep only the `automated` criteria, flattened to {@link AutomatedCriterion}; preserves rubric order. */
|
|
4
|
+
export function selectAutomatedCriteria(rubric) {
|
|
5
|
+
const automated = [];
|
|
6
|
+
for (const criterion of rubric.criteria) {
|
|
7
|
+
if (criterion.evaluation_method.type !== "automated")
|
|
8
|
+
continue;
|
|
9
|
+
automated.push({
|
|
10
|
+
id: criterion.id,
|
|
11
|
+
title: criterion.title,
|
|
12
|
+
knowledgeComponent: criterion.knowledge_component,
|
|
13
|
+
bloomLevel: criterion.bloom_level,
|
|
14
|
+
command: criterion.evaluation_method.command,
|
|
15
|
+
passingCondition: criterion.evaluation_method.passing_condition,
|
|
16
|
+
levels: criterion.levels.map((l) => ({ score: l.score, label: l.label, description: l.description })),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return automated;
|
|
20
|
+
}
|
|
21
|
+
/** Keep only the `ai` criteria, flattened to {@link AICriterion}; preserves rubric order. */
|
|
22
|
+
export function selectAICriteria(rubric) {
|
|
23
|
+
const ai = [];
|
|
24
|
+
for (const criterion of rubric.criteria) {
|
|
25
|
+
if (criterion.evaluation_method.type !== "ai")
|
|
26
|
+
continue;
|
|
27
|
+
ai.push({
|
|
28
|
+
id: criterion.id,
|
|
29
|
+
title: criterion.title,
|
|
30
|
+
knowledgeComponent: criterion.knowledge_component,
|
|
31
|
+
bloomLevel: criterion.bloom_level,
|
|
32
|
+
promptHint: criterion.evaluation_method.prompt_hint,
|
|
33
|
+
levels: criterion.levels.map((l) => ({ score: l.score, label: l.label, description: l.description })),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return ai;
|
|
37
|
+
}
|
|
38
|
+
/** Keep only the `hybrid` criteria, flattened to {@link HybridCriterion}; preserves rubric order. */
|
|
39
|
+
export function selectHybridCriteria(rubric) {
|
|
40
|
+
const hybrid = [];
|
|
41
|
+
for (const criterion of rubric.criteria) {
|
|
42
|
+
const method = criterion.evaluation_method;
|
|
43
|
+
if (method.type !== "hybrid")
|
|
44
|
+
continue;
|
|
45
|
+
hybrid.push({
|
|
46
|
+
id: criterion.id,
|
|
47
|
+
title: criterion.title,
|
|
48
|
+
knowledgeComponent: criterion.knowledge_component,
|
|
49
|
+
bloomLevel: criterion.bloom_level,
|
|
50
|
+
gateCommand: method.automated.command,
|
|
51
|
+
passingCondition: method.automated.passing_condition,
|
|
52
|
+
onPass: method.on_pass,
|
|
53
|
+
onFail: method.on_fail,
|
|
54
|
+
fallbackPromptHint: method.fallback_prompt_hint,
|
|
55
|
+
levels: criterion.levels.map((l) => ({ score: l.score, label: l.label, description: l.description })),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return hybrid;
|
|
59
|
+
}
|
|
60
|
+
/** The `human`-only criteria, so the preview can tell the learner which criteria need manual review. */
|
|
61
|
+
export function selectSkippedCriteria(rubric) {
|
|
62
|
+
const skipped = [];
|
|
63
|
+
for (const criterion of rubric.criteria) {
|
|
64
|
+
if (criterion.evaluation_method.type !== "human")
|
|
65
|
+
continue;
|
|
66
|
+
skipped.push({ id: criterion.id, title: criterion.title, evaluationType: "human" });
|
|
67
|
+
}
|
|
68
|
+
return skipped;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Read + validate `<repoRoot>/.case/rubric.yaml` from a local case checkout. Throws an actionable
|
|
72
|
+
* error if the rubric is absent or malformed (the checkout was already structurally re-validated on
|
|
73
|
+
* open — Task 5.2 — so this is a focused, fail-loud read, not the full structural backstop).
|
|
74
|
+
*/
|
|
75
|
+
export function loadRubric(repoRoot) {
|
|
76
|
+
const loaded = loadCaseDir(repoRoot);
|
|
77
|
+
if (loaded.parseErrors.length > 0) {
|
|
78
|
+
const detail = loaded.parseErrors.map((e) => `${e.file}: ${e.message}`).join("; ");
|
|
79
|
+
throw new Error(`Could not parse the case rubric: ${detail}`);
|
|
80
|
+
}
|
|
81
|
+
if (loaded.content.rubric === undefined) {
|
|
82
|
+
throw new Error(`No .case/rubric.yaml found under ${repoRoot}`);
|
|
83
|
+
}
|
|
84
|
+
const parsed = rubricSchema.safeParse(loaded.content.rubric);
|
|
85
|
+
if (!parsed.success) {
|
|
86
|
+
const detail = parsed.error.issues.map((i) => i.message).join("; ");
|
|
87
|
+
throw new Error(`.case/rubric.yaml is malformed: ${detail}`);
|
|
88
|
+
}
|
|
89
|
+
return parsed.data;
|
|
90
|
+
}
|