fito-tui 0.4.0 → 0.6.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.
Files changed (67) hide show
  1. package/agents/fito-case-source-planner.md +42 -13
  2. package/agents/fito-performance-reviewer.md +19 -8
  3. package/agents/fito-tutor.md +2 -1
  4. package/extensions/fito-fetch-tools.js +63 -7
  5. package/extensions/fito-fetch-tools.ts +70 -7
  6. package/extensions/fito-startup.js +32 -5
  7. package/extensions/fito-startup.ts +44 -8
  8. package/package.json +3 -3
  9. package/prompts/fito-auth-refresh.md +1 -1
  10. package/prompts/fito-case-design.md +71 -16
  11. package/prompts/fito-case-edit.md +2 -2
  12. package/prompts/fito-case-generate.md +30 -11
  13. package/prompts/fito-case-open.md +20 -12
  14. package/prompts/fito-case-plan-source.md +13 -6
  15. package/prompts/fito-create-or-update-competence.md +2 -2
  16. package/prompts/fito-create-or-update-technology.md +5 -5
  17. package/prompts/fito-delete-competence.md +2 -2
  18. package/prompts/fito-evaluate.md +30 -22
  19. package/prompts/fito-generate-domain-concepts.md +1 -1
  20. package/prompts/fito-generate-execution-facts.md +1 -1
  21. package/prompts/fito-generate-usage-scenarios.md +1 -1
  22. package/prompts/fito-login.md +3 -3
  23. package/prompts/fito-logout.md +1 -1
  24. package/prompts/fito-publish-case.md +3 -3
  25. package/prompts/fito-push-knowledge.md +1 -1
  26. package/prompts/fito-submit.md +55 -36
  27. package/shared/case-briefing/briefing.js +1 -0
  28. package/shared/case-briefing/briefing.ts +1 -0
  29. package/skills/fito-auth/SKILL.md +8 -7
  30. package/skills/fito-auth/browser.js +3 -2
  31. package/skills/fito-auth/browser.ts +3 -2
  32. package/skills/fito-auth/login.js +22 -6
  33. package/skills/fito-auth/login.ts +23 -6
  34. package/skills/fito-case-author/SKILL.md +12 -10
  35. package/skills/fito-case-author/checkout.js +22 -5
  36. package/skills/fito-case-author/checkout.ts +22 -5
  37. package/skills/fito-case-author/github-publish.js +29 -2
  38. package/skills/fito-case-author/github-publish.ts +30 -2
  39. package/skills/fito-case-author/publish.js +36 -3
  40. package/skills/fito-case-author/publish.ts +46 -2
  41. package/skills/fito-case-runner/SKILL.md +24 -7
  42. package/skills/fito-case-runner/github.js +20 -2
  43. package/skills/fito-case-runner/github.ts +21 -2
  44. package/skills/fito-case-runner/open.js +3 -3
  45. package/skills/fito-case-runner/open.ts +3 -3
  46. package/skills/fito-case-runner/runner.js +12 -1
  47. package/skills/fito-case-runner/runner.ts +15 -0
  48. package/skills/fito-case-runner/submit.js +1 -1
  49. package/skills/fito-case-runner/submit.ts +1 -1
  50. package/skills/fito-case-runner/temp-file.js +16 -0
  51. package/skills/fito-case-runner/temp-file.ts +17 -0
  52. package/skills/fito-competence-write/SKILL.md +3 -3
  53. package/skills/fito-competence-write/delete.js +1 -1
  54. package/skills/fito-competence-write/delete.ts +1 -1
  55. package/skills/fito-evaluator/SKILL.md +7 -6
  56. package/skills/fito-evaluator/criterion-exec.js +113 -17
  57. package/skills/fito-evaluator/criterion-exec.ts +110 -18
  58. package/skills/fito-evaluator/evaluate-automated.js +7 -3
  59. package/skills/fito-evaluator/evaluate-automated.ts +7 -3
  60. package/skills/fito-knowledge-push/SKILL.md +1 -1
  61. package/skills/fito-knowledge-push/push.js +8 -8
  62. package/skills/fito-knowledge-push/push.ts +8 -8
  63. package/skills/fito-source-ingestion/SKILL.md +4 -4
  64. package/skills/fito-technology-write/SKILL.md +2 -2
  65. package/skills/fito-technology-write/create.js +2 -2
  66. package/skills/fito-technology-write/create.ts +2 -2
  67. package/skills/fito-url-content-fetcher/SKILL.md +53 -16
@@ -37,10 +37,13 @@ Your caller hands you:
37
37
  technologies paired with the major line each is scoped to. You pass the
38
38
  matching version when you fetch a component (section 2), so every read
39
39
  resolves the case's declared major line.
40
- 4. **The toolchain** — the build tools and their major lines the case project
41
- is built against (e.g. Gradle 9, Kotlin 2, Javalin 7). It grounds a
42
- greenfield scaffold (section 4), and you cross-check it against the declared
43
- technologies' version prose (section 2).
40
+ 4. **The toolchain** — the tools and their major lines the case project is
41
+ built against (e.g. JDK 21, Gradle 9, Kotlin 2, Javalin 7), each entry
42
+ naming who provides it: `learner` (the learner installs it, and its line is
43
+ a minimum — that line or newer) or `project` (the build fetches it itself,
44
+ through a wrapper or a lockfile). It grounds a greenfield scaffold and the
45
+ build's version rules (section 4), and you cross-check it against the
46
+ declared technologies' version prose (section 2).
44
47
  5. On a revision run, **the author's feedback** on the previous documents.
45
48
 
