fito-tui 0.3.0 → 0.5.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/agents/fito-performance-reviewer.md +6 -5
- package/extensions/fito-startup.js +27 -3
- package/extensions/fito-startup.ts +39 -7
- package/package.json +7 -3
- package/prompts/fito-auth-refresh.md +4 -4
- package/prompts/fito-case-edit.md +2 -2
- package/prompts/fito-case-generate.md +1 -1
- package/prompts/fito-case-open.md +6 -5
- package/prompts/fito-create-or-update-competence.md +2 -2
- package/prompts/fito-create-or-update-technology.md +5 -5
- package/prompts/fito-delete-competence.md +2 -2
- package/prompts/fito-evaluate.md +30 -22
- package/prompts/fito-login.md +3 -3
- package/prompts/fito-logout.md +4 -4
- package/prompts/fito-publish-case.md +3 -3
- package/prompts/fito-push-knowledge.md +1 -1
- package/prompts/fito-submit.md +55 -36
- package/shared/fito-session/credentials.js +27 -15
- package/shared/fito-session/credentials.ts +33 -15
- package/shared/fito-session/session.js +7 -5
- package/shared/fito-session/session.ts +10 -7
- package/skills/fito-auth/SKILL.md +14 -13
- package/skills/fito-auth/auth-refresh.js +3 -2
- package/skills/fito-auth/auth-refresh.ts +3 -2
- package/skills/fito-auth/browser.js +3 -2
- package/skills/fito-auth/browser.ts +3 -2
- package/skills/fito-auth/login.js +24 -8
- package/skills/fito-auth/login.ts +25 -8
- package/skills/fito-auth/logout.js +3 -2
- package/skills/fito-auth/logout.ts +3 -2
- package/skills/fito-case-author/SKILL.md +4 -4
- package/skills/fito-case-author/checkout.js +22 -5
- package/skills/fito-case-author/checkout.ts +22 -5
- package/skills/fito-case-author/publish-version.js +1 -1
- package/skills/fito-case-author/publish-version.ts +1 -1
- package/skills/fito-case-author/publish.js +1 -1
- package/skills/fito-case-author/publish.ts +1 -1
- package/skills/fito-case-runner/SKILL.md +24 -7
- package/skills/fito-case-runner/github.js +20 -2
- package/skills/fito-case-runner/github.ts +21 -2
- package/skills/fito-case-runner/open.js +3 -3
- package/skills/fito-case-runner/open.ts +3 -3
- package/skills/fito-case-runner/runner.js +12 -1
- package/skills/fito-case-runner/runner.ts +15 -0
- package/skills/fito-case-runner/submit.js +1 -1
- package/skills/fito-case-runner/submit.ts +1 -1
- package/skills/fito-case-runner/temp-file.js +16 -0
- package/skills/fito-case-runner/temp-file.ts +17 -0
- package/skills/fito-competence-write/SKILL.md +3 -3
- package/skills/fito-competence-write/delete.js +1 -1
- package/skills/fito-competence-write/delete.ts +1 -1
- package/skills/fito-evaluator/SKILL.md +7 -6
- package/skills/fito-evaluator/criterion-exec.js +113 -17
- package/skills/fito-evaluator/criterion-exec.ts +110 -18
- package/skills/fito-evaluator/evaluate-automated.js +7 -3
- package/skills/fito-evaluator/evaluate-automated.ts +7 -3
- package/skills/fito-knowledge-push/SKILL.md +1 -1
- package/skills/fito-knowledge-push/push.js +8 -8
- package/skills/fito-knowledge-push/push.ts +8 -8
- package/skills/fito-source-ingestion/SKILL.md +4 -4
- package/skills/fito-technology-write/SKILL.md +2 -2
- package/skills/fito-technology-write/create.js +2 -2
- package/skills/fito-technology-write/create.ts +2 -2
|
@@ -27,11 +27,12 @@ writes — so it always agrees with where the learner is working.
|
|
|
27
27
|
## Run the evaluation
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
|
-
node <fito-evaluator skill dir>/evaluate-automated.js <case-id>
|
|
30
|
+
node "<fito-evaluator skill dir>/evaluate-automated.js" <case-id>
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
Loads the checkout's `rubric.yaml` and prints one **evaluation report** the reviewer
|
|
34
|
-
scores,
|
|
34
|
+
scores. Its first line, `Case checkout: <path>`, is the checkout's absolute path. Then
|
|
35
|
+
come up to three parts:
|
|
35
36
|
|
|
36
37
|
- **Automated criteria** — runs each `evaluation_method.type: automated` `command`
|
|
37
38
|
via `sh -c` in the checkout (a non-zero exit is **evidence**, not a failure):
|
|
@@ -53,10 +54,10 @@ This runs the case author's commands on the learner's machine and checkout — t
|
|
|
53
54
|
same trust boundary as the learner working in the repo (Architecture Decision #4).
|
|
54
55
|
It writes nothing to the backend and never reads `.case/solution/`.
|
|
55
56
|
|
|
56
|
-
**Done when** it prints the report. Hand that report **and the checkout path**
|
|
57
|
-
|
|
58
|
-
`subagent` tool) to assign the 0–3 scores: it judges the automated/gate evidence
|
|
59
|
-
the report and reads the learner's artifacts + git diff from the checkout for the
|
|
57
|
+
**Done when** it prints the report. Hand that report **and the checkout path** (its
|
|
58
|
+
first line, exactly as printed) to the `fito-performance-reviewer` **subagent** (via
|
|
59
|
+
the `subagent` tool) to assign the 0–3 scores: it judges the automated/gate evidence
|
|
60
|
+
from the report and reads the learner's artifacts + git diff from the checkout for the
|
|
60
61
|
`ai`/`hybrid` criteria. If the report has no scorable criteria, there is nothing to
|
|
61
62
|
score.
|
|
62
63
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
1
|
+
import { execFile, spawn } from "node:child_process";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
2
4
|
import { promisify } from "node:util";
|
|
3
5
|
/**
|
|
4
6
|
* The real executor for automated rubric criteria (Task 6.1): runs each criterion's free-form
|
|
@@ -18,7 +20,7 @@ const MAX_BUFFER = 16 * 1024 * 1024;
|
|
|
18
20
|
* Default per-command time budget; a command still running after this is terminated and scored as
|
|
19
21
|
* evidence.
|
|
20
22
|
*
|
|
21
|
-
* **Deliberately generous, because a timeout is scored as a failure** (see the `
|
|
23
|
+
* **Deliberately generous, because a timeout is scored as a failure** (see the `timedOut` branch
|
|
22
24
|
* below) and that score reaches the learner's competence profile through `/fito-submit`. A command
|
|
23
25
|
* that is merely *slow* is indistinguishable here from one that is *hung*, so the budget has to
|
|
24
26
|
* clear the slow case by a wide margin: a first `./gradlew test` on a cold cache downloads
|
|
@@ -34,31 +36,125 @@ const DEFAULT_TIMEOUT_MS = 15 * 60 * 1000;
|
|
|
34
36
|
const TIMEOUT_EXIT_CODE = 124;
|
|
35
37
|
export const shellExec = async (command, options) => {
|
|
36
38
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
// Fito's own output limit and timer, not `execFile`'s `maxBuffer` and `timeout`: those end the
|
|
40
|
+
// `sh` alone, and the programs it started kept running (Phase 17a, finding 14).
|
|
41
|
+
const run = execFileAsync("sh", ["-c", command], {
|
|
42
|
+
cwd: options.cwd,
|
|
43
|
+
encoding: "utf8",
|
|
44
|
+
maxBuffer: Infinity,
|
|
45
|
+
});
|
|
46
|
+
const stop = () => {
|
|
47
|
+
endProcessTree(run.child);
|
|
48
|
+
// As `execFile`'s own limits do: a program that still holds the output open must not hold the
|
|
49
|
+
// result back.
|
|
50
|
+
run.child.stdout?.destroy();
|
|
51
|
+
run.child.stderr?.destroy();
|
|
52
|
+
};
|
|
53
|
+
let overflow;
|
|
54
|
+
for (const stream of [run.child.stdout, run.child.stderr]) {
|
|
55
|
+
let bytes = 0;
|
|
56
|
+
stream?.on("data", (chunk) => {
|
|
57
|
+
bytes += Buffer.byteLength(chunk);
|
|
58
|
+
if (bytes > MAX_BUFFER && overflow === undefined) {
|
|
59
|
+
overflow = new Error(`\`${command}\` produced more than ${MAX_BUFFER} bytes of output`);
|
|
60
|
+
stop();
|
|
61
|
+
}
|
|
43
62
|
});
|
|
63
|
+
}
|
|
64
|
+
let timedOut = false;
|
|
65
|
+
const timer = setTimeout(() => {
|
|
66
|
+
timedOut = true;
|
|
67
|
+
stop();
|
|
68
|
+
}, timeoutMs);
|
|
69
|
+
try {
|
|
70
|
+
const { stdout, stderr } = await run;
|
|
71
|
+
// A command can exit 0 right as its output passes the limit.
|
|
72
|
+
if (overflow !== undefined)
|
|
73
|
+
throw overflow;
|
|
44
74
|
return { stdout: String(stdout), stderr: String(stderr), exitCode: 0 };
|
|
45
75
|
}
|
|
46
76
|
catch (error) {
|
|
77
|
+
if (overflow !== undefined)
|
|
78
|
+
throw overflow;
|
|
47
79
|
const e = error;
|
|
80
|
+
if (timedOut) {
|
|
81
|
+
// Terminated by the timeout — report it as evidence so it scores like a failure, not an
|
|
82
|
+
// abort. Checked first: `taskkill` ends the `sh` with exit code 1.
|
|
83
|
+
const note = `[fito] command timed out after ${timeoutMs}ms and was terminated`;
|
|
84
|
+
const stderr = e.stderr ? `${String(e.stderr)}\n${note}` : note;
|
|
85
|
+
return { stdout: String(e.stdout ?? ""), stderr, exitCode: TIMEOUT_EXIT_CODE };
|
|
86
|
+
}
|
|
48
87
|
if (typeof e.code === "number") {
|
|
49
88
|
// The command ran and exited non-zero — capture its output as evidence, don't throw.
|
|
50
89
|
return { stdout: String(e.stdout ?? ""), stderr: String(e.stderr ?? ""), exitCode: e.code };
|
|
51
90
|
}
|
|
52
|
-
if (e.code === "
|
|
53
|
-
|
|
91
|
+
if (e.code === "ENOENT") {
|
|
92
|
+
// No `sh` on `PATH`: a missing `cwd` gives the same error, and `runEvaluate` checks the
|
|
93
|
+
// checkout before any command runs. Windows has no `sh` of its own (Phase 17a, finding 3).
|
|
94
|
+
throw new Error(`Could not run \`${command}\`: Fito scores a rubric command with \`sh\`, and none was found. ` +
|
|
95
|
+
"On Windows, `sh` comes with Git for Windows, in Git Bash: https://git-scm.com/download/win");
|
|
54
96
|
}
|
|
55
|
-
|
|
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).
|
|
97
|
+
// Could not run the command at all, for a reason other than a missing `sh`.
|
|
62
98
|
throw new Error(`Failed to run \`${command}\`: ${e.message ?? "unknown error"}`);
|
|
63
99
|
}
|
|
100
|
+
finally {
|
|
101
|
+
clearTimeout(timer);
|
|
102
|
+
}
|
|
64
103
|
};
|
|
104
|
+
/**
|
|
105
|
+
* Ends the `sh` and every program below it. On Windows, `taskkill /T` follows the parent chain — pi
|
|
106
|
+
* runs it the same way, from `System32`, so `PATH` does not matter. On Linux each process of the tree
|
|
107
|
+
* is killed, found in `/proc`.
|
|
108
|
+
*
|
|
109
|
+
* The command stays in the process group of pi's `bash`, which pi kills on Esc, at its `bash` tool's
|
|
110
|
+
* timeout and when it quits; a group of its own would put it out of reach of all three (author's
|
|
111
|
+
* choice, 2026-10-22, measured on Linux). The cost: a program whose parent has already ended belongs
|
|
112
|
+
* to `init` and is not found, and with no `/proc` (macOS) only the `sh` is killed.
|
|
113
|
+
*/
|
|
114
|
+
function endProcessTree(child) {
|
|
115
|
+
if (child.pid === undefined)
|
|
116
|
+
return;
|
|
117
|
+
if (process.platform === "win32") {
|
|
118
|
+
const taskkill = path.join(process.env.SystemRoot ?? "C:\\Windows", "System32", "taskkill.exe");
|
|
119
|
+
spawn(taskkill, ["/PID", String(child.pid), "/T", "/F"], { stdio: "ignore", windowsHide: true }).on("error", () => child.kill());
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
for (const pid of processTree(child.pid)) {
|
|
123
|
+
try {
|
|
124
|
+
process.kill(pid, "SIGKILL");
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
// It ended on its own in the meantime.
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** `root` and the pid of every process below it, from each process's parent in `/proc`; `[root]` with no `/proc`. */
|
|
132
|
+
function processTree(root) {
|
|
133
|
+
let entries;
|
|
134
|
+
try {
|
|
135
|
+
entries = fs.readdirSync("/proc");
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
return [root];
|
|
139
|
+
}
|
|
140
|
+
const parentOf = new Map();
|
|
141
|
+
for (const entry of entries) {
|
|
142
|
+
if (!/^\d+$/.test(entry))
|
|
143
|
+
continue;
|
|
144
|
+
try {
|
|
145
|
+
// `<pid> (<name>) <state> <ppid> …` — a name can hold spaces and `)`, so read after the last `)`.
|
|
146
|
+
const stat = fs.readFileSync(`/proc/${entry}/stat`, "utf8");
|
|
147
|
+
parentOf.set(Number(entry), Number(stat.slice(stat.lastIndexOf(")") + 2).split(" ")[1]));
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
// The process ended while the table was read.
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const tree = [root];
|
|
154
|
+
for (let i = 0; i < tree.length; i++) {
|
|
155
|
+
for (const [pid, parent] of parentOf)
|
|
156
|
+
if (parent === tree[i])
|
|
157
|
+
tree.push(pid);
|
|
158
|
+
}
|
|
159
|
+
return tree;
|
|
160
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
1
|
+
import { type ChildProcess, execFile, spawn } from "node:child_process";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
2
4
|
import { promisify } from "node:util";
|
|
3
5
|
|
|
4
6
|
import type { AutomatedExecutor, CommandResult } from "./evaluate.ts";
|
|
@@ -21,7 +23,7 @@ const MAX_BUFFER = 16 * 1024 * 1024;
|
|
|
21
23
|
* Default per-command time budget; a command still running after this is terminated and scored as
|
|
22
24
|
* evidence.
|
|
23
25
|
*
|
|
24
|
-
* **Deliberately generous, because a timeout is scored as a failure** (see the `
|
|
26
|
+
* **Deliberately generous, because a timeout is scored as a failure** (see the `timedOut` branch
|
|
25
27
|
* below) and that score reaches the learner's competence profile through `/fito-submit`. A command
|
|
26
28
|
* that is merely *slow* is indistinguishable here from one that is *hung*, so the budget has to
|
|
27
29
|
* clear the slow case by a wide margin: a first `./gradlew test` on a cold cache downloads
|
|
@@ -38,36 +40,126 @@ const TIMEOUT_EXIT_CODE = 124;
|
|
|
38
40
|
|
|
39
41
|
export const shellExec: AutomatedExecutor = async (command, options): Promise<CommandResult> => {
|
|
40
42
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
// Fito's own output limit and timer, not `execFile`'s `maxBuffer` and `timeout`: those end the
|
|
44
|
+
// `sh` alone, and the programs it started kept running (Phase 17a, finding 14).
|
|
45
|
+
const run = execFileAsync("sh", ["-c", command], {
|
|
46
|
+
cwd: options.cwd,
|
|
47
|
+
encoding: "utf8",
|
|
48
|
+
maxBuffer: Infinity,
|
|
49
|
+
});
|
|
50
|
+
const stop = (): void => {
|
|
51
|
+
endProcessTree(run.child);
|
|
52
|
+
// As `execFile`'s own limits do: a program that still holds the output open must not hold the
|
|
53
|
+
// result back.
|
|
54
|
+
run.child.stdout?.destroy();
|
|
55
|
+
run.child.stderr?.destroy();
|
|
56
|
+
};
|
|
57
|
+
let overflow: Error | undefined;
|
|
58
|
+
for (const stream of [run.child.stdout, run.child.stderr]) {
|
|
59
|
+
let bytes = 0;
|
|
60
|
+
stream?.on("data", (chunk: string) => {
|
|
61
|
+
bytes += Buffer.byteLength(chunk);
|
|
62
|
+
if (bytes > MAX_BUFFER && overflow === undefined) {
|
|
63
|
+
overflow = new Error(`\`${command}\` produced more than ${MAX_BUFFER} bytes of output`);
|
|
64
|
+
stop();
|
|
65
|
+
}
|
|
47
66
|
});
|
|
67
|
+
}
|
|
68
|
+
let timedOut = false;
|
|
69
|
+
const timer = setTimeout(() => {
|
|
70
|
+
timedOut = true;
|
|
71
|
+
stop();
|
|
72
|
+
}, timeoutMs);
|
|
73
|
+
try {
|
|
74
|
+
const { stdout, stderr } = await run;
|
|
75
|
+
// A command can exit 0 right as its output passes the limit.
|
|
76
|
+
if (overflow !== undefined) throw overflow;
|
|
48
77
|
return { stdout: String(stdout), stderr: String(stderr), exitCode: 0 };
|
|
49
78
|
} catch (error) {
|
|
79
|
+
if (overflow !== undefined) throw overflow;
|
|
50
80
|
const e = error as {
|
|
51
81
|
code?: number | string;
|
|
52
|
-
killed?: boolean;
|
|
53
82
|
stdout?: string;
|
|
54
83
|
stderr?: string;
|
|
55
84
|
message?: string;
|
|
56
85
|
};
|
|
86
|
+
if (timedOut) {
|
|
87
|
+
// Terminated by the timeout — report it as evidence so it scores like a failure, not an
|
|
88
|
+
// abort. Checked first: `taskkill` ends the `sh` with exit code 1.
|
|
89
|
+
const note = `[fito] command timed out after ${timeoutMs}ms and was terminated`;
|
|
90
|
+
const stderr = e.stderr ? `${String(e.stderr)}\n${note}` : note;
|
|
91
|
+
return { stdout: String(e.stdout ?? ""), stderr, exitCode: TIMEOUT_EXIT_CODE };
|
|
92
|
+
}
|
|
57
93
|
if (typeof e.code === "number") {
|
|
58
94
|
// The command ran and exited non-zero — capture its output as evidence, don't throw.
|
|
59
95
|
return { stdout: String(e.stdout ?? ""), stderr: String(e.stderr ?? ""), exitCode: e.code };
|
|
60
96
|
}
|
|
61
|
-
if (e.code === "
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return { stdout: String(e.stdout ?? ""), stderr, exitCode: TIMEOUT_EXIT_CODE };
|
|
97
|
+
if (e.code === "ENOENT") {
|
|
98
|
+
// No `sh` on `PATH`: a missing `cwd` gives the same error, and `runEvaluate` checks the
|
|
99
|
+
// checkout before any command runs. Windows has no `sh` of its own (Phase 17a, finding 3).
|
|
100
|
+
throw new Error(
|
|
101
|
+
`Could not run \`${command}\`: Fito scores a rubric command with \`sh\`, and none was found. ` +
|
|
102
|
+
"On Windows, `sh` comes with Git for Windows, in Git Bash: https://git-scm.com/download/win",
|
|
103
|
+
);
|
|
69
104
|
}
|
|
70
|
-
// Could not run the command at all
|
|
105
|
+
// Could not run the command at all, for a reason other than a missing `sh`.
|
|
71
106
|
throw new Error(`Failed to run \`${command}\`: ${e.message ?? "unknown error"}`);
|
|
107
|
+
} finally {
|
|
108
|
+
clearTimeout(timer);
|
|
72
109
|
}
|
|
73
110
|
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Ends the `sh` and every program below it. On Windows, `taskkill /T` follows the parent chain — pi
|
|
114
|
+
* runs it the same way, from `System32`, so `PATH` does not matter. On Linux each process of the tree
|
|
115
|
+
* is killed, found in `/proc`.
|
|
116
|
+
*
|
|
117
|
+
* The command stays in the process group of pi's `bash`, which pi kills on Esc, at its `bash` tool's
|
|
118
|
+
* timeout and when it quits; a group of its own would put it out of reach of all three (author's
|
|
119
|
+
* choice, 2026-10-22, measured on Linux). The cost: a program whose parent has already ended belongs
|
|
120
|
+
* to `init` and is not found, and with no `/proc` (macOS) only the `sh` is killed.
|
|
121
|
+
*/
|
|
122
|
+
function endProcessTree(child: ChildProcess): void {
|
|
123
|
+
if (child.pid === undefined) return;
|
|
124
|
+
if (process.platform === "win32") {
|
|
125
|
+
const taskkill = path.join(process.env.SystemRoot ?? "C:\\Windows", "System32", "taskkill.exe");
|
|
126
|
+
spawn(taskkill, ["/PID", String(child.pid), "/T", "/F"], { stdio: "ignore", windowsHide: true }).on(
|
|
127
|
+
"error",
|
|
128
|
+
() => child.kill(),
|
|
129
|
+
);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
for (const pid of processTree(child.pid)) {
|
|
133
|
+
try {
|
|
134
|
+
process.kill(pid, "SIGKILL");
|
|
135
|
+
} catch {
|
|
136
|
+
// It ended on its own in the meantime.
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** `root` and the pid of every process below it, from each process's parent in `/proc`; `[root]` with no `/proc`. */
|
|
142
|
+
function processTree(root: number): number[] {
|
|
143
|
+
let entries: string[];
|
|
144
|
+
try {
|
|
145
|
+
entries = fs.readdirSync("/proc");
|
|
146
|
+
} catch {
|
|
147
|
+
return [root];
|
|
148
|
+
}
|
|
149
|
+
const parentOf = new Map<number, number>();
|
|
150
|
+
for (const entry of entries) {
|
|
151
|
+
if (!/^\d+$/.test(entry)) continue;
|
|
152
|
+
try {
|
|
153
|
+
// `<pid> (<name>) <state> <ppid> …` — a name can hold spaces and `)`, so read after the last `)`.
|
|
154
|
+
const stat = fs.readFileSync(`/proc/${entry}/stat`, "utf8");
|
|
155
|
+
parentOf.set(Number(entry), Number(stat.slice(stat.lastIndexOf(")") + 2).split(" ")[1]));
|
|
156
|
+
} catch {
|
|
157
|
+
// The process ended while the table was read.
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const tree = [root];
|
|
161
|
+
for (let i = 0; i < tree.length; i++) {
|
|
162
|
+
for (const [pid, parent] of parentOf) if (parent === tree[i]) tree.push(pid);
|
|
163
|
+
}
|
|
164
|
+
return tree;
|
|
165
|
+
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* `node evaluate-automated.js <case-id>` — the `fito-performance-reviewer` automated-criteria
|
|
3
3
|
* entrypoint (Task 6.1). Resolves the learner's per-case checkout (`~/.fito/cases/<case-id>/`, the
|
|
4
4
|
* same location `/fito-case-open` writes), loads its `rubric.yaml`, runs every `automated` criterion's
|
|
5
|
-
* command, and prints the captured-evidence report
|
|
6
|
-
* the report to the reviewer subagent for scoring.
|
|
5
|
+
* command, and prints the captured-evidence report, headed by the checkout's absolute path. The
|
|
6
|
+
* `/fito-evaluate` prompt runs this, then hands the report to the reviewer subagent for scoring.
|
|
7
7
|
*
|
|
8
8
|
* `runEvaluate` is the testable core (deps injectable); `main` is the thin CLI wrapper (argv + real
|
|
9
9
|
* deps + printing). It performs no submission and writes nothing to the backend — evaluation on submit
|
|
@@ -33,7 +33,11 @@ export async function runEvaluate(options) {
|
|
|
33
33
|
// Hybrid gates run deterministically here (inheriting the 5-min timeout); the pass/fail judgment
|
|
34
34
|
// against `passingCondition` and the AI fallback are the reviewer subagent's job (Task 6.2).
|
|
35
35
|
const hybridRuns = await evaluateHybridGates(selectHybridCriteria(rubric), exec, dir, options.onProgress);
|
|
36
|
-
|
|
36
|
+
const report = renderReport(runs, selectSkippedCriteria(rubric), selectAICriteria(rubric), hybridRuns);
|
|
37
|
+
// The reviewer and the prompt's later steps use this path as printed (Task 17a.2): a
|
|
38
|
+
// `~/.fito/cases/<id>/` would be read from `HOME` by Git Bash and from `USERPROFILE` by Node, and
|
|
39
|
+
// with `/` a model copying the path into a tool call has no `\` to escape.
|
|
40
|
+
return `Case checkout: ${dir.split(path.sep).join("/")}\n\n${report}`;
|
|
37
41
|
}
|
|
38
42
|
async function main() {
|
|
39
43
|
const caseId = process.argv[2];
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* `node evaluate-automated.js <case-id>` — the `fito-performance-reviewer` automated-criteria
|
|
3
3
|
* entrypoint (Task 6.1). Resolves the learner's per-case checkout (`~/.fito/cases/<case-id>/`, the
|
|
4
4
|
* same location `/fito-case-open` writes), loads its `rubric.yaml`, runs every `automated` criterion's
|
|
5
|
-
* command, and prints the captured-evidence report
|
|
6
|
-
* the report to the reviewer subagent for scoring.
|
|
5
|
+
* command, and prints the captured-evidence report, headed by the checkout's absolute path. The
|
|
6
|
+
* `/fito-evaluate` prompt runs this, then hands the report to the reviewer subagent for scoring.
|
|
7
7
|
*
|
|
8
8
|
* `runEvaluate` is the testable core (deps injectable); `main` is the thin CLI wrapper (argv + real
|
|
9
9
|
* deps + printing). It performs no submission and writes nothing to the backend — evaluation on submit
|
|
@@ -58,7 +58,11 @@ export async function runEvaluate(options: RunEvaluateOptions): Promise<string>
|
|
|
58
58
|
// Hybrid gates run deterministically here (inheriting the 5-min timeout); the pass/fail judgment
|
|
59
59
|
// against `passingCondition` and the AI fallback are the reviewer subagent's job (Task 6.2).
|
|
60
60
|
const hybridRuns = await evaluateHybridGates(selectHybridCriteria(rubric), exec, dir, options.onProgress);
|
|
61
|
-
|
|
61
|
+
const report = renderReport(runs, selectSkippedCriteria(rubric), selectAICriteria(rubric), hybridRuns);
|
|
62
|
+
// The reviewer and the prompt's later steps use this path as printed (Task 17a.2): a
|
|
63
|
+
// `~/.fito/cases/<id>/` would be read from `HOME` by Git Bash and from `USERPROFILE` by Node, and
|
|
64
|
+
// with `/` a model copying the path into a tool call has no `\` to escape.
|
|
65
|
+
return `Case checkout: ${dir.split(path.sep).join("/")}\n\n${report}`;
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
async function main(): Promise<void> {
|
|
@@ -26,7 +26,7 @@ stop) is an explicit, per-component action.
|
|
|
26
26
|
## Store one component file
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
node <fito-knowledge-push skill dir>/push.js <component-file> [--version <label>]
|
|
29
|
+
node "<fito-knowledge-push skill dir>/push.js" "<component-file>" [--version <label>]
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
`<component-file>` is one generator output (`{metadata, content}` JSON, e.g.
|
|
@@ -185,7 +185,7 @@ export function renderRevisionLabelRefusal(refusal, payloadPath) {
|
|
|
185
185
|
...forAuthor,
|
|
186
186
|
"",
|
|
187
187
|
AGENT_MARKER,
|
|
188
|
-
`Supersede node push.js ${payloadPath} --supersede '${target.id}' --version <label>`,
|
|
188
|
+
`Supersede node "push.js" "${payloadPath}" --supersede '${target.id}' --version <label>`,
|
|
189
189
|
].join("\n");
|
|
190
190
|
}
|
|
191
191
|
/**
|
|
@@ -205,18 +205,18 @@ export function renderPushConflict(error, file) {
|
|
|
205
205
|
{
|
|
206
206
|
name: "Link",
|
|
207
207
|
description: [`Store it as an alternative definition of ${ref}.`],
|
|
208
|
-
command: `node push.js ${file.path} --link '${ref}'`,
|
|
208
|
+
command: `node "push.js" "${file.path}" --link '${ref}'`,
|
|
209
209
|
},
|
|
210
210
|
{
|
|
211
211
|
name: "Supersede",
|
|
212
212
|
description: [`Store it as the next revision of ${ref}.`],
|
|
213
|
-
command: `node push.js ${file.path} --supersede '${ref}'`,
|
|
213
|
+
command: `node "push.js" "${file.path}" --supersede '${ref}'`,
|
|
214
214
|
},
|
|
215
215
|
{ name: "Skip", description: ["Store nothing for this file."] },
|
|
216
216
|
{
|
|
217
217
|
name: "Create new component",
|
|
218
218
|
description: ["Store it as a separate component. Fito will then have two", "almost identical components."],
|
|
219
|
-
command: `node push.js ${file.path} --override '${ref}'`,
|
|
219
|
+
command: `node "push.js" "${file.path}" --override '${ref}'`,
|
|
220
220
|
},
|
|
221
221
|
]),
|
|
222
222
|
].join("\n");
|
|
@@ -228,7 +228,7 @@ export function renderPushConflict(error, file) {
|
|
|
228
228
|
"A new revision must follow the newest one. Do you want to supersede that one?",
|
|
229
229
|
"",
|
|
230
230
|
AGENT_MARKER,
|
|
231
|
-
`Supersede node push.js ${file.path} --supersede '${head}'`,
|
|
231
|
+
`Supersede node "push.js" "${file.path}" --supersede '${head}'`,
|
|
232
232
|
].join("\n");
|
|
233
233
|
}
|
|
234
234
|
return undefined;
|
|
@@ -262,12 +262,12 @@ export function renderNearMisses(matches, file) {
|
|
|
262
262
|
{
|
|
263
263
|
name: "Link",
|
|
264
264
|
description: [`Store it as an alternative definition of "${closest.name}".`],
|
|
265
|
-
command: `node push.js ${file.path} --link '${closest.id}'`,
|
|
265
|
+
command: `node "push.js" "${file.path}" --link '${closest.id}'`,
|
|
266
266
|
},
|
|
267
267
|
{
|
|
268
268
|
name: "Supersede",
|
|
269
269
|
description: [`Store it as the next revision of "${closest.name}" (now revision ${closest.version}).`],
|
|
270
|
-
command: `node push.js ${file.path} --supersede '${closest.id}'`,
|
|
270
|
+
command: `node "push.js" "${file.path}" --supersede '${closest.id}'`,
|
|
271
271
|
},
|
|
272
272
|
{ name: "Skip", description: ["Store nothing for this file."] },
|
|
273
273
|
{
|
|
@@ -276,7 +276,7 @@ export function renderNearMisses(matches, file) {
|
|
|
276
276
|
"Store it as a separate component, next to the similar ones.",
|
|
277
277
|
"If it is almost the same as one of them, Fito asks you again.",
|
|
278
278
|
],
|
|
279
|
-
command: `node push.js ${file.path} --proceed`,
|
|
279
|
+
command: `node "push.js" "${file.path}" --proceed`,
|
|
280
280
|
},
|
|
281
281
|
]),
|
|
282
282
|
].join("\n");
|
|
@@ -293,7 +293,7 @@ export function renderRevisionLabelRefusal(refusal: RevisionLabelRefusal, payloa
|
|
|
293
293
|
...forAuthor,
|
|
294
294
|
"",
|
|
295
295
|
AGENT_MARKER,
|
|
296
|
-
`Supersede node push.js ${payloadPath} --supersede '${target.id}' --version <label>`,
|
|
296
|
+
`Supersede node "push.js" "${payloadPath}" --supersede '${target.id}' --version <label>`,
|
|
297
297
|
].join("\n");
|
|
298
298
|
}
|
|
299
299
|
|
|
@@ -314,18 +314,18 @@ export function renderPushConflict(error: FitoApiError, file: PushFile): string
|
|
|
314
314
|
{
|
|
315
315
|
name: "Link",
|
|
316
316
|
description: [`Store it as an alternative definition of ${ref}.`],
|
|
317
|
-
command: `node push.js ${file.path} --link '${ref}'`,
|
|
317
|
+
command: `node "push.js" "${file.path}" --link '${ref}'`,
|
|
318
318
|
},
|
|
319
319
|
{
|
|
320
320
|
name: "Supersede",
|
|
321
321
|
description: [`Store it as the next revision of ${ref}.`],
|
|
322
|
-
command: `node push.js ${file.path} --supersede '${ref}'`,
|
|
322
|
+
command: `node "push.js" "${file.path}" --supersede '${ref}'`,
|
|
323
323
|
},
|
|
324
324
|
{ name: "Skip", description: ["Store nothing for this file."] },
|
|
325
325
|
{
|
|
326
326
|
name: "Create new component",
|
|
327
327
|
description: ["Store it as a separate component. Fito will then have two", "almost identical components."],
|
|
328
|
-
command: `node push.js ${file.path} --override '${ref}'`,
|
|
328
|
+
command: `node "push.js" "${file.path}" --override '${ref}'`,
|
|
329
329
|
},
|
|
330
330
|
]),
|
|
331
331
|
].join("\n");
|
|
@@ -337,7 +337,7 @@ export function renderPushConflict(error: FitoApiError, file: PushFile): string
|
|
|
337
337
|
"A new revision must follow the newest one. Do you want to supersede that one?",
|
|
338
338
|
"",
|
|
339
339
|
AGENT_MARKER,
|
|
340
|
-
`Supersede node push.js ${file.path} --supersede '${head}'`,
|
|
340
|
+
`Supersede node "push.js" "${file.path}" --supersede '${head}'`,
|
|
341
341
|
].join("\n");
|
|
342
342
|
}
|
|
343
343
|
return undefined;
|
|
@@ -373,12 +373,12 @@ export function renderNearMisses(matches: NearDuplicateMatch[], file: PushFile):
|
|
|
373
373
|
{
|
|
374
374
|
name: "Link",
|
|
375
375
|
description: [`Store it as an alternative definition of "${closest.name}".`],
|
|
376
|
-
command: `node push.js ${file.path} --link '${closest.id}'`,
|
|
376
|
+
command: `node "push.js" "${file.path}" --link '${closest.id}'`,
|
|
377
377
|
},
|
|
378
378
|
{
|
|
379
379
|
name: "Supersede",
|
|
380
380
|
description: [`Store it as the next revision of "${closest.name}" (now revision ${closest.version}).`],
|
|
381
|
-
command: `node push.js ${file.path} --supersede '${closest.id}'`,
|
|
381
|
+
command: `node "push.js" "${file.path}" --supersede '${closest.id}'`,
|
|
382
382
|
},
|
|
383
383
|
{ name: "Skip", description: ["Store nothing for this file."] },
|
|
384
384
|
{
|
|
@@ -387,7 +387,7 @@ export function renderNearMisses(matches: NearDuplicateMatch[], file: PushFile):
|
|
|
387
387
|
"Store it as a separate component, next to the similar ones.",
|
|
388
388
|
"If it is almost the same as one of them, Fito asks you again.",
|
|
389
389
|
],
|
|
390
|
-
command: `node push.js ${file.path} --proceed`,
|
|
390
|
+
command: `node "push.js" "${file.path}" --proceed`,
|
|
391
391
|
},
|
|
392
392
|
]),
|
|
393
393
|
].join("\n");
|
|
@@ -12,12 +12,12 @@ allowed-tools: bash
|
|
|
12
12
|
|
|
13
13
|
# Fito Source Ingestion
|
|
14
14
|
|
|
15
|
-
Run the scripts with `node <file>.js`. Both are stateless and safe to re-run.
|
|
15
|
+
Run the scripts with `node "<file>.js"`. Both are stateless and safe to re-run.
|
|
16
16
|
|
|
17
17
|
## Build a source bundle
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
node <fito-source-ingestion skill dir>/bundle.js <source-path> [--output <dir>]
|
|
20
|
+
node "<fito-source-ingestion skill dir>/bundle.js" "<source-path>" [--output "<dir>"]
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
Run it from **your own working directory**, as every Fito skill command is — both
|
|
@@ -42,10 +42,10 @@ identifier agent as its docs path.
|
|
|
42
42
|
## Authoring-context check
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
|
-
node <fito-source-ingestion skill dir>/authoring-check.js [path]
|
|
45
|
+
node "<fito-source-ingestion skill dir>/authoring-check.js" ["<path>"]
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
Classifies the case checkout at
|
|
48
|
+
Classifies the case checkout at `<path>` (default `.`) before offering `--source .`.
|
|
49
49
|
**Not authoring** ⇔ the checkout's `origin` is a GitHub fork whose parent URL is a
|
|
50
50
|
published case registered in the backend — a learner clone by construction
|
|
51
51
|
(`/fito-case-open`). The case repo itself, a tree without an origin remote, a
|
|
@@ -33,7 +33,7 @@ existing row stores no descriptions, so most update runs follow a create.
|
|
|
33
33
|
## Create or resolve the technology
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
node <fito-technology-write skill dir>/create.js <payload-file> [--override]
|
|
36
|
+
node "<fito-technology-write skill dir>/create.js" "<payload-file>" [--override]
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
POSTs the payload's two blocks to `POST /technologies`. The backend picks the branch and reports it
|
|
@@ -75,7 +75,7 @@ de-duplicated on an author's behalf.
|
|
|
75
75
|
## Update the descriptions
|
|
76
76
|
|
|
77
77
|
```bash
|
|
78
|
-
node <fito-technology-write skill dir>/update.js <payload-file> [--overview] [--version-prose]
|
|
78
|
+
node "<fito-technology-write skill dir>/update.js" "<payload-file>" [--overview] [--version-prose]
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
Writes the payload's confirmed prose onto the two axes, each behind its own flag: `--overview` is the
|
|
@@ -59,7 +59,7 @@ export function renderNearDuplicates(error, payloadPath) {
|
|
|
59
59
|
" technology already exists, so the run becomes an update of its descriptions",
|
|
60
60
|
" re-declare re-run with a distinct --technology slug, when this is genuinely a different",
|
|
61
61
|
" technology that the matches only resemble",
|
|
62
|
-
` override node create.js ${payloadPath} --override`,
|
|
62
|
+
` override node "create.js" "${payloadPath}" --override`,
|
|
63
63
|
" create an independent technology that will coexist with every match above —",
|
|
64
64
|
" the false-positive escape; run it only after the author confirms that consequence",
|
|
65
65
|
].join("\n");
|
|
@@ -87,7 +87,7 @@ export function describeOutcome(response, payloadPath) {
|
|
|
87
87
|
"neither submitted description was stored",
|
|
88
88
|
"--overview --version-prose",
|
|
89
89
|
];
|
|
90
|
-
return [headline, ` ${note}.`, ` Write the confirmed prose with: node update.js ${payloadPath} ${flags}`].join("\n");
|
|
90
|
+
return [headline, ` ${note}.`, ` Write the confirmed prose with: node "update.js" "${payloadPath}" ${flags}`].join("\n");
|
|
91
91
|
}
|
|
92
92
|
const USAGE = "Usage: node create.js <payload-file> [--override]";
|
|
93
93
|
function parseArgs(argv) {
|
|
@@ -84,7 +84,7 @@ export function renderNearDuplicates(error: FitoApiError, payloadPath: string):
|
|
|
84
84
|
" technology already exists, so the run becomes an update of its descriptions",
|
|
85
85
|
" re-declare re-run with a distinct --technology slug, when this is genuinely a different",
|
|
86
86
|
" technology that the matches only resemble",
|
|
87
|
-
` override node create.js ${payloadPath} --override`,
|
|
87
|
+
` override node "create.js" "${payloadPath}" --override`,
|
|
88
88
|
" create an independent technology that will coexist with every match above —",
|
|
89
89
|
" the false-positive escape; run it only after the author confirms that consequence",
|
|
90
90
|
].join("\n");
|
|
@@ -114,7 +114,7 @@ export function describeOutcome(response: TechnologyWriteResponse, payloadPath:
|
|
|
114
114
|
"neither submitted description was stored",
|
|
115
115
|
"--overview --version-prose",
|
|
116
116
|
];
|
|
117
|
-
return [headline, ` ${note}.`, ` Write the confirmed prose with: node update.js ${payloadPath} ${flags}`].join("\n");
|
|
117
|
+
return [headline, ` ${note}.`, ` Write the confirmed prose with: node "update.js" "${payloadPath}" ${flags}`].join("\n");
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
const USAGE = "Usage: node create.js <payload-file> [--override]";
|