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,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `node update.js <competence-id> <payload-file> [--name] [--description]` — write the author's
|
|
3
|
+
* confirmed prose onto a competence that already exists (PLAN Task 15b.8), in place. Only the two
|
|
4
|
+
* prose axes can move: a competence's elements are frozen once created, so a different element list is
|
|
5
|
+
* a new competence rather than an edit.
|
|
6
|
+
*
|
|
7
|
+
* The flags are what makes an edit deliberate: each names one axis the author confirmed, so a run
|
|
8
|
+
* never overwrites prose the author did not look at. Both flags go in **one** PATCH, so no run
|
|
9
|
+
* half-lands.
|
|
10
|
+
*
|
|
11
|
+
* With neither flag the run writes nothing — and rather than *assume* it had nothing to do, it reads
|
|
12
|
+
* the competence and checks. Matching prose is reported as a verified no-op; prose that differs is a
|
|
13
|
+
* refusal naming the axes, because the confirmed payload says the competence should have changed and
|
|
14
|
+
* a silent "nothing to do" would bury that. That path never resolves a session: the read is public and
|
|
15
|
+
* nothing is written.
|
|
16
|
+
*
|
|
17
|
+
* The backend refuses a caller who is neither the competence's owner nor an admin (403) — its message
|
|
18
|
+
* names both ways in, so the author can tell which one they lack — and an unknown id (404). Each
|
|
19
|
+
* refusal is printed exactly as the backend wrote it.
|
|
20
|
+
*
|
|
21
|
+
* `runUpdate` is the testable core (injectable client/home); `main` is the thin CLI wrapper.
|
|
22
|
+
*/
|
|
23
|
+
import * as os from "node:os";
|
|
24
|
+
import * as path from "node:path";
|
|
25
|
+
import { fileURLToPath } from "node:url";
|
|
26
|
+
import { FitoApiError, createFitoApiClient, } from "../../shared/fito-api/client.js";
|
|
27
|
+
import { resolveFitoSession } from "../../shared/fito-session/session.js";
|
|
28
|
+
import { quoted } from "./display.js";
|
|
29
|
+
import { loadCompetenceEditPayload } from "./payload.js";
|
|
30
|
+
/**
|
|
31
|
+
* Write the named axes in one request. Every named value is checked for substance **before** the
|
|
32
|
+
* request, so a run that cannot write an axis writes neither. Backend refusals (403, 404) propagate as
|
|
33
|
+
* `FitoApiError` for the caller to surface verbatim.
|
|
34
|
+
*/
|
|
35
|
+
export async function runUpdate(options) {
|
|
36
|
+
const home = options.home ?? os.homedir();
|
|
37
|
+
const client = options.client ?? createFitoApiClient();
|
|
38
|
+
const payload = loadCompetenceEditPayload(options.payloadPath);
|
|
39
|
+
if (!options.name && !options.description) {
|
|
40
|
+
return { competence: await confirmNothingToWrite(client, options.competenceId, payload), written: [] };
|
|
41
|
+
}
|
|
42
|
+
const input = {};
|
|
43
|
+
const written = [];
|
|
44
|
+
if (options.name) {
|
|
45
|
+
input.name = payload.name;
|
|
46
|
+
written.push("name");
|
|
47
|
+
}
|
|
48
|
+
if (options.description) {
|
|
49
|
+
input.description = requireProse(payload);
|
|
50
|
+
written.push("description");
|
|
51
|
+
}
|
|
52
|
+
const { tokens } = await resolveFitoSession(client, home);
|
|
53
|
+
const competence = await client.updateCompetence(tokens.accessToken, options.competenceId, input);
|
|
54
|
+
return { competence, written };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A run that named no axis, answered by reading rather than by assuming. Matching prose is the honest
|
|
58
|
+
* "there is nothing to do here", and the competence read back is the evidence for it.
|
|
59
|
+
*
|
|
60
|
+
* Prose that differs is a refusal instead, because the author confirmed a payload that says this
|
|
61
|
+
* competence should read differently: reporting "nothing to write" there would tell them their edit
|
|
62
|
+
* had landed when it never left. The message names which axes differ, so the re-run is obvious.
|
|
63
|
+
*
|
|
64
|
+
* No session is resolved: `GET /competences/{id}` is public and this path writes nothing, so a
|
|
65
|
+
* signed-out author still gets a true answer.
|
|
66
|
+
*/
|
|
67
|
+
async function confirmNothingToWrite(client, competenceId, payload) {
|
|
68
|
+
const stored = await client.getCompetence(competenceId);
|
|
69
|
+
const differing = [];
|
|
70
|
+
if (stored.name !== payload.name)
|
|
71
|
+
differing.push("name");
|
|
72
|
+
if (stored.description !== payload.description)
|
|
73
|
+
differing.push("description");
|
|
74
|
+
if (differing.length === 0)
|
|
75
|
+
return stored;
|
|
76
|
+
throw new Error(`The confirmed payload differs from the stored competence on: ${differing.join(", ")}. ` +
|
|
77
|
+
"Name the axis to write: --name, --description, or both. An edit writes what the author " +
|
|
78
|
+
"confirmed, not everything the payload happens to carry.");
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The description to write, or an actionable refusal. `null` is the author's confirmed "this
|
|
82
|
+
* competence has no description", and it cannot be sent: the backend reads a null description the way
|
|
83
|
+
* it reads a missing key — leave the stored one alone — so the request would succeed having written
|
|
84
|
+
* nothing, and the run would say `✓ Updated the description`. Blank is the same gap spelled with
|
|
85
|
+
* whitespace, and the endpoint rejects it as a 400. The fix is the author supplementing the draft, not
|
|
86
|
+
* a request.
|
|
87
|
+
*/
|
|
88
|
+
function requireProse(payload) {
|
|
89
|
+
const { description } = payload;
|
|
90
|
+
if (description === null) {
|
|
91
|
+
throw new Error("The payload's description is `null` — the author confirmed no description, and an edit cannot " +
|
|
92
|
+
"clear one: the backend reads a null description as \"leave the stored one alone\", so this run " +
|
|
93
|
+
"would report writing a description it never wrote. Drop --description, or supplement the draft " +
|
|
94
|
+
"with the author's own prose, then re-run.");
|
|
95
|
+
}
|
|
96
|
+
if (description.trim() === "") {
|
|
97
|
+
throw new Error("The payload's description is blank — there is no way to write an empty description. Drop " +
|
|
98
|
+
"--description, or supplement the draft with the author's own prose, then re-run.");
|
|
99
|
+
}
|
|
100
|
+
return description;
|
|
101
|
+
}
|
|
102
|
+
/** The success line: which axes were written, on which competence — or the verified no-op. */
|
|
103
|
+
export function describeUpdated(result, payloadPath) {
|
|
104
|
+
const competence = `competence ${quoted(result.competence.name)} (${result.competence.id})`;
|
|
105
|
+
if (result.written.length === 0) {
|
|
106
|
+
return `✓ Nothing to write — ${competence} already carries what was confirmed ← ${payloadPath}`;
|
|
107
|
+
}
|
|
108
|
+
const axes = result.written.map((axis) => `the ${axis}`).join(" and ");
|
|
109
|
+
return `✓ Updated ${axes} of ${competence} ← ${payloadPath}`;
|
|
110
|
+
}
|
|
111
|
+
const USAGE = "Usage: node update.js <competence-id> <payload-file> [--name] [--description]";
|
|
112
|
+
function parseArgs(argv) {
|
|
113
|
+
const [competenceId, payloadPath, ...rest] = argv;
|
|
114
|
+
if (!competenceId || !payloadPath)
|
|
115
|
+
return undefined;
|
|
116
|
+
const options = { competenceId, payloadPath };
|
|
117
|
+
for (const flag of rest) {
|
|
118
|
+
if (flag === "--name") {
|
|
119
|
+
options.name = true;
|
|
120
|
+
}
|
|
121
|
+
else if (flag === "--description") {
|
|
122
|
+
options.description = true;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return options;
|
|
129
|
+
}
|
|
130
|
+
async function main() {
|
|
131
|
+
const options = parseArgs(process.argv.slice(2));
|
|
132
|
+
if (!options) {
|
|
133
|
+
console.error(USAGE);
|
|
134
|
+
process.exitCode = 1;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
console.log(describeUpdated(await runUpdate(options), options.payloadPath));
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
if (error instanceof FitoApiError) {
|
|
142
|
+
console.error(`✗ Update failed (${error.status}): ${error.message}`);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
|
|
146
|
+
}
|
|
147
|
+
process.exitCode = 1;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/** Only auto-invoke the CLI when run directly (`node update.js …`), not when imported. */
|
|
151
|
+
const entry = process.argv[1];
|
|
152
|
+
const isMainModule = !!entry && path.resolve(entry) === fileURLToPath(import.meta.url);
|
|
153
|
+
if (isMainModule) {
|
|
154
|
+
void main();
|
|
155
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `node update.js <competence-id> <payload-file> [--name] [--description]` — write the author's
|
|
3
|
+
* confirmed prose onto a competence that already exists (PLAN Task 15b.8), in place. Only the two
|
|
4
|
+
* prose axes can move: a competence's elements are frozen once created, so a different element list is
|
|
5
|
+
* a new competence rather than an edit.
|
|
6
|
+
*
|
|
7
|
+
* The flags are what makes an edit deliberate: each names one axis the author confirmed, so a run
|
|
8
|
+
* never overwrites prose the author did not look at. Both flags go in **one** PATCH, so no run
|
|
9
|
+
* half-lands.
|
|
10
|
+
*
|
|
11
|
+
* With neither flag the run writes nothing — and rather than *assume* it had nothing to do, it reads
|
|
12
|
+
* the competence and checks. Matching prose is reported as a verified no-op; prose that differs is a
|
|
13
|
+
* refusal naming the axes, because the confirmed payload says the competence should have changed and
|
|
14
|
+
* a silent "nothing to do" would bury that. That path never resolves a session: the read is public and
|
|
15
|
+
* nothing is written.
|
|
16
|
+
*
|
|
17
|
+
* The backend refuses a caller who is neither the competence's owner nor an admin (403) — its message
|
|
18
|
+
* names both ways in, so the author can tell which one they lack — and an unknown id (404). Each
|
|
19
|
+
* refusal is printed exactly as the backend wrote it.
|
|
20
|
+
*
|
|
21
|
+
* `runUpdate` is the testable core (injectable client/home); `main` is the thin CLI wrapper.
|
|
22
|
+
*/
|
|
23
|
+
import * as os from "node:os";
|
|
24
|
+
import * as path from "node:path";
|
|
25
|
+
import { fileURLToPath } from "node:url";
|
|
26
|
+
|
|
27
|
+
import {
|
|
28
|
+
FitoApiError,
|
|
29
|
+
createFitoApiClient,
|
|
30
|
+
type Competence,
|
|
31
|
+
type FitoApiClient,
|
|
32
|
+
type UpdateCompetenceInput,
|
|
33
|
+
} from "../../shared/fito-api/client.ts";
|
|
34
|
+
import { resolveFitoSession } from "../../shared/fito-session/session.ts";
|
|
35
|
+
import { quoted } from "./display.ts";
|
|
36
|
+
import { loadCompetenceEditPayload, type CompetenceEditPayload } from "./payload.ts";
|
|
37
|
+
|
|
38
|
+
/** The fito-api surface this flow needs: the session lookup, the no-axis read, and the one write. */
|
|
39
|
+
type UpdateClient = Pick<FitoApiClient, "meWithRefresh" | "getCompetence" | "updateCompetence">;
|
|
40
|
+
|
|
41
|
+
/** The two axes `PATCH /competences/{id}` writes. */
|
|
42
|
+
export type CompetenceAxis = "name" | "description";
|
|
43
|
+
|
|
44
|
+
export interface RunUpdateOptions {
|
|
45
|
+
/** The competence to edit, by the id the create printed. */
|
|
46
|
+
competenceId: string;
|
|
47
|
+
/** Path to the confirmed edit payload (`edit.yaml`). */
|
|
48
|
+
payloadPath: string;
|
|
49
|
+
/** Write the payload's `name`. */
|
|
50
|
+
name?: boolean;
|
|
51
|
+
/** Write the payload's `description`. */
|
|
52
|
+
description?: boolean;
|
|
53
|
+
home?: string;
|
|
54
|
+
client?: UpdateClient;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* What a run found: the competence as stored afterwards, and the axes it wrote. An empty [written] is
|
|
59
|
+
* the verified no-op — nothing was sent, and the competence is what the read returned.
|
|
60
|
+
*/
|
|
61
|
+
export interface UpdateResult {
|
|
62
|
+
competence: Competence;
|
|
63
|
+
written: CompetenceAxis[];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Write the named axes in one request. Every named value is checked for substance **before** the
|
|
68
|
+
* request, so a run that cannot write an axis writes neither. Backend refusals (403, 404) propagate as
|
|
69
|
+
* `FitoApiError` for the caller to surface verbatim.
|
|
70
|
+
*/
|
|
71
|
+
export async function runUpdate(options: RunUpdateOptions): Promise<UpdateResult> {
|
|
72
|
+
const home = options.home ?? os.homedir();
|
|
73
|
+
const client = options.client ?? createFitoApiClient();
|
|
74
|
+
|
|
75
|
+
const payload = loadCompetenceEditPayload(options.payloadPath);
|
|
76
|
+
|
|
77
|
+
if (!options.name && !options.description) {
|
|
78
|
+
return { competence: await confirmNothingToWrite(client, options.competenceId, payload), written: [] };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const input: UpdateCompetenceInput = {};
|
|
82
|
+
const written: CompetenceAxis[] = [];
|
|
83
|
+
if (options.name) {
|
|
84
|
+
input.name = payload.name;
|
|
85
|
+
written.push("name");
|
|
86
|
+
}
|
|
87
|
+
if (options.description) {
|
|
88
|
+
input.description = requireProse(payload);
|
|
89
|
+
written.push("description");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const { tokens } = await resolveFitoSession(client, home);
|
|
93
|
+
const competence = await client.updateCompetence(tokens.accessToken, options.competenceId, input);
|
|
94
|
+
|
|
95
|
+
return { competence, written };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A run that named no axis, answered by reading rather than by assuming. Matching prose is the honest
|
|
100
|
+
* "there is nothing to do here", and the competence read back is the evidence for it.
|
|
101
|
+
*
|
|
102
|
+
* Prose that differs is a refusal instead, because the author confirmed a payload that says this
|
|
103
|
+
* competence should read differently: reporting "nothing to write" there would tell them their edit
|
|
104
|
+
* had landed when it never left. The message names which axes differ, so the re-run is obvious.
|
|
105
|
+
*
|
|
106
|
+
* No session is resolved: `GET /competences/{id}` is public and this path writes nothing, so a
|
|
107
|
+
* signed-out author still gets a true answer.
|
|
108
|
+
*/
|
|
109
|
+
async function confirmNothingToWrite(
|
|
110
|
+
client: Pick<FitoApiClient, "getCompetence">,
|
|
111
|
+
competenceId: string,
|
|
112
|
+
payload: CompetenceEditPayload,
|
|
113
|
+
): Promise<Competence> {
|
|
114
|
+
const stored = await client.getCompetence(competenceId);
|
|
115
|
+
const differing: CompetenceAxis[] = [];
|
|
116
|
+
if (stored.name !== payload.name) differing.push("name");
|
|
117
|
+
if (stored.description !== payload.description) differing.push("description");
|
|
118
|
+
if (differing.length === 0) return stored;
|
|
119
|
+
|
|
120
|
+
throw new Error(
|
|
121
|
+
`The confirmed payload differs from the stored competence on: ${differing.join(", ")}. ` +
|
|
122
|
+
"Name the axis to write: --name, --description, or both. An edit writes what the author " +
|
|
123
|
+
"confirmed, not everything the payload happens to carry.",
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The description to write, or an actionable refusal. `null` is the author's confirmed "this
|
|
129
|
+
* competence has no description", and it cannot be sent: the backend reads a null description the way
|
|
130
|
+
* it reads a missing key — leave the stored one alone — so the request would succeed having written
|
|
131
|
+
* nothing, and the run would say `✓ Updated the description`. Blank is the same gap spelled with
|
|
132
|
+
* whitespace, and the endpoint rejects it as a 400. The fix is the author supplementing the draft, not
|
|
133
|
+
* a request.
|
|
134
|
+
*/
|
|
135
|
+
function requireProse(payload: CompetenceEditPayload): string {
|
|
136
|
+
const { description } = payload;
|
|
137
|
+
if (description === null) {
|
|
138
|
+
throw new Error(
|
|
139
|
+
"The payload's description is `null` — the author confirmed no description, and an edit cannot " +
|
|
140
|
+
"clear one: the backend reads a null description as \"leave the stored one alone\", so this run " +
|
|
141
|
+
"would report writing a description it never wrote. Drop --description, or supplement the draft " +
|
|
142
|
+
"with the author's own prose, then re-run.",
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
if (description.trim() === "") {
|
|
146
|
+
throw new Error(
|
|
147
|
+
"The payload's description is blank — there is no way to write an empty description. Drop " +
|
|
148
|
+
"--description, or supplement the draft with the author's own prose, then re-run.",
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
return description;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** The success line: which axes were written, on which competence — or the verified no-op. */
|
|
155
|
+
export function describeUpdated(result: UpdateResult, payloadPath: string): string {
|
|
156
|
+
const competence = `competence ${quoted(result.competence.name)} (${result.competence.id})`;
|
|
157
|
+
if (result.written.length === 0) {
|
|
158
|
+
return `✓ Nothing to write — ${competence} already carries what was confirmed ← ${payloadPath}`;
|
|
159
|
+
}
|
|
160
|
+
const axes = result.written.map((axis) => `the ${axis}`).join(" and ");
|
|
161
|
+
return `✓ Updated ${axes} of ${competence} ← ${payloadPath}`;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const USAGE = "Usage: node update.js <competence-id> <payload-file> [--name] [--description]";
|
|
165
|
+
|
|
166
|
+
function parseArgs(argv: string[]): RunUpdateOptions | undefined {
|
|
167
|
+
const [competenceId, payloadPath, ...rest] = argv;
|
|
168
|
+
if (!competenceId || !payloadPath) return undefined;
|
|
169
|
+
const options: RunUpdateOptions = { competenceId, payloadPath };
|
|
170
|
+
for (const flag of rest) {
|
|
171
|
+
if (flag === "--name") {
|
|
172
|
+
options.name = true;
|
|
173
|
+
} else if (flag === "--description") {
|
|
174
|
+
options.description = true;
|
|
175
|
+
} else {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return options;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async function main(): Promise<void> {
|
|
183
|
+
const options = parseArgs(process.argv.slice(2));
|
|
184
|
+
if (!options) {
|
|
185
|
+
console.error(USAGE);
|
|
186
|
+
process.exitCode = 1;
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
console.log(describeUpdated(await runUpdate(options), options.payloadPath));
|
|
191
|
+
} catch (error) {
|
|
192
|
+
if (error instanceof FitoApiError) {
|
|
193
|
+
console.error(`✗ Update failed (${error.status}): ${error.message}`);
|
|
194
|
+
} else {
|
|
195
|
+
console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
|
|
196
|
+
}
|
|
197
|
+
process.exitCode = 1;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Only auto-invoke the CLI when run directly (`node update.js …`), not when imported. */
|
|
202
|
+
const entry = process.argv[1];
|
|
203
|
+
const isMainModule = !!entry && path.resolve(entry) === fileURLToPath(import.meta.url);
|
|
204
|
+
if (isMainModule) {
|
|
205
|
+
void main();
|
|
206
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fito-evaluator
|
|
3
|
+
description: >
|
|
4
|
+
Run a Fito case's rubric against the learner's local checkout and build the
|
|
5
|
+
evaluation report the reviewer scores: automated criteria's command evidence,
|
|
6
|
+
hybrid criteria's gate evidence, and the ai criteria + their prompt hints. Use
|
|
7
|
+
when /fito-evaluate previews results before submitting, or when the /fito-submit
|
|
8
|
+
round-trip evaluates a submission.
|
|
9
|
+
allowed-tools: bash
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Fito Evaluator — rubric evaluation report
|
|
13
|
+
|
|
14
|
+
Run the script from wherever you are — the command below names this
|
|
15
|
+
skill's directory itself. `<case-id>` is the case's backend UUID; it reads the per-case
|
|
16
|
+
checkout at `~/.fito/cases/<case-id>/` — the same location `/fito-case-open`
|
|
17
|
+
writes — so it always agrees with where the learner is working.
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
- The case must be **open** — run `/fito-case-open <case-id>` first. The script
|
|
22
|
+
fails with an actionable message (pointing at `/fito-case-open`) if the checkout
|
|
23
|
+
is absent.
|
|
24
|
+
- The learner's work should be **committed/saved in the checkout**, since the
|
|
25
|
+
rubric commands run against the working tree as it stands.
|
|
26
|
+
|
|
27
|
+
## Run the evaluation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
node <fito-evaluator skill dir>/evaluate-automated.js <case-id>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Loads the checkout's `rubric.yaml` and prints one **evaluation report** the reviewer
|
|
34
|
+
scores, with up to three parts:
|
|
35
|
+
|
|
36
|
+
- **Automated criteria** — runs each `evaluation_method.type: automated` `command`
|
|
37
|
+
via `sh -c` in the checkout (a non-zero exit is **evidence**, not a failure):
|
|
38
|
+
command, exit code, `passing_condition`, the 0–3 levels, and captured stdout/stderr.
|
|
39
|
+
- **AI criteria** — each `ai` criterion's knowledge component, Bloom level,
|
|
40
|
+
`prompt_hint`, and the 0–3 levels. (No command; the reviewer judges the learner's
|
|
41
|
+
work.)
|
|
42
|
+
- **Hybrid criteria** — runs each `hybrid` criterion's automated **gate** command
|
|
43
|
+
(same evidence capture), and carries `passing_condition`, `on_pass`, `on_fail`,
|
|
44
|
+
and any `fallback_prompt_hint` so the reviewer can branch.
|
|
45
|
+
|
|
46
|
+
Any `human` criteria are listed under **Needs human review**.
|
|
47
|
+
|
|
48
|
+
Each command has a **15-minute time budget** (automated commands and hybrid gates
|
|
49
|
+
alike); one still running after that is terminated and reported as a timeout (exit
|
|
50
|
+
`124`) — evidence, not an abort — so a hung build can't stall the rest.
|
|
51
|
+
|
|
52
|
+
This runs the case author's commands on the learner's machine and checkout — the
|
|
53
|
+
same trust boundary as the learner working in the repo (Architecture Decision #4).
|
|
54
|
+
It writes nothing to the backend and never reads `.case/solution/`.
|
|
55
|
+
|
|
56
|
+
**Done when** it prints the report. Hand that report **and the checkout path**
|
|
57
|
+
(`~/.fito/cases/<case-id>/`) to the `fito-performance-reviewer` **subagent** (via the
|
|
58
|
+
`subagent` tool) to assign the 0–3 scores: it judges the automated/gate evidence from
|
|
59
|
+
the report and reads the learner's artifacts + git diff from the checkout for the
|
|
60
|
+
`ai`/`hybrid` criteria. If the report has no scorable criteria, there is nothing to
|
|
61
|
+
score.
|
|
62
|
+
|
|
63
|
+
## Files
|
|
64
|
+
|
|
65
|
+
| File | Role |
|
|
66
|
+
|---|---|
|
|
67
|
+
| `evaluate-automated.ts` | CLI entrypoint — `runEvaluate` testable core + `main` |
|
|
68
|
+
| `rubric.ts` | Load `.case/rubric.yaml` + select criteria by type (automated / ai / hybrid; human is skipped) |
|
|
69
|
+
| `evaluate.ts` | Run automated commands **and** hybrid gate commands over an injectable executor |
|
|
70
|
+
| `criterion-exec.ts` | The real `sh -c` executor (captures stdout/stderr/exit; 15-min timeout) |
|
|
71
|
+
| `report.ts` | Render the automated evidence, ai criteria, and hybrid gate evidence into the report |
|
|
72
|
+
|
|
73
|
+
See [the `.case/` validator](../../shared/case-validation/) for the rubric schema.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
/**
|
|
4
|
+
* The real executor for automated rubric criteria (Task 6.1): runs each criterion's free-form
|
|
5
|
+
* `command` through `sh -c` in the learner's checkout and captures stdout/stderr/exit. A non-zero exit
|
|
6
|
+
* — or a **timeout** — is **evidence the reviewer judges** (e.g. a failing test suite, or a hung
|
|
7
|
+
* build), so it is returned, not thrown; only a genuine failure to run the command (missing `sh`,
|
|
8
|
+
* output overflow) throws. The pure sequencing in `evaluate.ts` is unit-tested against a fake; this
|
|
9
|
+
* thin spawn glue is covered by a handful of real-`sh` tests.
|
|
10
|
+
*
|
|
11
|
+
* Per Architecture Decision #4, the command is the case author's and runs on the learner's own
|
|
12
|
+
* machine and checkout — the same trust boundary as the learner working in the repo. The timeout
|
|
13
|
+
* bounds a runaway/hung command so one criterion can't stall the whole evaluation.
|
|
14
|
+
*/
|
|
15
|
+
const execFileAsync = promisify(execFile);
|
|
16
|
+
const MAX_BUFFER = 16 * 1024 * 1024;
|
|
17
|
+
/**
|
|
18
|
+
* Default per-command time budget; a command still running after this is terminated and scored as
|
|
19
|
+
* evidence.
|
|
20
|
+
*
|
|
21
|
+
* **Deliberately generous, because a timeout is scored as a failure** (see the `e.killed` branch
|
|
22
|
+
* below) and that score reaches the learner's competence profile through `/fito-submit`. A command
|
|
23
|
+
* that is merely *slow* is indistinguishable here from one that is *hung*, so the budget has to
|
|
24
|
+
* clear the slow case by a wide margin: a first `./gradlew test` on a cold cache downloads
|
|
25
|
+
* dependencies and compiles from scratch before a single test runs. Raised from 5 minutes at the
|
|
26
|
+
* Phase 11 checkpoint, where exactly that happened — Gradle was killed mid-`compileKotlin` at 300 s
|
|
27
|
+
* and the criterion scored 0 for a machine-speed reason the learner could neither see nor act on.
|
|
28
|
+
*
|
|
29
|
+
* The cost of a long budget is bounded: the evaluator streams output, so a learner watching a
|
|
30
|
+
* genuinely hung command can see it is stuck and stop it.
|
|
31
|
+
*/
|
|
32
|
+
const DEFAULT_TIMEOUT_MS = 15 * 60 * 1000;
|
|
33
|
+
/** Conventional shell exit code for a command terminated by a timeout. */
|
|
34
|
+
const TIMEOUT_EXIT_CODE = 124;
|
|
35
|
+
export const shellExec = async (command, options) => {
|
|
36
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
37
|
+
try {
|
|
38
|
+
const { stdout, stderr } = await execFileAsync("sh", ["-c", command], {
|
|
39
|
+
cwd: options.cwd,
|
|
40
|
+
encoding: "utf8",
|
|
41
|
+
maxBuffer: MAX_BUFFER,
|
|
42
|
+
timeout: timeoutMs,
|
|
43
|
+
});
|
|
44
|
+
return { stdout: String(stdout), stderr: String(stderr), exitCode: 0 };
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
const e = error;
|
|
48
|
+
if (typeof e.code === "number") {
|
|
49
|
+
// The command ran and exited non-zero — capture its output as evidence, don't throw.
|
|
50
|
+
return { stdout: String(e.stdout ?? ""), stderr: String(e.stderr ?? ""), exitCode: e.code };
|
|
51
|
+
}
|
|
52
|
+
if (e.code === "ERR_CHILD_PROCESS_STDIO_MAXBUFFER") {
|
|
53
|
+
throw new Error(`\`${command}\` produced more than ${MAX_BUFFER} bytes of output`);
|
|
54
|
+
}
|
|
55
|
+
if (e.killed) {
|
|
56
|
+
// Terminated by the timeout — report it as evidence so it scores like a failure, not an abort.
|
|
57
|
+
const note = `[fito] command timed out after ${timeoutMs}ms and was terminated`;
|
|
58
|
+
const stderr = e.stderr ? `${String(e.stderr)}\n${note}` : note;
|
|
59
|
+
return { stdout: String(e.stdout ?? ""), stderr, exitCode: TIMEOUT_EXIT_CODE };
|
|
60
|
+
}
|
|
61
|
+
// Could not run the command at all (e.g. missing sh).
|
|
62
|
+
throw new Error(`Failed to run \`${command}\`: ${e.message ?? "unknown error"}`);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
|
|
4
|
+
import type { AutomatedExecutor, CommandResult } from "./evaluate.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The real executor for automated rubric criteria (Task 6.1): runs each criterion's free-form
|
|
8
|
+
* `command` through `sh -c` in the learner's checkout and captures stdout/stderr/exit. A non-zero exit
|
|
9
|
+
* — or a **timeout** — is **evidence the reviewer judges** (e.g. a failing test suite, or a hung
|
|
10
|
+
* build), so it is returned, not thrown; only a genuine failure to run the command (missing `sh`,
|
|
11
|
+
* output overflow) throws. The pure sequencing in `evaluate.ts` is unit-tested against a fake; this
|
|
12
|
+
* thin spawn glue is covered by a handful of real-`sh` tests.
|
|
13
|
+
*
|
|
14
|
+
* Per Architecture Decision #4, the command is the case author's and runs on the learner's own
|
|
15
|
+
* machine and checkout — the same trust boundary as the learner working in the repo. The timeout
|
|
16
|
+
* bounds a runaway/hung command so one criterion can't stall the whole evaluation.
|
|
17
|
+
*/
|
|
18
|
+
const execFileAsync = promisify(execFile);
|
|
19
|
+
const MAX_BUFFER = 16 * 1024 * 1024;
|
|
20
|
+
/**
|
|
21
|
+
* Default per-command time budget; a command still running after this is terminated and scored as
|
|
22
|
+
* evidence.
|
|
23
|
+
*
|
|
24
|
+
* **Deliberately generous, because a timeout is scored as a failure** (see the `e.killed` branch
|
|
25
|
+
* below) and that score reaches the learner's competence profile through `/fito-submit`. A command
|
|
26
|
+
* that is merely *slow* is indistinguishable here from one that is *hung*, so the budget has to
|
|
27
|
+
* clear the slow case by a wide margin: a first `./gradlew test` on a cold cache downloads
|
|
28
|
+
* dependencies and compiles from scratch before a single test runs. Raised from 5 minutes at the
|
|
29
|
+
* Phase 11 checkpoint, where exactly that happened — Gradle was killed mid-`compileKotlin` at 300 s
|
|
30
|
+
* and the criterion scored 0 for a machine-speed reason the learner could neither see nor act on.
|
|
31
|
+
*
|
|
32
|
+
* The cost of a long budget is bounded: the evaluator streams output, so a learner watching a
|
|
33
|
+
* genuinely hung command can see it is stuck and stop it.
|
|
34
|
+
*/
|
|
35
|
+
const DEFAULT_TIMEOUT_MS = 15 * 60 * 1000;
|
|
36
|
+
/** Conventional shell exit code for a command terminated by a timeout. */
|
|
37
|
+
const TIMEOUT_EXIT_CODE = 124;
|
|
38
|
+
|
|
39
|
+
export const shellExec: AutomatedExecutor = async (command, options): Promise<CommandResult> => {
|
|
40
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
41
|
+
try {
|
|
42
|
+
const { stdout, stderr } = await execFileAsync("sh", ["-c", command], {
|
|
43
|
+
cwd: options.cwd,
|
|
44
|
+
encoding: "utf8",
|
|
45
|
+
maxBuffer: MAX_BUFFER,
|
|
46
|
+
timeout: timeoutMs,
|
|
47
|
+
});
|
|
48
|
+
return { stdout: String(stdout), stderr: String(stderr), exitCode: 0 };
|
|
49
|
+
} catch (error) {
|
|
50
|
+
const e = error as {
|
|
51
|
+
code?: number | string;
|
|
52
|
+
killed?: boolean;
|
|
53
|
+
stdout?: string;
|
|
54
|
+
stderr?: string;
|
|
55
|
+
message?: string;
|
|
56
|
+
};
|
|
57
|
+
if (typeof e.code === "number") {
|
|
58
|
+
// The command ran and exited non-zero — capture its output as evidence, don't throw.
|
|
59
|
+
return { stdout: String(e.stdout ?? ""), stderr: String(e.stderr ?? ""), exitCode: e.code };
|
|
60
|
+
}
|
|
61
|
+
if (e.code === "ERR_CHILD_PROCESS_STDIO_MAXBUFFER") {
|
|
62
|
+
throw new Error(`\`${command}\` produced more than ${MAX_BUFFER} bytes of output`);
|
|
63
|
+
}
|
|
64
|
+
if (e.killed) {
|
|
65
|
+
// Terminated by the timeout — report it as evidence so it scores like a failure, not an abort.
|
|
66
|
+
const note = `[fito] command timed out after ${timeoutMs}ms and was terminated`;
|
|
67
|
+
const stderr = e.stderr ? `${String(e.stderr)}\n${note}` : note;
|
|
68
|
+
return { stdout: String(e.stdout ?? ""), stderr, exitCode: TIMEOUT_EXIT_CODE };
|
|
69
|
+
}
|
|
70
|
+
// Could not run the command at all (e.g. missing sh).
|
|
71
|
+
throw new Error(`Failed to run \`${command}\`: ${e.message ?? "unknown error"}`);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
import { caseWorkDir } from "../fito-case-runner/workdir.js";
|
|
17
|
+
import { evaluateAutomatedCriteria, evaluateHybridGates } from "./evaluate.js";
|
|
18
|
+
import { shellExec } from "./criterion-exec.js";
|
|
19
|
+
import { renderReport } from "./report.js";
|
|
20
|
+
import { loadRubric, selectAICriteria, selectAutomatedCriteria, selectHybridCriteria, selectSkippedCriteria, } from "./rubric.js";
|
|
21
|
+
/** Resolve the checkout → load the rubric → run the automated criteria → return the rendered report. */
|
|
22
|
+
export async function runEvaluate(options) {
|
|
23
|
+
const home = options.home ?? os.homedir();
|
|
24
|
+
const dir = caseWorkDir(options.caseId, home);
|
|
25
|
+
if (!existsSync(dir)) {
|
|
26
|
+
throw new Error(`No open case at:\n ${dir}\n` +
|
|
27
|
+
`Open it first with: /fito-case-open ${options.caseId}`);
|
|
28
|
+
}
|
|
29
|
+
const load = options.load ?? loadRubric;
|
|
30
|
+
const rubric = load(dir);
|
|
31
|
+
const exec = options.exec ?? shellExec;
|
|
32
|
+
const runs = await evaluateAutomatedCriteria(selectAutomatedCriteria(rubric), exec, dir, options.onProgress);
|
|
33
|
+
// Hybrid gates run deterministically here (inheriting the 5-min timeout); the pass/fail judgment
|
|
34
|
+
// against `passingCondition` and the AI fallback are the reviewer subagent's job (Task 6.2).
|
|
35
|
+
const hybridRuns = await evaluateHybridGates(selectHybridCriteria(rubric), exec, dir, options.onProgress);
|
|
36
|
+
return renderReport(runs, selectSkippedCriteria(rubric), selectAICriteria(rubric), hybridRuns);
|
|
37
|
+
}
|
|
38
|
+
async function main() {
|
|
39
|
+
const caseId = process.argv[2];
|
|
40
|
+
if (!caseId) {
|
|
41
|
+
console.error("Usage: node evaluate-automated.js <case-id>");
|
|
42
|
+
process.exitCode = 1;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
// Progress → stderr so it never mixes into the report on stdout (which the reviewer scores).
|
|
46
|
+
const report = await runEvaluate({ caseId, onProgress: (message) => console.error(message) });
|
|
47
|
+
console.log(report);
|
|
48
|
+
}
|
|
49
|
+
/** Only auto-invoke the CLI when run directly (`node evaluate-automated.js …`), not when imported. */
|
|
50
|
+
const entry = process.argv[1];
|
|
51
|
+
const isMainModule = !!entry && path.resolve(entry) === fileURLToPath(import.meta.url);
|
|
52
|
+
if (isMainModule) {
|
|
53
|
+
main().catch((error) => {
|
|
54
|
+
console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
|
|
55
|
+
process.exitCode = 1;
|
|
56
|
+
});
|
|
57
|
+
}
|