46
49
  ## 1. Read the case contract
@@ -73,7 +76,8 @@ From `<case-dir>/.case/`, collect what binds the source:
73
76
 
74
77
  On **reuse**, also skim the project itself — **structure, not a deep read**:
75
78
  layout, build/manifest files, test layout — enough to name real files in the
76
- plan and to confirm the gate commands are the ones the build files declare.
79
+ plan, to confirm the gate commands are the ones the build files declare, and
80
+ to see how the build names each `learner` tool's version.
77
81
  Read adaptively — never pull a whole large file into your context; the head
78
82
  of a build file or a grep for a gate command is enough.
79
83
 
@@ -182,8 +186,9 @@ exactly two files.
182
186
  ### `.authoring/source-spec.md` — what the source must be
183
187
 
184
188
  - **Project** — what the case project is and does, its stack and layout
185
- (reuse: as skimmed; greenfield: what to build), and how it matches the
186
- situation fiction (names, framing, the story the tree must tell).
189
+ (reuse: as skimmed; greenfield: what to build), each `learner` tool as the
190
+ minimum line the build accepts, and how it matches the situation fiction
191
+ (names, framing, the story the tree must tell).
187
192
  - **Starter state** (the branch carrying `.case/`) — the inline contract:
188
193
  every failing test by name with how it must fail, every known error
