fito-tui 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -0
- package/agents/fito-case-source-planner.md +265 -0
- package/agents/fito-performance-reviewer.md +231 -0
- package/agents/fito-practice-concept-content-generator.md +318 -0
- package/agents/fito-practice-concept-identifier.md +482 -0
- package/agents/fito-practice-execution-fact-content-generator.md +299 -0
- package/agents/fito-practice-execution-fact-identifier.md +367 -0
- package/agents/fito-practice-usage-scenario-content-generator.md +331 -0
- package/agents/fito-practice-usage-scenario-identifier.md +397 -0
- package/agents/fito-subagent-selftest.md +27 -0
- package/agents/fito-technology-generator.md +207 -0
- package/agents/fito-tool-concept-content-generator.md +282 -0
- package/agents/fito-tool-concept-identifier.md +384 -0
- package/agents/fito-tool-execution-fact-content-generator.md +382 -0
- package/agents/fito-tool-execution-fact-identifier.md +360 -0
- package/agents/fito-tool-usage-scenario-content-generator.md +381 -0
- package/agents/fito-tool-usage-scenario-identifier.md +432 -0
- package/agents/fito-tutor.md +185 -0
- package/extensions/fito-delegate.js +539 -0
- package/extensions/fito-delegate.ts +691 -0
- package/extensions/fito-fetch-tools.js +380 -0
- package/extensions/fito-fetch-tools.ts +419 -0
- package/extensions/fito-startup.js +166 -0
- package/extensions/fito-startup.ts +188 -0
- package/package.json +56 -0
- package/prompts/fito-auth-refresh.md +15 -0
- package/prompts/fito-case-design.md +506 -0
- package/prompts/fito-case-edit.md +91 -0
- package/prompts/fito-case-generate.md +222 -0
- package/prompts/fito-case-open.md +124 -0
- package/prompts/fito-case-plan-source.md +114 -0
- package/prompts/fito-create-or-update-competence.md +261 -0
- package/prompts/fito-create-or-update-technology.md +199 -0
- package/prompts/fito-delete-competence.md +147 -0
- package/prompts/fito-evaluate.md +148 -0
- package/prompts/fito-fetch-urls-content.md +35 -0
- package/prompts/fito-generate-domain-concepts.md +85 -0
- package/prompts/fito-generate-execution-facts.md +85 -0
- package/prompts/fito-generate-usage-scenarios.md +85 -0
- package/prompts/fito-identify-domain-concepts.md +49 -0
- package/prompts/fito-identify-execution-facts.md +49 -0
- package/prompts/fito-identify-usage-scenarios.md +49 -0
- package/prompts/fito-login.md +21 -0
- package/prompts/fito-logout.md +14 -0
- package/prompts/fito-publish-case.md +266 -0
- package/prompts/fito-push-knowledge.md +84 -0
- package/prompts/fito-submit.md +208 -0
- package/prompts/fito-tutor.md +120 -0
- package/shared/case-briefing/briefing.js +221 -0
- package/shared/case-briefing/briefing.ts +261 -0
- package/shared/case-quiz/scoring.js +16 -0
- package/shared/case-quiz/scoring.ts +61 -0
- package/shared/case-validation/case-loader.js +88 -0
- package/shared/case-validation/case-loader.ts +106 -0
- package/shared/case-validation/case-schema.js +716 -0
- package/shared/case-validation/case-schema.ts +895 -0
- package/shared/competences/competence-list.js +29 -0
- package/shared/competences/competence-list.ts +32 -0
- package/shared/fito-api/README.md +192 -0
- package/shared/fito-api/client.js +731 -0
- package/shared/fito-api/client.ts +1426 -0
- package/shared/fito-session/credentials.js +79 -0
- package/shared/fito-session/credentials.ts +88 -0
- package/shared/fito-session/session.js +16 -0
- package/shared/fito-session/session.ts +35 -0
- package/shared/github-url/parse.js +26 -0
- package/shared/github-url/parse.ts +35 -0
- package/shared/knowledge-components/component-names.js +35 -0
- package/shared/knowledge-components/component-names.ts +39 -0
- package/shared/knowledge-components/knowledge-fetch.js +46 -0
- package/shared/knowledge-components/knowledge-fetch.ts +57 -0
- package/shared/knowledge-components/knowledge-search.js +101 -0
- package/shared/knowledge-components/knowledge-search.ts +144 -0
- package/shared/knowledge-components/push-payload.js +104 -0
- package/shared/knowledge-components/push-payload.ts +129 -0
- package/shared/knowledge-components/reference.js +24 -0
- package/shared/knowledge-components/reference.ts +43 -0
- package/shared/knowledge-components/technology-fetch.js +30 -0
- package/shared/knowledge-components/technology-fetch.ts +38 -0
- package/shared/shell-exec/exec.js +22 -0
- package/shared/shell-exec/exec.ts +46 -0
- package/skills/fito-auth/SKILL.md +68 -0
- package/skills/fito-auth/auth-refresh.js +23 -0
- package/skills/fito-auth/auth-refresh.ts +25 -0
- package/skills/fito-auth/browser.js +35 -0
- package/skills/fito-auth/browser.ts +57 -0
- package/skills/fito-auth/callback-server.js +152 -0
- package/skills/fito-auth/callback-server.ts +189 -0
- package/skills/fito-auth/login.js +37 -0
- package/skills/fito-auth/login.ts +42 -0
- package/skills/fito-auth/logout.js +24 -0
- package/skills/fito-auth/logout.ts +25 -0
- package/skills/fito-case-author/SKILL.md +179 -0
- package/skills/fito-case-author/checkout.js +222 -0
- package/skills/fito-case-author/checkout.ts +281 -0
- package/skills/fito-case-author/github-publish.js +218 -0
- package/skills/fito-case-author/github-publish.ts +251 -0
- package/skills/fito-case-author/publish-payload.js +108 -0
- package/skills/fito-case-author/publish-payload.ts +186 -0
- package/skills/fito-case-author/publish-state.js +72 -0
- package/skills/fito-case-author/publish-state.ts +87 -0
- package/skills/fito-case-author/publish-version.js +364 -0
- package/skills/fito-case-author/publish-version.ts +495 -0
- package/skills/fito-case-author/publish.js +284 -0
- package/skills/fito-case-author/publish.ts +394 -0
- package/skills/fito-case-author/semver.js +55 -0
- package/skills/fito-case-author/semver.ts +63 -0
- package/skills/fito-case-author/status-gate.js +34 -0
- package/skills/fito-case-author/status-gate.ts +54 -0
- package/skills/fito-case-author/validate.js +62 -0
- package/skills/fito-case-author/validate.ts +64 -0
- package/skills/fito-case-runner/SKILL.md +119 -0
- package/skills/fito-case-runner/case-component-names.js +45 -0
- package/skills/fito-case-runner/case-component-names.ts +65 -0
- package/skills/fito-case-runner/case-detail.js +20 -0
- package/skills/fito-case-runner/case-detail.ts +20 -0
- package/skills/fito-case-runner/github.js +234 -0
- package/skills/fito-case-runner/github.ts +287 -0
- package/skills/fito-case-runner/manifest.js +56 -0
- package/skills/fito-case-runner/manifest.ts +73 -0
- package/skills/fito-case-runner/open.js +175 -0
- package/skills/fito-case-runner/open.ts +241 -0
- package/skills/fito-case-runner/report.js +22 -0
- package/skills/fito-case-runner/report.ts +24 -0
- package/skills/fito-case-runner/runner.js +158 -0
- package/skills/fito-case-runner/runner.ts +304 -0
- package/skills/fito-case-runner/score-quiz-mc.js +85 -0
- package/skills/fito-case-runner/score-quiz-mc.ts +99 -0
- package/skills/fito-case-runner/submit-evaluation.js +73 -0
- package/skills/fito-case-runner/submit-evaluation.ts +98 -0
- package/skills/fito-case-runner/submit-quiz-result.js +75 -0
- package/skills/fito-case-runner/submit-quiz-result.ts +100 -0
- package/skills/fito-case-runner/submit.js +85 -0
- package/skills/fito-case-runner/submit.ts +111 -0
- package/skills/fito-case-runner/workdir.js +10 -0
- package/skills/fito-case-runner/workdir.ts +11 -0
- package/skills/fito-competence-write/SKILL.md +155 -0
- package/skills/fito-competence-write/create.js +64 -0
- package/skills/fito-competence-write/create.ts +80 -0
- package/skills/fito-competence-write/delete.js +136 -0
- package/skills/fito-competence-write/delete.ts +166 -0
- package/skills/fito-competence-write/display.js +20 -0
- package/skills/fito-competence-write/display.ts +21 -0
- package/skills/fito-competence-write/payload.js +96 -0
- package/skills/fito-competence-write/payload.ts +115 -0
- package/skills/fito-competence-write/update.js +155 -0
- package/skills/fito-competence-write/update.ts +206 -0
- package/skills/fito-evaluator/SKILL.md +73 -0
- package/skills/fito-evaluator/criterion-exec.js +64 -0
- package/skills/fito-evaluator/criterion-exec.ts +73 -0
- package/skills/fito-evaluator/evaluate-automated.js +57 -0
- package/skills/fito-evaluator/evaluate-automated.ts +84 -0
- package/skills/fito-evaluator/evaluate.js +28 -0
- package/skills/fito-evaluator/evaluate.ts +86 -0
- package/skills/fito-evaluator/report.js +112 -0
- package/skills/fito-evaluator/report.ts +128 -0
- package/skills/fito-evaluator/rubric.js +90 -0
- package/skills/fito-evaluator/rubric.ts +170 -0
- package/skills/fito-knowledge-push/SKILL.md +114 -0
- package/skills/fito-knowledge-push/push.js +282 -0
- package/skills/fito-knowledge-push/push.ts +360 -0
- package/skills/fito-source-ingestion/SKILL.md +77 -0
- package/skills/fito-source-ingestion/authoring-check.js +128 -0
- package/skills/fito-source-ingestion/authoring-check.ts +155 -0
- package/skills/fito-source-ingestion/bundle.js +198 -0
- package/skills/fito-source-ingestion/bundle.ts +246 -0
- package/skills/fito-technology-write/SKILL.md +108 -0
- package/skills/fito-technology-write/create.js +134 -0
- package/skills/fito-technology-write/create.ts +161 -0
- package/skills/fito-technology-write/payload.js +64 -0
- package/skills/fito-technology-write/payload.ts +70 -0
- package/skills/fito-technology-write/update.js +122 -0
- package/skills/fito-technology-write/update.ts +171 -0
- package/skills/fito-url-content-fetcher/SKILL.md +213 -0
- package/templates/concept-practice-content-template.md +281 -0
- package/templates/concept-tool-content-template.md +207 -0
- package/templates/execution-fact-practice-content-template.md +372 -0
- package/templates/execution-fact-tool-content-template.md +307 -0
- package/templates/usage-scenario-content-template.md +248 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FitoApiError, createFitoApiClient } from "../fito-api/client.js";
|
|
2
|
+
/**
|
|
3
|
+
* List the competences one technology directly demands, each with its sub-competence tree (Task
|
|
4
|
+
* 15b.6). The single public HTTP read is the `fito_competence_list` custom tool's core: the
|
|
5
|
+
* competence-authoring flow reads what a technology already holds before drafting a new competence,
|
|
6
|
+
* and the author picks the id of one to edit or delete from it. It parallels `fetchTechnology` — the
|
|
7
|
+
* tool's `execute()` stays a thin adapter, and the backend-error mapping (a domain-facing concern,
|
|
8
|
+
* ADR-003/006) lives here rather than in the extension or the transport client.
|
|
9
|
+
*
|
|
10
|
+
* Throws a plain `Error` (clear message) on a 404 (no such technology) or any other backend failure —
|
|
11
|
+
* the tool wrapper lets it propagate so pi marks the call as an error. `options.client` keeps the HTTP
|
|
12
|
+
* boundary injectable for tests; production calls create the shared client per invocation (reading
|
|
13
|
+
* `FITO_API_BASE_URL`) and send no credentials because the read is public.
|
|
14
|
+
*/
|
|
15
|
+
export async function listCompetences(technology, options = {}) {
|
|
16
|
+
const client = options.client ?? createFitoApiClient();
|
|
17
|
+
try {
|
|
18
|
+
return await client.listTechnologyCompetences(technology);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error instanceof FitoApiError && error.status === 404) {
|
|
22
|
+
throw new Error(`No technology found for "${technology}".`);
|
|
23
|
+
}
|
|
24
|
+
if (error instanceof FitoApiError) {
|
|
25
|
+
throw new Error(`Competence list failed (${error.status}): ${error.message}`);
|
|
26
|
+
}
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Competence, type FitoApiClient, FitoApiError, createFitoApiClient } from "../fito-api/client.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* List the competences one technology directly demands, each with its sub-competence tree (Task
|
|
5
|
+
* 15b.6). The single public HTTP read is the `fito_competence_list` custom tool's core: the
|
|
6
|
+
* competence-authoring flow reads what a technology already holds before drafting a new competence,
|
|
7
|
+
* and the author picks the id of one to edit or delete from it. It parallels `fetchTechnology` — the
|
|
8
|
+
* tool's `execute()` stays a thin adapter, and the backend-error mapping (a domain-facing concern,
|
|
9
|
+
* ADR-003/006) lives here rather than in the extension or the transport client.
|
|
10
|
+
*
|
|
11
|
+
* Throws a plain `Error` (clear message) on a 404 (no such technology) or any other backend failure —
|
|
12
|
+
* the tool wrapper lets it propagate so pi marks the call as an error. `options.client` keeps the HTTP
|
|
13
|
+
* boundary injectable for tests; production calls create the shared client per invocation (reading
|
|
14
|
+
* `FITO_API_BASE_URL`) and send no credentials because the read is public.
|
|
15
|
+
*/
|
|
16
|
+
export async function listCompetences(
|
|
17
|
+
technology: string,
|
|
18
|
+
options: { client?: Pick<FitoApiClient, "listTechnologyCompetences"> } = {},
|
|
19
|
+
): Promise<Competence[]> {
|
|
20
|
+
const client = options.client ?? createFitoApiClient();
|
|
21
|
+
try {
|
|
22
|
+
return await client.listTechnologyCompetences(technology);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error instanceof FitoApiError && error.status === 404) {
|
|
25
|
+
throw new Error(`No technology found for "${technology}".`);
|
|
26
|
+
}
|
|
27
|
+
if (error instanceof FitoApiError) {
|
|
28
|
+
throw new Error(`Competence list failed (${error.status}): ${error.message}`);
|
|
29
|
+
}
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Fito API Client
|
|
2
|
+
|
|
3
|
+
The TUI's backend HTTP **transport boundary**: a thin client that mirrors backend REST
|
|
4
|
+
endpoints one method per endpoint, attaches auth, validates every response with Zod, and
|
|
5
|
+
normalises errors into `FitoApiError`. It is **shared code**, not a skill: a pure library
|
|
6
|
+
*imported* by relative path (by `fito-auth` today, and by `shared/knowledge-components/`,
|
|
7
|
+
case-runner, and others going forward), never invoked by the agent. See
|
|
8
|
+
`.ai/architecture_decisions/ADR-006-shared-code-vs-skills.md` for why it lives in
|
|
9
|
+
`tui/shared/` rather than `tui/skills/`.
|
|
10
|
+
|
|
11
|
+
**Scope — transport only.** This client holds **no domain logic**. Issuing one HTTP request,
|
|
12
|
+
mapping one endpoint, or defining a response's wire schema lives *here*. Interpreting,
|
|
13
|
+
composing, or presenting that data — parsing an identifier, turning a 404 into a user-facing
|
|
14
|
+
message, chaining calls into a workflow — lives in a subject folder under `shared/<subject>/`
|
|
15
|
+
that *imports* this client (e.g. `shared/knowledge-components/`). "Single seam" means **all raw
|
|
16
|
+
HTTP** funnels through here, not that all backend-shaped code belongs here.
|
|
17
|
+
|
|
18
|
+
> **Convention (ADR-003).** Every TUI → backend call goes through this one client.
|
|
19
|
+
> **Do not** make ad-hoc `fetch` calls from skills, prompts, or extensions, and
|
|
20
|
+
> **do not** add `axios` — native `fetch` + Zod is the sanctioned transport. This
|
|
21
|
+
> governance rule is documentation, not an agent capability (ADR-006); it is also
|
|
22
|
+
> recorded in `CLAUDE.md`.
|
|
23
|
+
|
|
24
|
+
Per **ADR-003**, the client is built on Node 24's built-in global `fetch`, validates
|
|
25
|
+
every response with **Zod**, normalises the backend's RFC 9457 problem-detail errors
|
|
26
|
+
into `FitoApiError`, and centralises `401 → /auth/refresh → retry`.
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { createFitoApiClient } from "../../shared/fito-api/client.ts";
|
|
32
|
+
|
|
33
|
+
const api = createFitoApiClient(); // baseUrl from FITO_API_BASE_URL (default :8080)
|
|
34
|
+
|
|
35
|
+
await api.refresh(refreshToken); // POST /auth/refresh -> new token pair
|
|
36
|
+
await api.logout(refreshToken); // POST /auth/logout -> revoke
|
|
37
|
+
const user = await api.me(accessToken); // GET /me -> SessionUser (+ linked githubLogin/githubUserId)
|
|
38
|
+
|
|
39
|
+
// GET /me, refreshing transparently on 401 and returning the (possibly new) pair:
|
|
40
|
+
const { user, tokens } = await api.meWithRefresh(storedTokens);
|
|
41
|
+
// user.githubLogin / user.githubUserId are null when no GitHub identity is linked.
|
|
42
|
+
|
|
43
|
+
// GET /knowledge/{type}/{slug} -> one component by (type, slug) (public read, no token):
|
|
44
|
+
const component = await api.getKnowledgeComponent("concept", "git.bisect");
|
|
45
|
+
|
|
46
|
+
// POST /technologies -> create-or-resolve a technology + one major line (bearer; Task 9b.2b):
|
|
47
|
+
// a near-duplicate stops the write with a 409 FitoApiError carrying `matches` — the author
|
|
48
|
+
// resolves it (reuse / distinct slug / override), never the client.
|
|
49
|
+
const written = await api.createOrResolveTechnology(accessToken, createTechnologyInput);
|
|
50
|
+
|
|
51
|
+
// PATCH /technologies/{slug} + /technologies/{slug}/versions/{versionSlug} -> enrich an existing
|
|
52
|
+
// description in place (bearer; Task 9b.4). Two distinct axes: the version-agnostic overview
|
|
53
|
+
// and one major line's prose. `description` is required and non-blank — there is no clear path.
|
|
54
|
+
await api.updateTechnologyDescription(accessToken, "javalin", overview);
|
|
55
|
+
await api.updateTechnologyVersionDescription(accessToken, "javalin", "7", majorLineProse);
|
|
56
|
+
|
|
57
|
+
// GET /technologies/{slug}/competences -> the competences a technology directly demands, each with
|
|
58
|
+
// its sub-competence tree (public read; an unknown slug is a 404, not an empty list — Task 15b.6):
|
|
59
|
+
const competences = await api.listTechnologyCompetences("javalin");
|
|
60
|
+
|
|
61
|
+
// GET /competences/{id} -> one competence with its whole subtree (public read; Task 15b.8 counts the
|
|
62
|
+
// descendants out of it to say what a delete will take):
|
|
63
|
+
const one = await api.getCompetence(competences[0].id);
|
|
64
|
+
|
|
65
|
+
// POST / PATCH / DELETE /competences -> create (curator or admin), edit the name or description
|
|
66
|
+
// (owner or admin), delete with the whole subtree (owner or admin). Bearer; Phase 15b.
|
|
67
|
+
const competence = await api.createCompetence(accessToken, createCompetenceInput);
|
|
68
|
+
await api.updateCompetence(accessToken, competence.id, { name: "Routing fundamentals" });
|
|
69
|
+
await api.deleteCompetence(accessToken, competence.id);
|
|
70
|
+
|
|
71
|
+
// GET /cases/{id} -> the case pointer + resolved references (public read, no token needed;
|
|
72
|
+
// an optional bearer token lets an owner read their own DRAFT — Task 9.7):
|
|
73
|
+
const caseDetail = await api.getCase(caseId);
|
|
74
|
+
// caseDetail.version / caseDetail.changeDescription: the current version's SemVer and its
|
|
75
|
+
// ADR-009 chain note (null on an initial version) — /fito-case-edit's orientation brief.
|
|
76
|
+
|
|
77
|
+
// GET /cases -> the public discovery listing, optionally filtered; the TUI's use is the
|
|
78
|
+
// repositoryUrl lookup: "is this URL a registered case?" (total >= 1 — matches a published
|
|
79
|
+
// OR deprecated case, Task 9.6; drafts never match).
|
|
80
|
+
const page = await api.listCases({ repositoryUrl });
|
|
81
|
+
|
|
82
|
+
// POST /cases -> register a case as a DRAFT with its external-repo pointer (bearer):
|
|
83
|
+
// the backend mints and returns the case UUID; NOT idempotent — reuse the id on retry.
|
|
84
|
+
const draft = await api.registerCase(accessToken, registerInput);
|
|
85
|
+
|
|
86
|
+
// POST /cases/{id}/publish -> the backend publish pipeline (bearer, owner-only): attestation
|
|
87
|
+
// check + reachability ping + reference resolution; rejections are 422 problem details.
|
|
88
|
+
// Each prerequisite ref may carry the author's optional `description` (Task 12a.3) — what the
|
|
89
|
+
// reference means for this case; only prerequisites.yaml supplies one, rubric entries never do.
|
|
90
|
+
const published = await api.publishCase(accessToken, draft.id, publishInput);
|
|
91
|
+
|
|
92
|
+
// POST /cases/{id}/versions -> publish a correction/perfection version of a published case
|
|
93
|
+
// (bearer, owner-only — Task 9.4/9.8): the publish payload + version/versionRef/changeDescription;
|
|
94
|
+
// the reference set is frozen across versions — rejections are 422 problem details.
|
|
95
|
+
const version = await api.publishCaseVersion(accessToken, caseId, versionInput);
|
|
96
|
+
|
|
97
|
+
// GET /cases/{id}/{learning-objectives|prerequisite-components|rubric} -> the stored role-grouped
|
|
98
|
+
// references resolved to names (public reads) — the version-publish preflight's baseline.
|
|
99
|
+
const learningObjectives = await api.getCaseLearningObjectives(caseId);
|
|
100
|
+
const prerequisites = await api.getCasePrerequisites(caseId);
|
|
101
|
+
const rubric = await api.getCaseRubric(caseId);
|
|
102
|
+
|
|
103
|
+
// POST /cases/{id}/enrollments -> record a case open as an enrollment (bearer; idempotent per
|
|
104
|
+
// version — no body, the backend pins the case's current version itself):
|
|
105
|
+
const enrollment = await api.createCaseEnrollment(accessToken, caseId);
|
|
106
|
+
|
|
107
|
+
// GET /cases/{id}/enrollments/me -> is this learner a participant (enrollment OR submission)?
|
|
108
|
+
// Never a 404 — an unknown case reads as false. Gates the open of a deprecated case (Task 9.6):
|
|
109
|
+
const { participant } = await api.getCaseParticipation(accessToken, caseId);
|
|
110
|
+
|
|
111
|
+
// POST /submissions -> record an opened PR as a submission (bearer; idempotent on the PR);
|
|
112
|
+
// versionRef is the checkout's frozen ref — the backend pins the exact case version (Task 9.4):
|
|
113
|
+
const submission = await api.createSubmission(accessToken, { caseId, prUrl, versionRef });
|
|
114
|
+
|
|
115
|
+
// POST /submissions/{id}/results -> record the reviewer's per-criterion scores (bearer):
|
|
116
|
+
// flips the submission to EVALUATED and records proficiency per knowledge component.
|
|
117
|
+
await api.submitEvaluationResults(accessToken, submissionId, { results });
|
|
118
|
+
|
|
119
|
+
// POST /submissions/{id}/quiz-result -> record the quiz's per-question scores (bearer):
|
|
120
|
+
// also flips the submission to EVALUATED (standalone) and records proficiency.
|
|
121
|
+
await api.submitQuizResult(accessToken, submissionId, perQuestionScores);
|
|
122
|
+
|
|
123
|
+
// GET /knowledge/templates/{type} -> the registered templates for a type (public read):
|
|
124
|
+
const templates = await api.getKnowledgeTemplates("concept");
|
|
125
|
+
|
|
126
|
+
// POST /knowledge/{type} -> create-and-publish one component (bearer; dedup-gated):
|
|
127
|
+
// a near-duplicate rejects with a 409 FitoApiError carrying `duplicateId`.
|
|
128
|
+
const created = await api.createKnowledgeComponent(accessToken, "concept", input);
|
|
129
|
+
|
|
130
|
+
// POST /knowledge/{type}/{slug}/alternative-definitions -> the 409 "link" resolution (bearer):
|
|
131
|
+
await api.createAlternativeDefinition(accessToken, "concept", "git.bisect", input);
|
|
132
|
+
|
|
133
|
+
// POST /knowledge/{type}/{slug}/new-version -> the revision path / 409 "supersede" resolution
|
|
134
|
+
// (bearer); a target already superseded rejects with a 409 carrying `supersededBy`.
|
|
135
|
+
await api.createNewVersion(accessToken, "concept", "git.bisect", input);
|
|
136
|
+
|
|
137
|
+
// POST /knowledge/{type}/near-duplicate-probe -> the advisory dedup probe (bearer): embeds the
|
|
138
|
+
// create payload without persisting; matches above the soft threshold, most similar first.
|
|
139
|
+
const matches = await api.probeNearDuplicates(accessToken, "concept", input);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
(The import path above is written from a skill one level under `tui/skills/`, e.g.
|
|
143
|
+
`skills/fito-auth/`; adjust the relative prefix to the importing module's location.)
|
|
144
|
+
|
|
145
|
+
`fetch` is dependency-injected (`createFitoApiClient({ fetch })`) so tests stub it
|
|
146
|
+
directly without an HTTP-mock library.
|
|
147
|
+
|
|
148
|
+
## Endpoints (grows per phase)
|
|
149
|
+
|
|
150
|
+
| Method | Backend | Purpose |
|
|
151
|
+
|---|---|---|
|
|
152
|
+
| `refresh` | `POST /auth/refresh` | Exchange refresh token for a fresh pair |
|
|
153
|
+
| `logout` | `POST /auth/logout` | Revoke a refresh token |
|
|
154
|
+
| `me` | `GET /me` | Authenticated user for an access token (incl. linked `githubLogin`/`githubUserId`, null when unlinked) |
|
|
155
|
+
| `meWithRefresh` | `GET /me` (+ refresh) | `me` with one transparent 401 refresh-retry |
|
|
156
|
+
| `getHealth` | `GET /actuator/health` | Whether the backend is up (no login; writes no `learning_events` row). The startup check calls it for the backend's answer to this TUI's version, and passes a `signal` that bounds the wait (Task 15d.7b) |
|
|
157
|
+
| `getKnowledgeComponent` | `GET /knowledge/{type}/{slug}` | One knowledge component by its canonical id (public read) |
|
|
158
|
+
| `searchKnowledgeComponents` | `GET /knowledge` | List knowledge components, optionally filtered by `type`, `technology` slug, `technologyVersion` slug and free-text `q` (public read; Task 9c.11) — the `{ items }` envelope is unwrapped, an unknown technology is an empty list rather than a 404 (a search, not an existence check), and each item is the full component record **plus** `technologyVersions`, carrying `supersededById` on the same terms as the point read since Task 11.14 — the **chain head**, absent when nothing replaced it, so an absent key means one thing on every endpoint rather than *"nothing replaced it"* here and *"nobody computed it"* there. **`excludeSuperseded` is required and travels on every request, `false` included** (Task 11.4a6-1): it states whether components a newer revision has replaced belong in the answer, and callers genuinely disagree, so no default is offered — an absent one is a 400 (Task 11.4a6-1c). The two parameters name **different axes** and neither is called `version` for that reason: `technologyVersion` is the technology major line a component applies to (picocli `4`), scoped server-side and before any limit, while `excludeSuperseded` acts on the component's own revision |
|
|
159
|
+
| `getTechnology` | `GET /technologies/{slug}` | One technology with its major-line versions and their version-specific prose (public read; ADR-011) — the `TechnologyVersion.description` compatibility facts the design / plan-source steps cross-check the declared toolchain against (9a.6a) |
|
|
160
|
+
| `createOrResolveTechnology` | `POST /technologies` | Create-or-resolve a technology and one major line (bearer; Task 9b.2b, ADR-012): an exact-slug hit reuses the technology (adding the major line when absent), otherwise the two-layer near-duplicate guard may stop the write with a 409 whose `matches` (`reason`: `dedup-key` Layer 1 / `trigram` Layer 2) the author resolves — reuse, a distinct slug, or `override: true` — never the client; the response's `outcome` (`created` 201 / `reused` \| `version-added` 200) reports the branch, narrowed to that closed union so a caller's three-way branch is checked at build time (and `input.technology.kind` is likewise narrowed to `tool`/`practice` — a type, not a runtime check) |
|
|
161
|
+
| `updateTechnologyDescription` | `PATCH /technologies/{slug}` | Replace a technology's **version-agnostic overview** in place (bearer; Task 9b.4 — the create-or-update tail for ADR-011 Decision 2's technology-level field); unknown slug → 404. `description` is required and non-blank: the endpoint is enrichment and has no "clear it" path (blank or absent → 400) |
|
|
162
|
+
| `updateTechnologyVersionDescription` | `PATCH /technologies/{slug}/versions/{versionSlug}` | Replace one **major line's** prose in place (bearer; Task 9b.4) — the other axis of the same tail, independent of the overview; an unknown technology *or* major line → 404; same required non-blank `description` |
|
|
163
|
+
| `listTechnologyCompetences` | `GET /technologies/{slug}/competences` | The competences a technology **directly demands**, name-ordered, each with its sub-competence tree nested in `components` (public read; Task 15b.6) — a sub-competence is never a row of its own, the `{ items }` envelope is unwrapped, and an unknown slug is a 404 rather than an empty list. The wire carries **no owner**, so whether a caller may edit or delete one is answered by the write, as a 403 |
|
|
164
|
+
| `getCompetence` | `GET /competences/{id}` | One competence with its whole sub-competence subtree nested in `components` (public read; Task 15b.8) — an unknown id is a 404, a non-UUID id a 400. It is the read behind the delete's preview: `deleteCompetence` removes the subtree, so what will go is counted here before the write |
|
|
165
|
+
| `createCompetence` | `POST /competences` | Create a top-level competence (bearer, curator or admin; Task 15b.3): `technologySlug`, `name`, optional `description`, and a non-empty list of element references. The caller becomes the owner; a reference naming no component is a 422 whose `detail` lists every one — relayed to the author verbatim |
|
|
166
|
+
| `updateCompetence` | `PATCH /competences/{id}` | Edit the name, the description, or both, in place (bearer, owner or admin; Task 15b.4). A field left out keeps its stored value; elements are frozen, so the payload has no field for them |
|
|
167
|
+
| `deleteCompetence` | `DELETE /competences/{id}` | Delete a competence and every sub-competence beneath it (bearer, owner or admin; Task 15b.5). The 204 carries no body; no learner's recorded proficiency is touched |
|
|
168
|
+
| `getCase` | `GET /cases/{id}` | One case's pointer + resolved references by backend id (public read; an optional bearer token additionally serves the owner's own `DRAFT`, and the detail carries `version` + the nullable `changeDescription` chain note — Task 9.7) |
|
|
169
|
+
| `listCases` | `GET /cases` | The public case-discovery listing, optionally filtered (Task 8.2); the TUI passes only `repositoryUrl` — the "is this URL a registered case?" lookup (`total >= 1`; the URL-filtered request matches a **published or deprecated** case (Task 9.6), drafts never match, and the URL is matched ignoring letter case and a trailing `.git`/`/`) used by `authoring-check.ts`, the publish flow's published-guard, and the version-publish routing (Task 9.8) |
|
|
170
|
+
| `registerCase` | `POST /cases` | Register a case as a `DRAFT` with its external-repo pointer (bearer); mints the case UUID; non-MVP platform/visibility → 422; **not idempotent** — the publish flow persists the minted id for retries (Task 9.3) |
|
|
171
|
+
| `publishCase` | `POST /cases/{id}/publish` | Publish a registered draft (bearer, owner-only): S1 presentation + role-grouped references + optional quiz + structural attestation; the backend pings the repo and resolves every reference — each rejection is a 422 whose problem detail the flow relays verbatim. A `prerequisites` reference carries the author's optional **`description`** (Task 12a.3) alongside `componentId` + `bloomLevel` — it is persisted and rendered under the entry on the case cover, and was dropped on this wire before that task, which is why every stored row held `NULL`; `rubric.yaml` has no criterion-level description, so a rubric entry's is always absent |
|
|
172
|
+
| `publishCaseVersion` | `POST /cases/{id}/versions` | Publish a correction/perfection **version** of a published case (bearer, owner-only; Task 9.4, ADR-009 — the Task 9.8 update flow): the publish payload plus `version`/`versionRef` (exactly `"v" + version`, strictly increasing) and the required `changeDescription`; the reference set is **frozen** across versions on `(componentId, bloomLevel, role)` — each rejection is a 422 relayed verbatim |
|
|
173
|
+
| `getCaseLearningObjectives` / `getCasePrerequisites` / `getCaseRubric` | `GET /cases/{id}/{learning-objectives\|prerequisite-components\|rubric}` | The stored role-grouped references resolved to knowledge-component names (public reads, Task 3.3c) — the baseline the version-publish preflight compares the local `.case/` tree against (Task 9.8) |
|
|
174
|
+
| `createCaseEnrollment` | `POST /cases/{id}/enrollments` | Record a learner's case open as an enrollment (bearer; body-less — the backend pins the case's **current** version; idempotent per `(learner, case, version)`, 201 fresh vs 200 existing; Task 9.5) — posted best-effort by the case-runner after a successful open |
|
|
175
|
+
| `getCaseParticipation` | `GET /cases/{id}/enrollments/me` | Whether the authenticated learner participates in the case — an enrollment **or** a recorded submission exists (bearer, learner-scoped; never a 404 — an unknown case reads `participant: false`, the `submissions/me` existence-hiding precedent; Task 9.6) — gates the case-runner's open of a deprecated case |
|
|
176
|
+
| `createSubmission` | `POST /submissions` | Record an opened PR as a submission (bearer; idempotent on the PR — the backend find-or-creates, returning 200 for an existing row vs 201 for a new one); carries the checkout's `versionRef`, pinning the exact case version the learner solved (Task 9.4) — an unregistered ref is a 422 |
|
|
177
|
+
| `submitEvaluationResults` | `POST /submissions/{id}/results` | Record the reviewer's per-criterion scores for a submission (bearer); flips it to `EVALUATED` and records proficiency per knowledge component |
|
|
178
|
+
| `submitQuizResult` | `POST /submissions/{id}/quiz-result` | Record the quiz's per-question scores for a submission (bearer); flips it to `EVALUATED` standalone (a quiz-only case needs no rubric result) and records proficiency, max-merged with the rubric's |
|
|
179
|
+
| `getKnowledgeTemplates` | `GET /knowledge/templates/{type}` | The registered templates for a component type (public read), version-ascending — the write's `templateId` + field-schema source |
|
|
180
|
+
| `createKnowledgeComponent` | `POST /knowledge/{type}` | Create-and-publish one knowledge component (bearer); a near-duplicate 409 `FitoApiError` carries `duplicateId`, resolved only by an explicit human choice (Task 8.5) |
|
|
181
|
+
| `createAlternativeDefinition` | `POST /knowledge/{type}/{slug}/alternative-definitions` | The 409 "link" resolution — create linked to the target (bearer; dedup-exempt) |
|
|
182
|
+
| `createNewVersion` | `POST /knowledge/{type}/{slug}/new-version` | The revision path / 409 "supersede" resolution — create the target's successor (bearer; dedup-exempt); a superseded target's 409 carries `supersededBy` (the chain head to retarget) |
|
|
183
|
+
| `probeNearDuplicates` | `POST /knowledge/{type}/near-duplicate-probe` | The advisory dedup probe (bearer, Task 8.7): validates + embeds the create payload without persisting, returning `{id, name, version, urlPath, similarity}` matches above the soft threshold — how the push flow surfaces reframed near-duplicates below the hard 409 bar |
|
|
184
|
+
|
|
185
|
+
The write APIs' 409s carry their RFC 9457 resolution properties on the `FitoApiError`
|
|
186
|
+
itself — `error.duplicateId` / `error.supersededBy` (knowledge) and `error.matches`
|
|
187
|
+
(technology) — `undefined` on every other error. `error.type` is the problem's `type` when
|
|
188
|
+
the backend sets one: `/problems/tui-too-old` is the refusal of a TUI older than the
|
|
189
|
+
backend's minimum (Task 15d.7a).
|
|
190
|
+
|
|
191
|
+
At Task 1.5 the client maps only what the TUI calls. New phases add typed,
|
|
192
|
+
Zod-validated functions here — they do not introduce a different HTTP client.
|