fito-tui 0.5.0 → 0.7.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-case-source-planner.md +42 -13
- package/agents/fito-performance-reviewer.md +15 -5
- package/agents/fito-tutor.md +2 -1
- package/extensions/fito-fetch-tools.js +63 -7
- package/extensions/fito-fetch-tools.ts +70 -7
- package/extensions/fito-startup.js +5 -2
- package/extensions/fito-startup.ts +5 -1
- package/package.json +1 -1
- package/prompts/fito-case-design.md +72 -17
- package/prompts/fito-case-generate.md +31 -12
- package/prompts/fito-case-open.md +17 -10
- package/prompts/fito-case-plan-source.md +13 -6
- package/prompts/fito-generate-domain-concepts.md +1 -1
- package/prompts/fito-generate-execution-facts.md +1 -1
- package/prompts/fito-generate-usage-scenarios.md +1 -1
- package/shared/case-briefing/briefing.js +1 -0
- package/shared/case-briefing/briefing.ts +1 -0
- package/shared/case-validation/case-schema.js +16 -21
- package/shared/case-validation/case-schema.ts +16 -21
- package/skills/fito-case-author/SKILL.md +8 -6
- package/skills/fito-case-author/github-publish.js +29 -2
- package/skills/fito-case-author/github-publish.ts +30 -2
- package/skills/fito-case-author/publish.js +36 -3
- package/skills/fito-case-author/publish.ts +46 -2
- package/skills/fito-evaluator/rubric.ts +29 -4
- package/skills/fito-url-content-fetcher/SKILL.md +53 -16
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* file) → local guards (clean tree, solution branch) → gh login + Fito session → identity check →
|
|
11
11
|
* published-guard → reconcile the solution branch's `.case/` with the canonical branch's (Task
|
|
12
12
|
* 9a.7 parity) → create the GitHub repo if absent → push `main` + the frozen `vX.Y.Z` branch/tag
|
|
13
|
-
* + the `case/solution-vX.Y.Z` branch →
|
|
13
|
+
* + the `case/solution-vX.Y.Z` branch → make `main` the default branch of a repo that had no
|
|
14
|
+
* branch before the push → `POST /cases` (draft) → `POST /cases/{id}/publish`.
|
|
14
15
|
*
|
|
15
16
|
* Failure leaves the local checkout intact for fix-and-retry: backend rejections surface their
|
|
16
17
|
* problem detail **verbatim**, the minted draft id is remembered in `~/.fito/publish-state.json`
|
|
@@ -35,6 +36,7 @@ import {
|
|
|
35
36
|
ghAuthStatusCommand,
|
|
36
37
|
ghCurrentLoginCommand,
|
|
37
38
|
ghRepoCreateCommand,
|
|
39
|
+
ghRepoSetDefaultBranchCommand,
|
|
38
40
|
ghRepoViewCommand,
|
|
39
41
|
gitCaseParityDiffCommand,
|
|
40
42
|
gitCheckoutCommand,
|
|
@@ -45,6 +47,7 @@ import {
|
|
|
45
47
|
gitRestoreCaseDirCommand,
|
|
46
48
|
gitStatusPorcelainCommand,
|
|
47
49
|
parseRepoArg,
|
|
50
|
+
parseRepoIsEmpty,
|
|
48
51
|
withoutAuthoringHarnessPaths,
|
|
49
52
|
} from "./github-publish.ts";
|
|
50
53
|
import type { ShellCommand } from "./github-publish.ts";
|
|
@@ -84,12 +87,19 @@ export interface RunPublishResult {
|
|
|
84
87
|
versionRef: string;
|
|
85
88
|
/** Whether this run created the GitHub repo (false: it already existed and was reused). */
|
|
86
89
|
repoCreated: boolean;
|
|
90
|
+
/** Whether this run made `main` the default branch — of a repo that had no branch before its push (Task 17.23). */
|
|
91
|
+
defaultBranchSet: boolean;
|
|
87
92
|
/** Whether the solution branch's `.case/` had diverged and was reconciled before the push (Task 9a.7). */
|
|
88
93
|
caseReconciled: boolean;
|
|
89
94
|
ghLogin: string;
|
|
90
95
|
title: string;
|
|
91
96
|
/** The case's web address, under Fito's — where it is now listed and openable. */
|
|
92
97
|
webUrl: string;
|
|
98
|
+
/**
|
|
99
|
+
* Set when making `main` the default branch failed — the case is published all the same. The
|
|
100
|
+
* caller prints this as a warning, never an error (the `refreshWarning` precedent).
|
|
101
|
+
*/
|
|
102
|
+
defaultBranchWarning?: string;
|
|
93
103
|
}
|
|
94
104
|
|
|
95
105
|
/** A backend rejection of the register/publish call: the problem detail verbatim, plus the retry id. */
|
|
@@ -197,14 +207,19 @@ export async function runPublish(options: RunPublishOptions): Promise<RunPublish
|
|
|
197
207
|
|
|
198
208
|
// Create the repo only when absent — a fix-and-retry re-run must never create a duplicate.
|
|
199
209
|
let repoCreated = false;
|
|
210
|
+
let repoView: string | undefined;
|
|
200
211
|
try {
|
|
201
|
-
await run(ghRepoViewCommand(slug));
|
|
212
|
+
repoView = await run(ghRepoViewCommand(slug));
|
|
202
213
|
} catch {
|
|
203
214
|
await run(ghRepoCreateCommand(slug, facts.title));
|
|
204
215
|
repoCreated = true;
|
|
205
216
|
}
|
|
217
|
+
// A repo with no branch yet takes its default branch from the push below: one this run created,
|
|
218
|
+
// or one a failed earlier run created and never pushed to. A repo with branches keeps its own.
|
|
219
|
+
const repoWasEmpty = repoView === undefined || parseRepoIsEmpty(repoView);
|
|
206
220
|
|
|
207
221
|
await run(gitPushCaseRefsCommand(repositoryUrl, facts.versionRef, facts.solutionBranch));
|
|
222
|
+
const defaultBranchWarning = repoWasEmpty ? await setDefaultBranchMain(run, slug) : undefined;
|
|
208
223
|
|
|
209
224
|
// Register (or reuse the draft id): POST /cases is not idempotent, so the minted id is
|
|
210
225
|
// remembered in ~/.fito/publish-state.json until the publish succeeds.
|
|
@@ -234,13 +249,36 @@ export async function runPublish(options: RunPublishOptions): Promise<RunPublish
|
|
|
234
249
|
repositoryUrl,
|
|
235
250
|
versionRef: facts.versionRef,
|
|
236
251
|
repoCreated,
|
|
252
|
+
defaultBranchSet: repoWasEmpty && defaultBranchWarning === undefined,
|
|
237
253
|
caseReconciled,
|
|
238
254
|
ghLogin,
|
|
239
255
|
title: facts.title,
|
|
240
256
|
webUrl: `${fitoUrl(env)}/cases/${caseId}`,
|
|
257
|
+
...(defaultBranchWarning === undefined ? {} : { defaultBranchWarning }),
|
|
241
258
|
};
|
|
242
259
|
}
|
|
243
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Name `main` the default branch of a repo this run pushed to first (Task 17.23). Never fatal: the
|
|
263
|
+
* default branch is what the repo's page shows and a plain `git clone` checks out, and no Fito
|
|
264
|
+
* command reads it. And a stop would be worse than the warning — a re-run finds the repo no
|
|
265
|
+
* longer empty and skips this step without a word. Returns the warning on a failure.
|
|
266
|
+
*/
|
|
267
|
+
async function setDefaultBranchMain(run: (command: ShellCommand) => Promise<string>, slug: string): Promise<string | undefined> {
|
|
268
|
+
const command = ghRepoSetDefaultBranchCommand(slug);
|
|
269
|
+
try {
|
|
270
|
+
await run(command);
|
|
271
|
+
return undefined;
|
|
272
|
+
} catch (error) {
|
|
273
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
274
|
+
return (
|
|
275
|
+
`Fito couldn't make main the repo's default branch (${reason.trimEnd()})\n` +
|
|
276
|
+
` GitHub picked one itself, and it may be the solution branch.\n` +
|
|
277
|
+
` Set it yourself: ${command.command} ${command.args.join(" ")}`
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
244
282
|
/**
|
|
245
283
|
* Enforce the `.case/` parity invariant (Task 9a.7, F9): `.case/` describes the case, not the
|
|
246
284
|
* branch — but plan-source finalizes `artifacts.yaml` on the canonical branch after the solution
|
|
@@ -364,8 +402,14 @@ async function main(): Promise<void> {
|
|
|
364
402
|
console.log("✓ Reconciled the solution branch's .case/ with main (it had diverged) before the push.");
|
|
365
403
|
}
|
|
366
404
|
console.log(`✓ Pushed main, ${result.versionRef} (branch + tag), and the solution branch.`);
|
|
405
|
+
if (result.defaultBranchSet) {
|
|
406
|
+
console.log("✓ Made main the repo's default branch.");
|
|
407
|
+
}
|
|
367
408
|
console.log(`✓ Published "${result.title}" — backend case id: ${result.caseId} (${result.status}).`);
|
|
368
409
|
console.log(`✓ Listed at: ${result.webUrl}`);
|
|
410
|
+
if (result.defaultBranchWarning) {
|
|
411
|
+
console.error(`⚠ ${result.defaultBranchWarning}`);
|
|
412
|
+
}
|
|
369
413
|
} catch (error) {
|
|
370
414
|
if (error instanceof PublishRejectedError) {
|
|
371
415
|
console.error(`✗ The backend rejected the publish (HTTP ${error.status}):\n ${error.message}`);
|
|
@@ -16,8 +16,33 @@ import { rubricSchema } from "../../shared/case-validation/case-schema.ts";
|
|
|
16
16
|
* canonical `.case/` reader + `rubricSchema` from `shared/case-validation/` rather than re-parsing YAML.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
/** A rubric as the validator accepts it: `automated` and `ai` criteria only, since ruleset 1.9.0. */
|
|
19
20
|
export type Rubric = z.infer<typeof rubricSchema>;
|
|
20
21
|
|
|
22
|
+
type ValidatedCriterion = Rubric["criteria"][number];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A rubric as the evaluator reads it, where a criterion may also be `human` or `hybrid`. The
|
|
26
|
+
* validator rejects both since Task 17.24, so {@link loadRubric} never returns one; the evaluator
|
|
27
|
+
* keeps their handling for when a person can score a criterion.
|
|
28
|
+
*/
|
|
29
|
+
export type EvaluatorRubric = {
|
|
30
|
+
criteria: Array<
|
|
31
|
+
Omit<ValidatedCriterion, "evaluation_method"> & {
|
|
32
|
+
evaluation_method:
|
|
33
|
+
| ValidatedCriterion["evaluation_method"]
|
|
34
|
+
| { type: "human"; guidance?: string }
|
|
35
|
+
| {
|
|
36
|
+
type: "hybrid";
|
|
37
|
+
automated: { command: string; passing_condition: string };
|
|
38
|
+
on_pass: string;
|
|
39
|
+
on_fail: "ai" | "human";
|
|
40
|
+
fallback_prompt_hint?: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
>;
|
|
44
|
+
};
|
|
45
|
+
|
|
21
46
|
export interface RubricLevel {
|
|
22
47
|
score: number;
|
|
23
48
|
label: string;
|
|
@@ -39,7 +64,7 @@ export interface AutomatedCriterion {
|
|
|
39
64
|
}
|
|
40
65
|
|
|
41
66
|
/** Keep only the `automated` criteria, flattened to {@link AutomatedCriterion}; preserves rubric order. */
|
|
42
|
-
export function selectAutomatedCriteria(rubric:
|
|
67
|
+
export function selectAutomatedCriteria(rubric: EvaluatorRubric): AutomatedCriterion[] {
|
|
43
68
|
const automated: AutomatedCriterion[] = [];
|
|
44
69
|
for (const criterion of rubric.criteria) {
|
|
45
70
|
if (criterion.evaluation_method.type !== "automated") continue;
|
|
@@ -69,7 +94,7 @@ export interface AICriterion {
|
|
|
69
94
|
}
|
|
70
95
|
|
|
71
96
|
/** Keep only the `ai` criteria, flattened to {@link AICriterion}; preserves rubric order. */
|
|
72
|
-
export function selectAICriteria(rubric:
|
|
97
|
+
export function selectAICriteria(rubric: EvaluatorRubric): AICriterion[] {
|
|
73
98
|
const ai: AICriterion[] = [];
|
|
74
99
|
for (const criterion of rubric.criteria) {
|
|
75
100
|
if (criterion.evaluation_method.type !== "ai") continue;
|
|
@@ -106,7 +131,7 @@ export interface HybridCriterion {
|
|
|
106
131
|
}
|
|
107
132
|
|
|
108
133
|
/** Keep only the `hybrid` criteria, flattened to {@link HybridCriterion}; preserves rubric order. */
|
|
109
|
-
export function selectHybridCriteria(rubric:
|
|
134
|
+
export function selectHybridCriteria(rubric: EvaluatorRubric): HybridCriterion[] {
|
|
110
135
|
const hybrid: HybridCriterion[] = [];
|
|
111
136
|
for (const criterion of rubric.criteria) {
|
|
112
137
|
const method = criterion.evaluation_method;
|
|
@@ -138,7 +163,7 @@ export interface SkippedCriterion {
|
|
|
138
163
|
}
|
|
139
164
|
|
|
140
165
|
/** The `human`-only criteria, so the preview can tell the learner which criteria need manual review. */
|
|
141
|
-
export function selectSkippedCriteria(rubric:
|
|
166
|
+
export function selectSkippedCriteria(rubric: EvaluatorRubric): SkippedCriterion[] {
|
|
142
167
|
const skipped: SkippedCriterion[] = [];
|
|
143
168
|
for (const criterion of rubric.criteria) {
|
|
144
169
|
if (criterion.evaluation_method.type !== "human") continue;
|
|
@@ -35,28 +35,59 @@ run's business — a source clone, sibling pipeline stages
|
|
|
35
35
|
under `output/`, the URL list itself: the run neither adds
|
|
36
36
|
to them nor removes them.
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
Find Python first. Try the three candidates in this order
|
|
39
|
+
and take the first whose `--version` prints `Python 3.`
|
|
40
|
+
and a version number; carry that command forward
|
|
41
|
+
literally, in place of `<python>` below — `py -3`
|
|
42
|
+
included. A candidate counts by what it prints: on
|
|
43
|
+
Windows, `python3` can be the Microsoft Store's
|
|
44
|
+
placeholder, which prints no version and runs no Python.
|
|
45
|
+
When none prints one, stop and report that the fetch
|
|
46
|
+
needs Python 3.
|
|
43
47
|
|
|
44
48
|
```bash
|
|
45
|
-
|
|
49
|
+
python3 --version
|
|
50
|
+
python --version
|
|
51
|
+
py -3 --version
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Then create the workspace with `<python>` and carry the
|
|
55
|
+
path it prints forward literally, in place of
|
|
56
|
+
`<workspace>` below. Python prints it with `/`
|
|
57
|
+
(`C:/Users/…` on Windows), the one form that Bash, Python
|
|
58
|
+
and the `write` tool all read as the same folder; keep
|
|
59
|
+
it in double quotes in every command, since it can hold
|
|
60
|
+
a space. Each `bash` call is a fresh shell, so a
|
|
61
|
+
variable set in one call is empty in the next, and a
|
|
62
|
+
`trap … EXIT` would delete the workspace on the way out
|
|
63
|
+
of the call that created it.
|
|
64
|
+
|
|
65
|
+
The venv keeps its programs in `<workspace>/venv/Scripts/`
|
|
66
|
+
on Windows and in `<workspace>/venv/bin/` elsewhere:
|
|
67
|
+
`<bin>` below is whichever of the two
|
|
68
|
+
`ls "<workspace>/venv"` lists.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
<python> -c "import pathlib, tempfile; print(pathlib.Path(tempfile.mkdtemp(prefix='fito-fetch-')).as_posix())"
|
|
46
72
|
# → this run's workspace; substitute what it printed for <workspace>
|
|
47
73
|
|
|
48
74
|
# a PEP 668-protected box refuses a bare `pip install`;
|
|
49
75
|
# add any fallback package the same way
|
|
50
|
-
|
|
51
|
-
|
|
76
|
+
<python> -m venv "<workspace>/venv"
|
|
77
|
+
# the venv's pip is the one <python> shipped, and an old one skips
|
|
78
|
+
# the lxml_html_clean extra that `import trafilatura` needs, so
|
|
79
|
+
# upgrade it first; call pip through the venv's python every time,
|
|
80
|
+
# since on Windows the pip program refuses to replace itself
|
|
81
|
+
"<workspace>/venv/<bin>/python" -m pip install --upgrade pip
|
|
82
|
+
"<workspace>/venv/<bin>/python" -m pip install trafilatura youtube-transcript-api
|
|
52
83
|
|
|
53
84
|
# write the fetch script to <workspace>/fetch_urls.py, then run it from
|
|
54
85
|
# the working directory — never `cd` into the workspace, or the script's
|
|
55
86
|
# ./output/… paths move with you
|
|
56
|
-
<workspace>/venv
|
|
87
|
+
"<workspace>/venv/<bin>/python" "<workspace>/fetch_urls.py" "<URL list file>"
|
|
57
88
|
|
|
58
89
|
# the run's last act, before the summary — failed runs included
|
|
59
|
-
rm -rf <workspace>
|
|
90
|
+
rm -rf "<workspace>"
|
|
60
91
|
```
|
|
61
92
|
|
|
62
93
|
## URL Detection
|
|
@@ -77,10 +108,12 @@ multiple languages are available, prefer manual
|
|
|
77
108
|
captions over auto-generated ones.
|
|
78
109
|
|
|
79
110
|
If no transcript is available at all, fall back to
|
|
80
|
-
auto-generated subtitles, landing them in the workspace
|
|
111
|
+
auto-generated subtitles, landing them in the workspace.
|
|
112
|
+
Install `yt-dlp` into the venv first:
|
|
81
113
|
|
|
82
114
|
```bash
|
|
83
|
-
<workspace>/venv
|
|
115
|
+
"<workspace>/venv/<bin>/python" -m pip install yt-dlp
|
|
116
|
+
"<workspace>/venv/<bin>/yt-dlp" --write-auto-sub --skip-download -P "<workspace>" "<url>"
|
|
84
117
|
```
|
|
85
118
|
|
|
86
119
|
Then read and clean the resulting .vtt file there
|
|
@@ -172,10 +205,14 @@ Create the directory if it doesn't exist.
|
|
|
172
205
|
|
|
173
206
|
### Summary generation
|
|
174
207
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
208
|
+
The summary is yours, written from the page you have
|
|
209
|
+
read: a script has no words of its own, and a summary
|
|
210
|
+
written before the fetch comes from recall. So the
|
|
211
|
+
script writes each file with every front-matter key
|
|
212
|
+
but `summary`. Once the script has run, read each file
|
|
213
|
+
it wrote, then add its `summary` to the front matter
|
|
214
|
+
with `edit`: a coherent sentence or two describing
|
|
215
|
+
what the page is about, max 50 words. Do NOT truncate
|
|
179
216
|
the content or copy its first lines — write an
|
|
180
217
|
original summary.
|
|
181
218
|
|