189
194
  verbatim, the build status, and what must *not* be present (the solution,
@@ -209,7 +214,7 @@ the starter checks fail on the starter branch exactly as `known_state.yaml`
209
214
  states.
210
215
 
211
216
  On **greenfield**, the scaffold steps must produce a **complete, buildable**
212
- project from the declared toolchain — three load-bearing requirements, each a
217
+ project from the declared toolchain — four load-bearing requirements, each a
213
218
  precondition for the plan to execute and every gate command to actually run:
214
219
 
215
220
  - **Complete build config** — the build files wire the test runner (e.g.
@@ -220,10 +225,30 @@ precondition for the plan to execute and every gate command to actually run:
220
225
  - **No patch pins** — every dependency version is a major line the toolchain
221
226
  declared; the step resolves an actual release satisfying that major at build
222
227
  time and pins no fabricated patch version.
228
+ - **Learner tools at their line or newer** — the build accepts each `learner`
229
+ entry at its declared line or any newer install, with that line as a floor
230
+ and no ceiling: a JVM build that targets Java 21 on whatever JDK 21 or newer
231
+ it finds, rather than demanding JDK 21 itself; a Node project whose
232
+ `engines` field reads `>=24`, rather than `24.x`. The step's check: the
233
+ gates pass on the minimum line, and the build file sets that line as a floor
234
+ with no upper limit; when the creator has a newer line installed, the gates
235
+ pass on it too.
223
236
  - **A `.gitignore` covering build outputs** — a clean-tree guard so the starter
224
237
  branch starts from a known state and every gate runs against the source, not
225
238
  build artifacts.
226
239
 
240
+ On **reuse**, a build that refuses a newer line of a `learner` tool — an exact
241
+ version, such as a JVM build fixed at one JDK, or an upper limit, such as an
242
+ `engines` range that stops below the next Node line — gets a plan step of its
243
+ own that makes the build accept that line or newer, verified by the check
244
+ the greenfield bullet above names. The project's other pins stay as they are:
245
+ the build fetches those tools itself.
246
+
247
+ A `learner` tool the build cannot accept at its line or newer is a **gap**:
248
+ flag it in your digest rather than claiming the line or newer. The project's
249
+ own tools can set that ceiling — a build tool runs only on the runtime lines
250
+ it knows, up to its newest one.
251
+
227
252
  Trace the starter contract entry by entry, never implicitly: every
228
253
  `failing_tests` entry, every known error, and every deliverable has a named,
229
254
  file-level counterpart in the plan — which file, what change or content makes
@@ -237,16 +262,20 @@ attestation, then `/fito-publish-case`.
237
262
 
238
263
  **Done when** both files exist, the spec carries both terminal states with
239
264
  every gate and every starter item inline, every plan step has a
240
- verification, and every starter entry and deliverable is traced — or flagged
241
- as a gap.
265
+ verification, every starter entry and deliverable is traced — or flagged
266
+ as a gap — and the build accepts every `learner` tool at its line or newer
267
+ (through the scaffold on greenfield, through a plan step on reuse wherever the
268
+ build refuses a newer line), or the tool is flagged as a gap.
242
269
 
243
270
  ## 5. Report back
244
271
 
245
272
  Return a digest for your caller to relay — not a file dump: the scenario, the
246
273
  two file paths, each terminal state in one line, the plan-step count, the
247
- gates covered, any contract conflict you surfaced (see Boundaries), and a
248
- **toolchain cross-check** section listing every declared technology whose
249
- version description contradicted the toolchain (empty when none did).
274
+ gates covered, each `learner` tool with its minimum line, any plan step that
275
+ lifts a limit on one, any `learner` tool flagged as a gap, any contract
276
+ conflict you surfaced (see Boundaries), and a **toolchain cross-check** section
277
+ listing every declared technology whose version description contradicted the
278
+ toolchain (empty when none did).
250
279
 
251
280
  ## Boundaries
252
281
 
@@ -34,9 +34,11 @@ you were given; the output contract differs per job.
34
34
  evidence (exit/stdout/stderr), the **passing condition**, the **on-pass** level
35
35
  label, the **on-fail** route (`ai`/`human`), and any **fallback prompt hint**.
36
36
  - A **Needs human review** list of any `human` criteria.
37
- 2. The **case checkout path** — the local directory (`~/.fito/cases/<case-id>/`)
38
- where the learner is working. You read the learner's work from here to score the
39
- `ai` and `hybrid` criteria. You never write to it.
37
+ 2. The **case checkout path** — the absolute path of the local directory where the
38
+ learner is working. You read the learner's work from here to score the `ai` and
39
+ failed-`hybrid` criteria — never an `automated` one. You never write to it. Use
40
+ the path exactly as given, in double quotes in every command: it can hold a
41
+ space or a `\`.
40
42
 
41
43
  If you are given **no checkout path**, score the automated criteria from the report,
42
44
  and say the `ai`/`hybrid` criteria could not be scored because no checkout was
@@ -47,13 +49,22 @@ Score **every** criterion the report lists, in report order, by its type.
47
49
 
48
50
  ## `automated` — score from the captured evidence
49
51
 
52
+ Score an `automated` criterion from the captured exit code and output alone: the
53
+ command is its whole evidence, so the checkout stays unread for it — even when a
54
+ rung seems to ask for more.
55
+
50
56
  1. Read the captured stdout/stderr and exit code as the ground truth of what the
51
57
  learner's work produced. A non-zero exit, an empty result where output was
52
58
  required, or a "command not found" is itself evidence — usually `not_achieved`.
53
- 2. Judge that evidence against the **passing condition**, then pick the single
54
- **level** (0–3) whose description it best matches.
59
+ 2. Judge that evidence against the **passing condition**, then award the highest
60
+ **level** (0–3) the output proves. A rung that needs evidence this output does
61
+ not show is not awarded: a passing run proves its passing condition, not which
62
+ test covers a behavior or which call the code makes — unless the output prints
63
+ it.
55
64
  3. Justify in one sentence citing the specific evidence (a line of stdout, the exit
56
- code) — not a restatement of the level.
65
+ code) — not a restatement of the level. When a higher rung went unawarded
66
+ because the output cannot show it, the sentence also names what the output
67
+ could not show.
57
68
 
58
69
  ## `ai` — judge the learner's work against the prompt hint
59
70
 
@@ -78,8 +89,8 @@ For `ai` (and failed-`hybrid`) criteria, read only from `<checkout>` to build th
78
89
  picture the case author intended (Case Structure Spec §16 "AI Assessment Context"):
79
90
 
80
91
  - **The learner's changes** — read `submission.target_branch` from
81
- `.case/manifest.yaml`, then `cd <checkout> && git diff <target_branch>`. If that
82
- ref is absent locally, fall back to `cd <checkout> && git diff` and note the diff
92
+ `.case/manifest.yaml`, then `git -C "<checkout>" diff <target_branch>`. If that
93
+ ref is absent locally, fall back to `git -C "<checkout>" diff` and note the diff
83
94
  is against the working tree only.
84
95
  - **Relevant artifacts** — the entries in `.case/artifacts.yaml` whose `role` is
85
96
  `target` or `evidence`; read those files.
@@ -43,7 +43,8 @@ from so you can cite it:
43
43
  - `situation` — the scenario documents, in reading order.
44
44
  - `task` — the objective, the constraints, any steps, the deliverables.
45
45
  - `artifacts` — the annotated map of the files the case works on.
46
- - `starter_state` — the baseline the learner started from.
46
+ - `starter_state` — the baseline the learner started from, and the tools they
47
+ install to build it.
47
48
  - `knowledge_refs` — the components the case teaches and the ones it assumes.
48
49
 
49
50
  Fetch the keys the question actually turns on, not all six: what is being asked
@@ -4,12 +4,14 @@ import { listCompetences } from "../shared/competences/competence-list.js";
4
4
  import { COMPONENT_TYPES } from "../shared/fito-api/client.js";
5
5
  import { fetchKnowledgeComponent } from "../shared/knowledge-components/knowledge-fetch.js";
6
6
  import { searchKnowledgeComponents } from "../shared/knowledge-components/knowledge-search.js";
7
+ import { resolveRegisteredTemplate } from "../shared/knowledge-components/push-payload.js";
7
8
  import { fetchTechnology } from "../shared/knowledge-components/technology-fetch.js";
8
9
  /**
9
- * Side-effect-free registrar for the five Fito read-only fetch tools
10
+ * Side-effect-free registrar for the six Fito read-only fetch tools
10
11
  * (`fito_knowledge_fetch`, `fito_knowledge_search`, `fito_technology_fetch`,
11
- * `fito_competence_list`, `fito_case_partial_fetch`). The first four read the backend over HTTP;
12
- * the fifth reads the learner's own `.case/` checkout through the `shared/case-briefing/` allow-list. None of them
12
+ * `fito_competence_list`, `fito_template_fetch`, `fito_case_partial_fetch`). The first five read the
13
+ * backend over HTTP; the sixth reads the learner's own `.case/` checkout through the
14
+ * `shared/case-briefing/` allow-list. None of them
13
15
  * spawns a process or opens a caller-named path, which is what lets a persona denied `bash`,
14
16
  * `read`, `edit` and `write` hold them (Success Criterion #9).
15
17
  *
@@ -37,6 +39,8 @@ export const TECHNOLOGY_FETCH_TOOL = "fito_technology_fetch";
37
39
  export const KNOWLEDGE_SEARCH_TOOL = "fito_knowledge_search";
38
40
  /** Name of the in-process competence-listing custom tool (Task 15b.6). */
39
41
  export const COMPETENCE_LIST_TOOL = "fito_competence_list";
42
+ /** Name of the in-process registered-template read (Task 17.22). */
43
+ export const TEMPLATE_FETCH_TOOL = "fito_template_fetch";
40
44
  /** Name of the in-process case-briefing custom tool (Task 11.2). */
41
45
  export const CASE_PARTIAL_FETCH_TOOL = "fito_case_partial_fetch";
42
46
  /**
@@ -296,6 +300,57 @@ export function registerFitoCompetenceListTool(pi) {
296
300
  });
297
301
  });
298
302
  }
303
+ /**
304
+ * Register the `fito_template_fetch` tool: given a component type and a technology slug, return
305
+ * the registered template — the field-schema a component's `content` must conform to — that the
306
+ * technology's `kind` selects (Task 17.22). The three `/fito-generate-*` prompts read it before they
307
+ * delegate. Without it they named no means, and each model found its own: the package's own
308
+ * `fito-api` code imported with `node -e`, which failed once on Windows, `curl`, or the authoring
309
+ * guide's field list alone (Task 17b.2's run, F1).
310
+ *
311
+ * **The tool takes the technology, not a kind**, so it resolves through `resolveRegisteredTemplate`,
312
+ * the same function `push.js` runs: the template the generator writes against is the one the push
313
+ * stores the component under, and no caller can ask for another variant.
314
+ *
315
+ * Transport + resolution stay in `shared/` (pi-free); this `execute()` is a thin adapter over two
316
+ * in-process public HTTP reads, and failures throw so pi marks the result `isError`.
317
+ */
318
+ export function registerFitoTemplateFetchTool(pi) {
319
+ registerToolTolerant(() => {
320
+ pi.registerTool({
321
+ name: TEMPLATE_FETCH_TOOL,
322
+ label: "Fetch Fito template",
323
+ description: "Fetch the registered template a Fito knowledge component must conform to — its " +
324
+ "field-schema: each field's key, label, type and requirement. Pass the component type " +
325
+ "and the technology's slug (e.g. `javalin`): the technology's kind selects the variant " +
326
+ "(an exact `tool` or `practice` template, otherwise the shared `any` one), newest version " +
327
+ "first, which is the template `/fito-push-knowledge` stores the component under. Use it " +
328
+ "before generating a component's content. The backend is the source of truth, so fetch " +
329
+ "rather than recall. The read is public (no login). Returns the template as JSON; an " +
330
+ "unknown technology is an error.",
331
+ promptSnippet: "Fetch the registered field-schema a knowledge component type must conform to, for one technology",
332
+ promptGuidelines: [
333
+ `Use ${TEMPLATE_FETCH_TOOL} to read a component type's registered field-schema before generating its content, instead of reading the Fito package's code or calling the backend from the shell.`,
334
+ ],
335
+ parameters: Type.Object({
336
+ // A literal union rather than a free string, as on `fito_knowledge_search`.
337
+ type: Type.Union(COMPONENT_TYPES.map((componentType) => Type.Literal(componentType)), { description: "The component type — `concept`, `execution-fact`, or `usage-scenario`." }),
338
+ technology: Type.String({
339
+ description: "The technology's slug (e.g. `javalin`, `specification-by-example`) — the middle " +
340
+ "segment of a knowledge-component id `<type>:<tech-slug>.<component-slug>`. Its kind " +
341
+ "selects the template variant.",
342
+ }),
343
+ }),
344
+ async execute(_toolCallId, params) {
345
+ const template = await resolveRegisteredTemplate(params.type, params.technology);
346
+ return {
347
+ content: [{ type: "text", text: JSON.stringify(template, null, 2) }],
348
+ details: { template },
349
+ };
350
+ },
351
+ });
352
+ });
353
+ }
299
354
  /**
300
355
  * Register the `fito_case_partial_fetch` tool: given a case id and one of an enumerated set of
301
356
  * document **keys**, return that part of the learner's local `.case/` checkout. It is the read the
@@ -350,9 +405,9 @@ export function registerFitoCasePartialFetchTool(pi) {
350
405
  "`manifest` is the case's title, type, version, tags and estimated duration; " +
351
406
  "`situation` the scenario documents in reading order; `task` the objective, " +
352
407
  "constraints, steps and deliverables; `artifacts` the annotated map of the files " +
353
- "the case works on; `starter_state` the baseline the learner starts from; " +
354
- "`knowledge_refs` the knowledge components the case teaches and assumes (fetch " +
355
- "those with `fito_knowledge_fetch`).",
408
+ "the case works on; `starter_state` the baseline the learner starts from and the tools " +
409
+ "they install to build it; `knowledge_refs` the knowledge components the case " +
410
+ "teaches and assumes (fetch those with `fito_knowledge_fetch`).",
356
411
  }),
357
412
  }),
358
413
  async execute(_toolCallId, params) {
@@ -366,7 +421,7 @@ export function registerFitoCasePartialFetchTool(pi) {
366
421
  });
367
422
  }
368
423
  /**
369
- * Register all five Fito fetch tools. This is the module's `default` export so it can be
424
+ * Register all six Fito fetch tools. This is the module's `default` export so it can be
370
425
  * named as a persona's `subagentOnlyExtensions` entry — `pi-subagents` loads the file
371
426
  * as a `--extension` in the child, and the registered tool names then survive the
372
427
  * child's strict `--tools` allowlist (Task 9a.10; pi-subagents README §subagentOnlyExtensions).
@@ -376,5 +431,6 @@ export default function registerFitoFetchTools(pi) {
376
431
  registerFitoKnowledgeSearchTool(pi);
377
432
  registerFitoTechnologyFetchTool(pi);
378
433
  registerFitoCompetenceListTool(pi);
434
+ registerFitoTemplateFetchTool(pi);
379
435
  registerFitoCasePartialFetchTool(pi);
380
436
  }
@@ -6,13 +6,15 @@ import { listCompetences } from "../shared/competences/competence-list.ts";
6
6
  import { COMPONENT_TYPES } from "../shared/fito-api/client.ts";
7
7
  import { fetchKnowledgeComponent } from "../shared/knowledge-components/knowledge-fetch.ts";
8
8
  import { searchKnowledgeComponents } from "../shared/knowledge-components/knowledge-search.ts";
9
+ import { resolveRegisteredTemplate } from "../shared/knowledge-components/push-payload.ts";
9
10
  import { fetchTechnology } from "../shared/knowledge-components/technology-fetch.ts";
10
11
 
11
12
  /**
12
- * Side-effect-free registrar for the five Fito read-only fetch tools
13
+ * Side-effect-free registrar for the six Fito read-only fetch tools
13
14
  * (`fito_knowledge_fetch`, `fito_knowledge_search`, `fito_technology_fetch`,
14
- * `fito_competence_list`, `fito_case_partial_fetch`). The first four read the backend over HTTP;
15
- * the fifth reads the learner's own `.case/` checkout through the `shared/case-briefing/` allow-list. None of them
15
+ * `fito_competence_list`, `fito_template_fetch`, `fito_case_partial_fetch`). The first five read the
16
+ * backend over HTTP; the sixth reads the learner's own `.case/` checkout through the
17
+ * `shared/case-briefing/` allow-list. None of them
16
18
  * spawns a process or opens a caller-named path, which is what lets a persona denied `bash`,
17
19
  * `read`, `edit` and `write` hold them (Success Criterion #9).
18
20
  *
@@ -45,6 +47,9 @@ export const KNOWLEDGE_SEARCH_TOOL = "fito_knowledge_search";
45
47
  /** Name of the in-process competence-listing custom tool (Task 15b.6). */
46
48
  export const COMPETENCE_LIST_TOOL = "fito_competence_list";
47
49
 
50
+ /** Name of the in-process registered-template read (Task 17.22). */
51
+ export const TEMPLATE_FETCH_TOOL = "fito_template_fetch";
52
+
48
53
  /** Name of the in-process case-briefing custom tool (Task 11.2). */
49
54
  export const CASE_PARTIAL_FETCH_TOOL = "fito_case_partial_fetch";
50
55
 
@@ -331,6 +336,63 @@ export function registerFitoCompetenceListTool(pi: ExtensionAPI): void {
331
336
  });
332
337
  }
333
338
 
339
+ /**
340
+ * Register the `fito_template_fetch` tool: given a component type and a technology slug, return
341
+ * the registered template — the field-schema a component's `content` must conform to — that the
342
+ * technology's `kind` selects (Task 17.22). The three `/fito-generate-*` prompts read it before they
343
+ * delegate. Without it they named no means, and each model found its own: the package's own
344
+ * `fito-api` code imported with `node -e`, which failed once on Windows, `curl`, or the authoring
345
+ * guide's field list alone (Task 17b.2's run, F1).
346
+ *
347
+ * **The tool takes the technology, not a kind**, so it resolves through `resolveRegisteredTemplate`,
348
+ * the same function `push.js` runs: the template the generator writes against is the one the push
349
+ * stores the component under, and no caller can ask for another variant.
350
+ *
351
+ * Transport + resolution stay in `shared/` (pi-free); this `execute()` is a thin adapter over two
352
+ * in-process public HTTP reads, and failures throw so pi marks the result `isError`.
353
+ */
354
+ export function registerFitoTemplateFetchTool(pi: ExtensionAPI): void {
355
+ registerToolTolerant(() => {
356
+ pi.registerTool({
357
+ name: TEMPLATE_FETCH_TOOL,
358
+ label: "Fetch Fito template",
359
+ description:
360
+ "Fetch the registered template a Fito knowledge component must conform to — its " +
361
+ "field-schema: each field's key, label, type and requirement. Pass the component type " +
362
+ "and the technology's slug (e.g. `javalin`): the technology's kind selects the variant " +
363
+ "(an exact `tool` or `practice` template, otherwise the shared `any` one), newest version " +
364
+ "first, which is the template `/fito-push-knowledge` stores the component under. Use it " +
365
+ "before generating a component's content. The backend is the source of truth, so fetch " +
366
+ "rather than recall. The read is public (no login). Returns the template as JSON; an " +
367
+ "unknown technology is an error.",
368
+ promptSnippet: "Fetch the registered field-schema a knowledge component type must conform to, for one technology",
369
+ promptGuidelines: [
370
+ `Use ${TEMPLATE_FETCH_TOOL} to read a component type's registered field-schema before generating its content, instead of reading the Fito package's code or calling the backend from the shell.`,
371
+ ],
372
+ parameters: Type.Object({
373
+ // A literal union rather than a free string, as on `fito_knowledge_search`.
374
+ type: Type.Union(
375
+ COMPONENT_TYPES.map((componentType) => Type.Literal(componentType)),
376
+ { description: "The component type — `concept`, `execution-fact`, or `usage-scenario`." },
377
+ ),
378
+ technology: Type.String({
379
+ description:
380
+ "The technology's slug (e.g. `javalin`, `specification-by-example`) — the middle " +
381
+ "segment of a knowledge-component id `<type>:<tech-slug>.<component-slug>`. Its kind " +
382
+ "selects the template variant.",
383
+ }),
384
+ }),
385
+ async execute(_toolCallId, params) {
386
+ const template = await resolveRegisteredTemplate(params.type, params.technology);
387
+ return {
388
+ content: [{ type: "text", text: JSON.stringify(template, null, 2) }],
389
+ details: { template },
390
+ };
391
+ },
392
+ });
393
+ });
394
+ }
395
+
334
396
  /**
335
397
  * Register the `fito_case_partial_fetch` tool: given a case id and one of an enumerated set of
336
398
  * document **keys**, return that part of the learner's local `.case/` checkout. It is the read the
@@ -388,9 +450,9 @@ export function registerFitoCasePartialFetchTool(pi: ExtensionAPI): void {
388
450
  "`manifest` is the case's title, type, version, tags and estimated duration; " +
389
451
  "`situation` the scenario documents in reading order; `task` the objective, " +
390
452
  "constraints, steps and deliverables; `artifacts` the annotated map of the files " +
391
- "the case works on; `starter_state` the baseline the learner starts from; " +
392
- "`knowledge_refs` the knowledge components the case teaches and assumes (fetch " +
393
- "those with `fito_knowledge_fetch`).",
453
+ "the case works on; `starter_state` the baseline the learner starts from and the tools " +
454
+ "they install to build it; `knowledge_refs` the knowledge components the case " +
455
+ "teaches and assumes (fetch those with `fito_knowledge_fetch`).",
394
456
  }),
395
457
  }),
396
458
  async execute(_toolCallId, params) {
@@ -405,7 +467,7 @@ export function registerFitoCasePartialFetchTool(pi: ExtensionAPI): void {
405
467
  }
406
468
 
407
469
  /**
408
- * Register all five Fito fetch tools. This is the module's `default` export so it can be
470
+ * Register all six Fito fetch tools. This is the module's `default` export so it can be
409
471
  * named as a persona's `subagentOnlyExtensions` entry — `pi-subagents` loads the file
410
472
  * as a `--extension` in the child, and the registered tool names then survive the
411
473
  * child's strict `--tools` allowlist (Task 9a.10; pi-subagents README §subagentOnlyExtensions).
@@ -415,5 +477,6 @@ export default function registerFitoFetchTools(pi: ExtensionAPI): void {
415
477
  registerFitoKnowledgeSearchTool(pi);
416
478
  registerFitoTechnologyFetchTool(pi);
417
479
  registerFitoCompetenceListTool(pi);
480
+ registerFitoTemplateFetchTool(pi);
418
481
  registerFitoCasePartialFetchTool(pi);
419
482
  }
@@ -1,8 +1,9 @@
1
1
  import * as fs from "node:fs";
2
2
  import * as path from "node:path";
3
+ import { getShellConfig, } from "@earendil-works/pi-coding-agent";
3
4
  import { FitoApiError, createFitoApiClient } from "../shared/fito-api/client.js";
4
5
  import { registerFitoDelegateTool } from "./fito-delegate.js";
5
- import { registerFitoCasePartialFetchTool, registerFitoCompetenceListTool, registerFitoKnowledgeFetchTool, registerFitoKnowledgeSearchTool, registerFitoTechnologyFetchTool, } from "./fito-fetch-tools.js";
6
+ import { registerFitoCasePartialFetchTool, registerFitoCompetenceListTool, registerFitoKnowledgeFetchTool, registerFitoKnowledgeSearchTool, registerFitoTechnologyFetchTool, registerFitoTemplateFetchTool, } from "./fito-fetch-tools.js";
6
7
  /**
7
8
  * Fito startup extension.
8
9
  *
@@ -20,8 +21,8 @@ import { registerFitoCasePartialFetchTool, registerFitoCompetenceListTool, regis
20
21
  *
21
22
  * What remains here is the `session_start` checks — the guard for the missing
22
23
  * `subagent` tool, the `pi-subagents` version floor, and the backend's refusal of this
23
- * TUI's version (both Task 15d.7b) — and registration of Fito-owned custom tools (`pi.registerTool(...)`)
24
- * for the **main**
24
+ * TUI's version (both Task 15d.7b), and Bash on Windows (Task 17a.3) — and registration
25
+ * of Fito-owned custom tools (`pi.registerTool(...)`) for the **main**
25
26
  * session: `fito_knowledge_fetch` (Task 5.1b), the in-process knowledge-component
26
27
  * read that the `fito-tutor` worker holds while denied bash/filesystem (Success
27
28
  * Criterion #9; ADR-006), `fito_technology_fetch` (Task 9a.6a), the
@@ -31,7 +32,9 @@ import { registerFitoCasePartialFetchTool, registerFitoCompetenceListTool, regis
31
32
  * a flow that runs **here**, in the main session, which is why the tool has to be
32
33
  * registered at this call site and not only in the child registrar —
33
34
  * `fito_competence_list` (Task 15b.6), a technology's competences, registered here for the
34
- * same reason: the competence-authoring flow that reads it runs in the main session — and
35
+ * same reason: the competence-authoring flow that reads it runs in the main session —
36
+ * `fito_template_fetch` (Task 17.22), the registered template the `/fito-generate-*` prompts read
37
+ * in the main session before they delegate — and
35
38
  * `fito_case_partial_fetch` (Task 11.2), the allow-listed read of a locally opened
36
39
  * case that the `fito-tutor` worker holds in place of filesystem access. The registrars
37
40
  * live in `./fito-fetch-tools.ts` so the
@@ -67,12 +70,14 @@ import { registerFitoCasePartialFetchTool, registerFitoCompetenceListTool, regis
67
70
  * that id out of prose to resume its thread. `fito_delegate` now runs the tutor's thread and holds
68
71
  * the id itself, so there is no vendor tool result left to annotate and no reader for the line.
69
72
  */
70
- export default function registerFitoStartup(pi) {
73
+ export default function registerFitoStartup(pi, options = {}) {
74
+ const platform = options.platform ?? process.platform;
71
75
  if (process.env.PI_SUBAGENT_CHILD !== "1") {
72
76
  registerFitoKnowledgeFetchTool(pi);
73
77
  registerFitoKnowledgeSearchTool(pi);
74
78
  registerFitoTechnologyFetchTool(pi);
75
79
  registerFitoCompetenceListTool(pi);
80
+ registerFitoTemplateFetchTool(pi);
76
81
  registerFitoCasePartialFetchTool(pi);
77
82
  registerFitoDelegateTool(pi);
78
83
  }
@@ -93,6 +98,13 @@ export default function registerFitoStartup(pi) {
93
98
  if (subagent !== undefined && isBelowPiSubagentsFloor(subagent.sourceInfo)) {
94
99
  ctx.ui.notify(`Fito needs pi-subagents ${PI_SUBAGENTS_FLOOR.join(".")} or newer. Run: \`pi update --extensions\``, "error");
95
100
  }
101
+ // Windows has no Bash of its own, and Fito needs one (ADR-021): every script command runs
102
+ // through pi's `bash` tool, and scoring runs each rubric command with `sh`. Without it they
103
+ // fail one by one at the point of use; this says so once.
104
+ if (platform === "win32" && !piFindsBash(pi.getSettings().shellPath)) {
105
+ ctx.ui.notify("Fito needs Bash, which pi did not find. Set `shellPath` in pi's settings.json to a bash.exe, " +
106
+ "or install Git for Windows, which brings Git Bash: https://git-scm.com/download/win", "error");
107
+ }
96
108
  // Not awaited: pi awaits what a handler returns, so the start would wait for the backend.
97
109
  void warnIfTuiTooOld(ctx);
98
110
  });
@@ -130,6 +142,21 @@ function isBelowPiSubagentsFloor(sourceInfo) {
130
142
  const differing = installed.findIndex((number, index) => number !== PI_SUBAGENTS_FLOOR[index]);
131
143
  return differing !== -1 && installed[differing] < PI_SUBAGENTS_FLOOR[differing];
132
144
  }
145
+ /**
146
+ * Whether pi's own Bash lookup — the one its `bash` tool runs — finds a Bash: the user's `shellPath`
147
+ * when it is set, otherwise Git Bash under `Program Files`, then a `bash.exe` on `PATH`. pi exports
148
+ * it for extensions. pi expands `~` and `/c/…` in `shellPath` before its own lookup, and this check
149
+ * does not, so a `shellPath` written that way reads here as missing.
150
+ */
151
+ function piFindsBash(shellPath) {
152
+ try {
153
+ getShellConfig(shellPath);
154
+ return true;
155
+ }
156
+ catch {
157
+ return false;
158
+ }
159
+ }
133
160
  /** The problem `type` of the backend's refusal of a TUI older than its minimum (Task 15d.7a). */
134
161
  const TUI_TOO_OLD = "/problems/tui-too-old";
135
162
  /** How long the start check waits for the backend before it gives up and shows nothing. */
@@ -1,10 +1,11 @@
1
1
  import * as fs from "node:fs";
2
2
  import * as path from "node:path";
3
3
 
4
- import type {
5
- ExtensionAPI,
6
- ExtensionContext,
7
- SourceInfo,
4
+ import {
5
+ type ExtensionAPI,
6
+ type ExtensionContext,
7
+ type SourceInfo,
8
+ getShellConfig,
8
9
  } from "@earendil-works/pi-coding-agent";
9
10
 
10
11
  import { FitoApiError, createFitoApiClient } from "../shared/fito-api/client.ts";
@@ -15,6 +16,7 @@ import {
15
16
  registerFitoKnowledgeFetchTool,
16
17
  registerFitoKnowledgeSearchTool,
17
18
  registerFitoTechnologyFetchTool,
19
+ registerFitoTemplateFetchTool,
18
20
  } from "./fito-fetch-tools.ts";
19
21
 
20
22
  /**
@@ -34,8 +36,8 @@ import {
34
36
  *
35
37
  * What remains here is the `session_start` checks — the guard for the missing
36
38
  * `subagent` tool, the `pi-subagents` version floor, and the backend's refusal of this
37
- * TUI's version (both Task 15d.7b) — and registration of Fito-owned custom tools (`pi.registerTool(...)`)
38
- * for the **main**
39
+ * TUI's version (both Task 15d.7b), and Bash on Windows (Task 17a.3) — and registration
40
+ * of Fito-owned custom tools (`pi.registerTool(...)`) for the **main**
39
41
  * session: `fito_knowledge_fetch` (Task 5.1b), the in-process knowledge-component
40
42
  * read that the `fito-tutor` worker holds while denied bash/filesystem (Success
41
43
  * Criterion #9; ADR-006), `fito_technology_fetch` (Task 9a.6a), the
@@ -45,7 +47,9 @@ import {
45
47
  * a flow that runs **here**, in the main session, which is why the tool has to be
46
48
  * registered at this call site and not only in the child registrar —
47
49
  * `fito_competence_list` (Task 15b.6), a technology's competences, registered here for the
48
- * same reason: the competence-authoring flow that reads it runs in the main session — and
50
+ * same reason: the competence-authoring flow that reads it runs in the main session —
51
+ * `fito_template_fetch` (Task 17.22), the registered template the `/fito-generate-*` prompts read
52
+ * in the main session before they delegate — and
49
53
  * `fito_case_partial_fetch` (Task 11.2), the allow-listed read of a locally opened
50
54
  * case that the `fito-tutor` worker holds in place of filesystem access. The registrars
51
55
  * live in `./fito-fetch-tools.ts` so the
@@ -81,12 +85,18 @@ import {
81
85
  * that id out of prose to resume its thread. `fito_delegate` now runs the tutor's thread and holds
82
86
  * the id itself, so there is no vendor tool result left to annotate and no reader for the line.
83
87
  */
84
- export default function registerFitoStartup(pi: ExtensionAPI): void {
88
+ export default function registerFitoStartup(
89
+ pi: ExtensionAPI,
90
+ options: { platform?: NodeJS.Platform } = {},
91
+ ): void {
92
+ const platform = options.platform ?? process.platform;
93
+
85
94
  if (process.env.PI_SUBAGENT_CHILD !== "1") {
86
95
  registerFitoKnowledgeFetchTool(pi);
87
96
  registerFitoKnowledgeSearchTool(pi);
88
97
  registerFitoTechnologyFetchTool(pi);
89
98
  registerFitoCompetenceListTool(pi);
99
+ registerFitoTemplateFetchTool(pi);
90
100
  registerFitoCasePartialFetchTool(pi);
91
101
  registerFitoDelegateTool(pi);
92
102
  }
@@ -116,6 +126,17 @@ export default function registerFitoStartup(pi: ExtensionAPI): void {
116
126
  );
117
127
  }
118
128
 
129
+ // Windows has no Bash of its own, and Fito needs one (ADR-021): every script command runs
130
+ // through pi's `bash` tool, and scoring runs each rubric command with `sh`. Without it they
131
+ // fail one by one at the point of use; this says so once.
132
+ if (platform === "win32" && !piFindsBash(pi.getSettings().shellPath)) {
133
+ ctx.ui.notify(
134
+ "Fito needs Bash, which pi did not find. Set `shellPath` in pi's settings.json to a bash.exe, " +
135
+ "or install Git for Windows, which brings Git Bash: https://git-scm.com/download/win",
136
+ "error",
137
+ );
138
+ }
139
+
119
140
  // Not awaited: pi awaits what a handler returns, so the start would wait for the backend.
120
141
  void warnIfTuiTooOld(ctx);
121
142
  });
@@ -153,6 +174,21 @@ function isBelowPiSubagentsFloor(sourceInfo: SourceInfo): boolean {
153
174
  return differing !== -1 && installed[differing] < PI_SUBAGENTS_FLOOR[differing];
154
175
  }
155
176
 
177
+ /**
178
+ * Whether pi's own Bash lookup — the one its `bash` tool runs — finds a Bash: the user's `shellPath`
179
+ * when it is set, otherwise Git Bash under `Program Files`, then a `bash.exe` on `PATH`. pi exports
180
+ * it for extensions. pi expands `~` and `/c/…` in `shellPath` before its own lookup, and this check
181
+ * does not, so a `shellPath` written that way reads here as missing.
182
+ */
183
+ function piFindsBash(shellPath: string | undefined): boolean {
184
+ try {
185
+ getShellConfig(shellPath);
186
+ return true;
187
+ } catch {
188
+ return false;
189
+ }
190
+ }
191
+
156
192
  /** The problem `type` of the backend's refusal of a TUI older than its minimum (Task 15d.7a). */
157
193
  const TUI_TOO_OLD = "/problems/tui-too-old";
158
194
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fito-tui",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Fito for pi: case-based practice for software engineers, in your terminal.",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -26,8 +26,8 @@
26
26
  "build": "tsc -p tsconfig.build.json",
27
27
  "lint": "tsc --noEmit && npm run build",
28
28
  "prepare": "npm run build",
29
- "test": "FITO_URL=http://127.0.0.1:9 node --test agents/*.test.ts extensions/*.test.ts prompts/*.test.ts skills/*/*.test.ts shared/*/*.test.ts",
30
- "test:coverage": "FITO_URL=http://127.0.0.1:9 node --test --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=tap --test-reporter-destination=tui-tap.txt --test-reporter=lcov --test-reporter-destination=lcov.info agents/*.test.ts extensions/*.test.ts prompts/*.test.ts skills/*/*.test.ts shared/*/*.test.ts"
29
+ "test": "node --import ./test-env.ts --test \"agents/*.test.ts\" \"extensions/*.test.ts\" \"prompts/*.test.ts\" \"skills/*/*.test.ts\" \"shared/*/*.test.ts\"",
30
+ "test:coverage": "node --import ./test-env.ts --test --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=tap --test-reporter-destination=tui-tap.txt --test-reporter=lcov --test-reporter-destination=lcov.info \"agents/*.test.ts\" \"extensions/*.test.ts\" \"prompts/*.test.ts\" \"skills/*/*.test.ts\" \"shared/*/*.test.ts\""
31
31
  },
32
32
  "dependencies": {
33
33
  "yaml": "2.9.0",
@@ -6,7 +6,7 @@ Refresh the learner's Fito access token.
6
6
  Use the `fito-auth` skill (read its `SKILL.md`), then run:
7
7
 
8
8
  ```bash
9
- node <fito-auth skill dir>/auth-refresh.js
9
+ node "<fito-auth skill dir>/auth-refresh.js"
10
10
  ```
11
11
 
12
12
  This exchanges the stored refresh token for a fresh token pair via the backend