fito-tui 0.2.1 → 0.3.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 +2 -86
- package/package.json +4 -4
- package/prompts/fito-evaluate.md +10 -5
- package/prompts/fito-push-knowledge.md +61 -65
- package/prompts/fito-submit.md +7 -2
- package/shared/competences/competence-list.js +1 -1
- package/shared/competences/competence-list.ts +1 -1
- package/shared/fito-api/README.md +1 -1
- package/shared/fito-api/client.js +7 -11
- package/shared/fito-api/client.ts +8 -12
- package/shared/fito-url/fito-url.js +29 -0
- package/shared/fito-url/fito-url.ts +32 -0
- package/shared/knowledge-components/knowledge-fetch.js +1 -1
- package/shared/knowledge-components/knowledge-fetch.ts +1 -1
- package/shared/knowledge-components/knowledge-search.js +1 -1
- package/shared/knowledge-components/knowledge-search.ts +1 -1
- package/shared/knowledge-components/technology-fetch.js +1 -1
- package/shared/knowledge-components/technology-fetch.ts +1 -1
- package/{skills/fito-case-author → shared/semver}/semver.js +8 -0
- package/{skills/fito-case-author → shared/semver}/semver.ts +9 -0
- package/skills/fito-auth/SKILL.md +3 -10
- package/skills/fito-auth/login.js +3 -2
- package/skills/fito-auth/login.ts +3 -2
- package/skills/fito-case-author/SKILL.md +1 -3
- package/skills/fito-case-author/publish-version.js +4 -4
- package/skills/fito-case-author/publish-version.ts +6 -6
- package/skills/fito-case-author/publish.js +4 -4
- package/skills/fito-case-author/publish.ts +6 -6
- package/skills/fito-case-runner/SKILL.md +10 -6
- package/skills/fito-case-runner/case-component-names.ts +1 -1
- package/skills/fito-case-runner/fito-url.js +8 -0
- package/skills/fito-case-runner/fito-url.ts +9 -0
- package/skills/fito-case-runner/open.ts +1 -1
- package/skills/fito-competence-write/SKILL.md +0 -6
- package/skills/fito-knowledge-push/SKILL.md +55 -76
- package/skills/fito-knowledge-push/push.js +169 -77
- package/skills/fito-knowledge-push/push.ts +210 -84
- package/skills/fito-source-ingestion/SKILL.md +0 -6
- package/skills/fito-source-ingestion/authoring-check.ts +1 -1
- package/skills/fito-technology-write/SKILL.md +0 -6
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
* 422 refuse exactly the same version bumps. The guard matters locally because the push precedes
|
|
5
5
|
* the API call: the current version is always the chain's maximum, so a strictly-greater new
|
|
6
6
|
* version is guaranteed not to collide with (and force-move) any published frozen ref.
|
|
7
|
+
*
|
|
8
|
+
* The knowledge push uses the same grammar and precedence for a supersede's revision label, which
|
|
9
|
+
* must be newer than the revision it replaces. Shared here because a skill cannot import another
|
|
10
|
+
* skill's files.
|
|
7
11
|
*/
|
|
8
12
|
|
|
9
13
|
/** SemVer 2.0.0 grammar with capture groups: major, minor, patch, optional pre-release (build metadata matched, ignored). */
|
|
@@ -37,6 +41,11 @@ function compareIdentifiers(a: string, b: string): number {
|
|
|
37
41
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
38
42
|
}
|
|
39
43
|
|
|
44
|
+
/** Whether [version] is a SemVer 2.0.0 string — the precondition of every comparison below. */
|
|
45
|
+
export function isSemVer(version: string): boolean {
|
|
46
|
+
return SEMVER_GRAMMAR.test(version);
|
|
47
|
+
}
|
|
48
|
+
|
|
40
49
|
/** SemVer 2.0.0 precedence: negative when `a < b`, zero when equal (build metadata ignored), positive when `a > b`. */
|
|
41
50
|
export function compareSemVerPrecedence(a: string, b: string): number {
|
|
42
51
|
const left = parseSemVer(a);
|
|
@@ -17,22 +17,15 @@ hands back only the token pair.
|
|
|
17
17
|
Run the commands from wherever you are — each one below names this
|
|
18
18
|
skill's directory itself.
|
|
19
19
|
|
|
20
|
-
## Configuration
|
|
21
|
-
|
|
22
|
-
| Env var | Default | Purpose |
|
|
23
|
-
|---|---|---|
|
|
24
|
-
| `FITO_WEB_ORIGIN` | `http://localhost:5173` | Web origin hosting the login page |
|
|
25
|
-
| `FITO_API_BASE_URL` | `http://localhost:8080` | Backend origin (used by logout/refresh) |
|
|
26
|
-
|
|
27
20
|
## Log in
|
|
28
21
|
|
|
29
22
|
```bash
|
|
30
23
|
node <fito-auth skill dir>/login.js
|
|
31
24
|
```
|
|
32
25
|
|
|
33
|
-
Starts a loopback server on an ephemeral port, opens the system browser to
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
Starts a loopback server on an ephemeral port, opens the system browser to Fito's
|
|
27
|
+
`/auth/login?return_to=tui&port=<port>` page, and waits for the browser to POST the
|
|
28
|
+
freshly minted token pair back. On success it writes
|
|
36
29
|
`~/.fito/credentials` and prints a confirmation. The learner can complete either
|
|
37
30
|
auth flow (email/password or "Continue with GitHub") in the browser.
|
|
38
31
|
|
|
@@ -8,8 +8,9 @@ import * as crypto from "node:crypto";
|
|
|
8
8
|
import { openBrowser } from "./browser.js";
|
|
9
9
|
import { startCallbackServer } from "./callback-server.js";
|
|
10
10
|
import { writeCredentials } from "../../shared/fito-session/credentials.js";
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
import { fitoUrl } from "../../shared/fito-url/fito-url.js";
|
|
12
|
+
/** Web origin hosting the login page: the address of the Fito this TUI uses. */
|
|
13
|
+
const WEB_ORIGIN = fitoUrl();
|
|
13
14
|
/** How long to wait for the browser handoff before giving up. */
|
|
14
15
|
const TIMEOUT_MS = 5 * 60 * 1000;
|
|
15
16
|
async function main() {
|
|
@@ -9,9 +9,10 @@ import * as crypto from "node:crypto";
|
|
|
9
9
|
import { openBrowser } from "./browser.ts";
|
|
10
10
|
import { startCallbackServer } from "./callback-server.ts";
|
|
11
11
|
import { type Credentials, writeCredentials } from "../../shared/fito-session/credentials.ts";
|
|
12
|
+
import { fitoUrl } from "../../shared/fito-url/fito-url.ts";
|
|
12
13
|
|
|
13
|
-
/** Web origin hosting the login page
|
|
14
|
-
const WEB_ORIGIN =
|
|
14
|
+
/** Web origin hosting the login page: the address of the Fito this TUI uses. */
|
|
15
|
+
const WEB_ORIGIN = fitoUrl();
|
|
15
16
|
/** How long to wait for the browser handoff before giving up. */
|
|
16
17
|
const TIMEOUT_MS = 5 * 60 * 1000;
|
|
17
18
|
|
|
@@ -156,9 +156,7 @@ registrations — it never guesses which case the checkout is).
|
|
|
156
156
|
|
|
157
157
|
| Env var | Default | Purpose |
|
|
158
158
|
|---|---|---|
|
|
159
|
-
| `FITO_API_BASE_URL` | `http://localhost:8080` | Backend origin (registry writes + session) |
|
|
160
159
|
| `FITO_PUBLISH_GITHUB_OWNER` | *(unset — falls back to the `gh` login)* | Default repo owner (e.g. an org) for a bare `--repo <name>` |
|
|
161
|
-
| `FITO_WEB_ORIGIN` | `http://localhost:5173` | The web origin used in the printed case URL |
|
|
162
160
|
|
|
163
161
|
## Files
|
|
164
162
|
|
|
@@ -170,10 +168,10 @@ registrations — it never guesses which case the checkout is).
|
|
|
170
168
|
| `publish-version.ts` | CLI entrypoint — `runPublishVersion` core: validate → staleness guards → origin route → frozen-set preflight → push → `POST /cases/{id}/versions`; `--probe` resolves initial vs update |
|
|
171
169
|
| `publish-payload.ts` | Pure `.case/` → register/publish/version wire-payload mapping (+ publish facts) |
|
|
172
170
|
| `github-publish.ts` | Pure `gh`/`git` command builders (repo create, explicit-refspec push, guards) |
|
|
173
|
-
| `semver.ts` | SemVer 2.0.0 precedence — the strictly-greater pre-push guard (mirrors the backend `SemVerPrecedence`) |
|
|
174
171
|
| `status-gate.ts` | One home for the case-status policy (ADR-009): the status → allow/refuse/hint mapping behind `checkout.ts`, `runPublishVersion`, and the probe's deprecated route |
|
|
175
172
|
| `publish-state.ts` | `~/.fito/publish-state.json` — the draft-id retry store |
|
|
176
173
|
| — | The real `gh`/`git` executor is the shared `../../shared/shell-exec/exec.ts` (ADR-006) |
|
|
174
|
+
| — | The strictly-greater SemVer guard is the shared `../../shared/semver/semver.ts` (mirrors the backend `SemVerPrecedence`) |
|
|
177
175
|
|
|
178
176
|
See [the `.case/` validator](../../shared/case-validation/) for the ruleset itself and
|
|
179
177
|
[the fito-api client](../../shared/fito-api/README.md) for the registry endpoints.
|
|
@@ -31,11 +31,12 @@ import { fileURLToPath } from "node:url";
|
|
|
31
31
|
import { manifestSchema } from "../../shared/case-validation/case-schema.js";
|
|
32
32
|
import { FitoApiError, createFitoApiClient } from "../../shared/fito-api/client.js";
|
|
33
33
|
import { resolveFitoSession } from "../../shared/fito-session/session.js";
|
|
34
|
+
import { fitoApiUrl, fitoUrl } from "../../shared/fito-url/fito-url.js";
|
|
34
35
|
import { parseGithubUrl } from "../../shared/github-url/parse.js";
|
|
35
36
|
import { gitFetchOriginTagsCommand, gitListLocalBranchCommand, gitPushCaseRefsCommand, gitStatusPorcelainCommand, withoutAuthoringHarnessPaths, } from "./github-publish.js";
|
|
36
37
|
import { buildCaseVersionPayload, readCasePublishFacts } from "./publish-payload.js";
|
|
37
38
|
import { PublishRejectedError, reconcileSolutionBranchCase, validateOrThrow } from "./publish.js";
|
|
38
|
-
import { isStrictlyGreaterSemVer } from "
|
|
39
|
+
import { isStrictlyGreaterSemVer } from "../../shared/semver/semver.js";
|
|
39
40
|
import { deprecatedRefusal, gateStatus } from "./status-gate.js";
|
|
40
41
|
/** `git remote get-url origin` — the checkout's origin URL (the authoring-check mechanism, duplicated per ADR-006's single-skill corollary). */
|
|
41
42
|
export function gitOriginUrlCommand() {
|
|
@@ -115,7 +116,7 @@ export async function runPublishVersion(options) {
|
|
|
115
116
|
const caseDir = path.resolve(options.caseDir);
|
|
116
117
|
const home = options.home ?? os.homedir();
|
|
117
118
|
const env = options.env ?? process.env;
|
|
118
|
-
const client = options.client ?? createFitoApiClient();
|
|
119
|
+
const client = options.client ?? createFitoApiClient({ baseUrl: fitoApiUrl(env) });
|
|
119
120
|
const exec = options.exec ?? (await import("../../shared/shell-exec/exec.js")).shellExec;
|
|
120
121
|
const run = (command) => exec(command, { cwd: caseDir });
|
|
121
122
|
if (!existsSync(path.join(caseDir, ".case"))) {
|
|
@@ -199,7 +200,6 @@ export async function runPublishVersion(options) {
|
|
|
199
200
|
// here, after the POST, rather than after the push: before the POST a failure tells the author to
|
|
200
201
|
// re-run, and a re-run re-cuts the same unregistered refs, so refreshing them would be noise.
|
|
201
202
|
const refreshWarning = await refreshLocalRepoView(run);
|
|
202
|
-
const webOrigin = env.FITO_WEB_ORIGIN ?? "http://localhost:5173";
|
|
203
203
|
return {
|
|
204
204
|
caseId: response.id,
|
|
205
205
|
status: response.status,
|
|
@@ -209,7 +209,7 @@ export async function runPublishVersion(options) {
|
|
|
209
209
|
versionRef: response.versionRef,
|
|
210
210
|
caseReconciled,
|
|
211
211
|
title: facts.title,
|
|
212
|
-
webUrl: `${
|
|
212
|
+
webUrl: `${fitoUrl(env)}/cases/${response.id}`,
|
|
213
213
|
...(refreshWarning === undefined ? {} : { refreshWarning }),
|
|
214
214
|
};
|
|
215
215
|
}
|
|
@@ -33,6 +33,7 @@ import { manifestSchema } from "../../shared/case-validation/case-schema.ts";
|
|
|
33
33
|
import { FitoApiError, createFitoApiClient } from "../../shared/fito-api/client.ts";
|
|
34
34
|
import type { FitoApiClient, PublishCaseVersionInput } from "../../shared/fito-api/client.ts";
|
|
35
35
|
import { resolveFitoSession } from "../../shared/fito-session/session.ts";
|
|
36
|
+
import { fitoApiUrl, fitoUrl } from "../../shared/fito-url/fito-url.ts";
|
|
36
37
|
import { parseGithubUrl } from "../../shared/github-url/parse.ts";
|
|
37
38
|
import type { Executor, ShellCommand } from "../../shared/shell-exec/exec.ts";
|
|
38
39
|
import {
|
|
@@ -44,7 +45,7 @@ import {
|
|
|
44
45
|
} from "./github-publish.ts";
|
|
45
46
|
import { buildCaseVersionPayload, readCasePublishFacts } from "./publish-payload.ts";
|
|
46
47
|
import { PublishRejectedError, reconcileSolutionBranchCase, validateOrThrow } from "./publish.ts";
|
|
47
|
-
import { isStrictlyGreaterSemVer } from "
|
|
48
|
+
import { isStrictlyGreaterSemVer } from "../../shared/semver/semver.ts";
|
|
48
49
|
import { deprecatedRefusal, gateStatus } from "./status-gate.ts";
|
|
49
50
|
|
|
50
51
|
/** Spawns one `{command, args}` in `cwd` and resolves its stdout (the shared `shell-exec` contract). */
|
|
@@ -69,7 +70,7 @@ export interface RunPublishVersionOptions {
|
|
|
69
70
|
/** `--overview`: the author-approved storefront markdown (`.authoring/description-overview.md`). */
|
|
70
71
|
overviewFile: string;
|
|
71
72
|
home?: string;
|
|
72
|
-
/** Environment (
|
|
73
|
+
/** Environment (FITO_URL); defaults to `process.env`. */
|
|
73
74
|
env?: Record<string, string | undefined>;
|
|
74
75
|
client?: VersionPublishClient;
|
|
75
76
|
exec?: Executor;
|
|
@@ -86,7 +87,7 @@ export interface RunPublishVersionResult {
|
|
|
86
87
|
/** Whether the solution branch's `.case/` had diverged and was reconciled before the push (Task 9a.7). */
|
|
87
88
|
caseReconciled: boolean;
|
|
88
89
|
title: string;
|
|
89
|
-
/** The case's web address
|
|
90
|
+
/** The case's web address, under Fito's — where the new version is now served. */
|
|
90
91
|
webUrl: string;
|
|
91
92
|
/**
|
|
92
93
|
* Set when the best-effort post-publish refresh failed (Task 12a.8, F58) — the version itself is
|
|
@@ -202,7 +203,7 @@ export async function runPublishVersion(options: RunPublishVersionOptions): Prom
|
|
|
202
203
|
const caseDir = path.resolve(options.caseDir);
|
|
203
204
|
const home = options.home ?? os.homedir();
|
|
204
205
|
const env = options.env ?? process.env;
|
|
205
|
-
const client = options.client ?? createFitoApiClient();
|
|
206
|
+
const client = options.client ?? createFitoApiClient({ baseUrl: fitoApiUrl(env) });
|
|
206
207
|
const exec = options.exec ?? (await import("../../shared/shell-exec/exec.ts")).shellExec;
|
|
207
208
|
const run = (command: ShellCommand): Promise<string> => exec(command, { cwd: caseDir });
|
|
208
209
|
|
|
@@ -316,7 +317,6 @@ export async function runPublishVersion(options: RunPublishVersionOptions): Prom
|
|
|
316
317
|
// re-run, and a re-run re-cuts the same unregistered refs, so refreshing them would be noise.
|
|
317
318
|
const refreshWarning = await refreshLocalRepoView(run);
|
|
318
319
|
|
|
319
|
-
const webOrigin = env.FITO_WEB_ORIGIN ?? "http://localhost:5173";
|
|
320
320
|
return {
|
|
321
321
|
caseId: response.id,
|
|
322
322
|
status: response.status,
|
|
@@ -326,7 +326,7 @@ export async function runPublishVersion(options: RunPublishVersionOptions): Prom
|
|
|
326
326
|
versionRef: response.versionRef,
|
|
327
327
|
caseReconciled,
|
|
328
328
|
title: facts.title,
|
|
329
|
-
webUrl: `${
|
|
329
|
+
webUrl: `${fitoUrl(env)}/cases/${response.id}`,
|
|
330
330
|
...(refreshWarning === undefined ? {} : { refreshWarning }),
|
|
331
331
|
};
|
|
332
332
|
}
|
|
@@ -23,8 +23,9 @@ import * as path from "node:path";
|
|
|
23
23
|
import { fileURLToPath } from "node:url";
|
|
24
24
|
import { loadCaseDir } from "../../shared/case-validation/case-loader.js";
|
|
25
25
|
import { validateCaseContent } from "../../shared/case-validation/case-schema.js";
|
|
26
|
-
import {
|
|
26
|
+
import { FitoApiError, createFitoApiClient } from "../../shared/fito-api/client.js";
|
|
27
27
|
import { resolveFitoSession } from "../../shared/fito-session/session.js";
|
|
28
|
+
import { fitoApiUrl, fitoUrl } from "../../shared/fito-url/fito-url.js";
|
|
28
29
|
import { caseRepoHttpsUrl, ghAuthStatusCommand, ghCurrentLoginCommand, ghRepoCreateCommand, ghRepoViewCommand, gitCaseParityDiffCommand, gitCheckoutCommand, gitCommitCaseParityCommand, gitCurrentBranchCommand, gitListLocalBranchCommand, gitPushCaseRefsCommand, gitRestoreCaseDirCommand, gitStatusPorcelainCommand, parseRepoArg, withoutAuthoringHarnessPaths, } from "./github-publish.js";
|
|
29
30
|
import { buildCaseWritePayloads, readCasePublishFacts } from "./publish-payload.js";
|
|
30
31
|
import { clearPublishState, readPublishState, writePublishState } from "./publish-state.js";
|
|
@@ -45,7 +46,7 @@ export async function runPublish(options) {
|
|
|
45
46
|
const caseDir = path.resolve(options.caseDir);
|
|
46
47
|
const home = options.home ?? os.homedir();
|
|
47
48
|
const env = options.env ?? process.env;
|
|
48
|
-
const apiBaseUrl = options.apiBaseUrl ??
|
|
49
|
+
const apiBaseUrl = options.apiBaseUrl ?? fitoApiUrl(env);
|
|
49
50
|
const client = options.client ?? createFitoApiClient({ baseUrl: apiBaseUrl });
|
|
50
51
|
const exec = options.exec ?? (await import("../../shared/shell-exec/exec.js")).shellExec;
|
|
51
52
|
const run = (command) => exec(command, { cwd: caseDir });
|
|
@@ -140,7 +141,6 @@ export async function runPublish(options) {
|
|
|
140
141
|
await publishOnce(client, session.tokens.accessToken, caseId, payloads.publish);
|
|
141
142
|
}
|
|
142
143
|
clearPublishState(repositoryUrl, home);
|
|
143
|
-
const webOrigin = env.FITO_WEB_ORIGIN ?? "http://localhost:5173";
|
|
144
144
|
return {
|
|
145
145
|
caseId,
|
|
146
146
|
status: "PUBLISHED",
|
|
@@ -150,7 +150,7 @@ export async function runPublish(options) {
|
|
|
150
150
|
caseReconciled,
|
|
151
151
|
ghLogin,
|
|
152
152
|
title: facts.title,
|
|
153
|
-
webUrl: `${
|
|
153
|
+
webUrl: `${fitoUrl(env)}/cases/${caseId}`,
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
@@ -25,9 +25,10 @@ import { fileURLToPath } from "node:url";
|
|
|
25
25
|
import { loadCaseDir } from "../../shared/case-validation/case-loader.ts";
|
|
26
26
|
import { validateCaseContent } from "../../shared/case-validation/case-schema.ts";
|
|
27
27
|
import type { Attestation, CaseContent, ValidationError } from "../../shared/case-validation/case-schema.ts";
|
|
28
|
-
import {
|
|
28
|
+
import { FitoApiError, createFitoApiClient } from "../../shared/fito-api/client.ts";
|
|
29
29
|
import type { FitoApiClient } from "../../shared/fito-api/client.ts";
|
|
30
30
|
import { resolveFitoSession } from "../../shared/fito-session/session.ts";
|
|
31
|
+
import { fitoApiUrl, fitoUrl } from "../../shared/fito-url/fito-url.ts";
|
|
31
32
|
import type { Executor } from "../../shared/shell-exec/exec.ts";
|
|
32
33
|
import {
|
|
33
34
|
caseRepoHttpsUrl,
|
|
@@ -70,7 +71,7 @@ export interface RunPublishOptions {
|
|
|
70
71
|
home?: string;
|
|
71
72
|
/** The backend origin — must match the client's; also stamps the retry state. */
|
|
72
73
|
apiBaseUrl?: string;
|
|
73
|
-
/** Environment (FITO_PUBLISH_GITHUB_OWNER,
|
|
74
|
+
/** Environment (FITO_PUBLISH_GITHUB_OWNER, FITO_URL); defaults to `process.env`. */
|
|
74
75
|
env?: Record<string, string | undefined>;
|
|
75
76
|
client?: PublishClient;
|
|
76
77
|
exec?: Executor;
|
|
@@ -87,7 +88,7 @@ export interface RunPublishResult {
|
|
|
87
88
|
caseReconciled: boolean;
|
|
88
89
|
ghLogin: string;
|
|
89
90
|
title: string;
|
|
90
|
-
/** The case's web address
|
|
91
|
+
/** The case's web address, under Fito's — where it is now listed and openable. */
|
|
91
92
|
webUrl: string;
|
|
92
93
|
}
|
|
93
94
|
|
|
@@ -110,7 +111,7 @@ export async function runPublish(options: RunPublishOptions): Promise<RunPublish
|
|
|
110
111
|
const caseDir = path.resolve(options.caseDir);
|
|
111
112
|
const home = options.home ?? os.homedir();
|
|
112
113
|
const env = options.env ?? process.env;
|
|
113
|
-
const apiBaseUrl = options.apiBaseUrl ??
|
|
114
|
+
const apiBaseUrl = options.apiBaseUrl ?? fitoApiUrl(env);
|
|
114
115
|
const client = options.client ?? createFitoApiClient({ baseUrl: apiBaseUrl });
|
|
115
116
|
const exec = options.exec ?? (await import("../../shared/shell-exec/exec.ts")).shellExec;
|
|
116
117
|
const run = (command: ShellCommand): Promise<string> => exec(command, { cwd: caseDir });
|
|
@@ -227,7 +228,6 @@ export async function runPublish(options: RunPublishOptions): Promise<RunPublish
|
|
|
227
228
|
}
|
|
228
229
|
|
|
229
230
|
clearPublishState(repositoryUrl, home);
|
|
230
|
-
const webOrigin = env.FITO_WEB_ORIGIN ?? "http://localhost:5173";
|
|
231
231
|
return {
|
|
232
232
|
caseId,
|
|
233
233
|
status: "PUBLISHED",
|
|
@@ -237,7 +237,7 @@ export async function runPublish(options: RunPublishOptions): Promise<RunPublish
|
|
|
237
237
|
caseReconciled,
|
|
238
238
|
ghLogin,
|
|
239
239
|
title: facts.title,
|
|
240
|
-
webUrl: `${
|
|
240
|
+
webUrl: `${fitoUrl(env)}/cases/${caseId}`,
|
|
241
241
|
};
|
|
242
242
|
}
|
|
243
243
|
|
|
@@ -23,12 +23,6 @@ per-case checkout at `~/.fito/cases/<case-id>/`, so open and submit always agree
|
|
|
23
23
|
the learner's Fito-linked GitHub identity via `GET /me`; open needs no login (the case read is
|
|
24
24
|
public — a logged-in open additionally records participation, see below).
|
|
25
25
|
|
|
26
|
-
## Configuration
|
|
27
|
-
|
|
28
|
-
| Env var | Default | Purpose |
|
|
29
|
-
|---|---|---|
|
|
30
|
-
| `FITO_API_BASE_URL` | `http://localhost:8080` | Backend origin (case lookup) |
|
|
31
|
-
|
|
32
26
|
## Open a case
|
|
33
27
|
|
|
34
28
|
```bash
|
|
@@ -102,6 +96,15 @@ case detail (`GET /cases/{id}` — public, no login) and prints one `<id>\t<labe
|
|
|
102
96
|
id, where `<label>` is `name (id)` for a declared learning objective/prerequisite, or the bare id for a
|
|
103
97
|
rubric-only component. Pass the distinct `knowledgeComponent` ids from the reviewer's results.
|
|
104
98
|
|
|
99
|
+
## Print Fito's address (for feedback links)
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
node <fito-case-runner skill dir>/fito-url.js
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Prints one line: the address `/fito-submit` and `/fito-evaluate` put in front of each
|
|
106
|
+
`/knowledge/...` link.
|
|
107
|
+
|
|
105
108
|
## Files
|
|
106
109
|
|
|
107
110
|
| File | Role |
|
|
@@ -112,6 +115,7 @@ rubric-only component. Pass the distinct `knowledgeComponent` ids from the revie
|
|
|
112
115
|
| `manifest.ts` | Read `submission.target_branch` / `student_branch` and derive the checkout's `versionRef` (the submission's version pin, Task 9.4) from the manifest |
|
|
113
116
|
| `case-detail.ts` | Fetch the case pointer + map API errors |
|
|
114
117
|
| `case-component-names.ts` | Resolve KC names for feedback — fetch case detail, label each id `name (id)` (id fallback) |
|
|
118
|
+
| `fito-url.ts` | Print Fito's address — the prefix of the feedback's `/knowledge/...` links |
|
|
115
119
|
| `report.ts` | Render the malformed-case backstop report |
|
|
116
120
|
| — | The real `gh`/`git` executor is the shared `../../shared/shell-exec/exec.ts` (ADR-006) |
|
|
117
121
|
| `workdir.ts` | Resolve `~/.fito/cases/<case-id>/` |
|
|
@@ -21,7 +21,7 @@ export interface ResolveCaseComponentNamesOptions {
|
|
|
21
21
|
caseId: string;
|
|
22
22
|
/** The component ids to label — the distinct `knowledgeComponent` ids from the reviewer's results. */
|
|
23
23
|
componentIds: string[];
|
|
24
|
-
/** Injectable for tests; defaults to a client reading `
|
|
24
|
+
/** Injectable for tests; defaults to a client reading `FITO_URL`. Only the public case read is used. */
|
|
25
25
|
client?: Pick<FitoApiClient, "getCase">;
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `node fito-url.js` — print the address of the Fito this TUI uses (Task 15d.9a). `/fito-submit`
|
|
3
|
+
* and `/fito-evaluate` run it to make each `/knowledge/...` link in their feedback clickable: a
|
|
4
|
+
* user sets no variable, and the model cannot see an address held in code, so a script hands it
|
|
5
|
+
* over. The address itself lives in `shared/fito-url/`.
|
|
6
|
+
*/
|
|
7
|
+
import { fitoUrl } from "../../shared/fito-url/fito-url.js";
|
|
8
|
+
console.log(fitoUrl());
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `node fito-url.js` — print the address of the Fito this TUI uses (Task 15d.9a). `/fito-submit`
|
|
3
|
+
* and `/fito-evaluate` run it to make each `/knowledge/...` link in their feedback clickable: a
|
|
4
|
+
* user sets no variable, and the model cannot see an address held in code, so a script hands it
|
|
5
|
+
* over. The address itself lives in `shared/fito-url/`.
|
|
6
|
+
*/
|
|
7
|
+
import { fitoUrl } from "../../shared/fito-url/fito-url.ts";
|
|
8
|
+
|
|
9
|
+
console.log(fitoUrl());
|
|
@@ -34,7 +34,7 @@ export interface RunOpenOptions {
|
|
|
34
34
|
home?: string;
|
|
35
35
|
/**
|
|
36
36
|
* Backend client (case fetch, the deprecated-case participant gate — Task 9.6, and the
|
|
37
|
-
* best-effort enrollment record — Task 9.5); defaults to the real one (reads `
|
|
37
|
+
* best-effort enrollment record — Task 9.5); defaults to the real one (reads `FITO_URL`).
|
|
38
38
|
*/
|
|
39
39
|
client?: Pick<FitoApiClient, "getCase" | "meWithRefresh" | "createCaseEnrollment" | "getCaseParticipation">;
|
|
40
40
|
exec?: Executor;
|
|
@@ -27,12 +27,6 @@ itself.
|
|
|
27
27
|
- **The competence's id** — `update.js` and `delete.js` address a competence by it. `create.js` prints
|
|
28
28
|
it, and `fito_competence_list` reports it for every competence a technology demands.
|
|
29
29
|
|
|
30
|
-
## Configuration
|
|
31
|
-
|
|
32
|
-
| Env var | Default | Purpose |
|
|
33
|
-
|---|---|---|
|
|
34
|
-
| `FITO_API_BASE_URL` | `http://localhost:8080` | Backend origin |
|
|
35
|
-
|
|
36
30
|
## Create the competence
|
|
37
31
|
|
|
38
32
|
```bash
|
|
@@ -1,114 +1,93 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: fito-knowledge-push
|
|
3
3
|
description: >
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
or acknowledged override). Driven by /fito-push-knowledge.
|
|
4
|
+
Store generated knowledge component files in Fito — the PUSH step of
|
|
5
|
+
the Fito knowledge pipeline. One file per run; a similar or duplicate
|
|
6
|
+
component stops the push for the author's choice (Link, Supersede,
|
|
7
|
+
Skip, or Create new component). Driven by /fito-push-knowledge.
|
|
9
8
|
allowed-tools: bash
|
|
10
9
|
---
|
|
11
10
|
|
|
12
11
|
# Fito Knowledge Push
|
|
13
12
|
|
|
14
13
|
Run the script from wherever you are — the command below names this
|
|
15
|
-
skill's directory itself. One
|
|
16
|
-
`/fito-push-knowledge` orchestrator loops over the generated files, so every
|
|
17
|
-
|
|
14
|
+
skill's directory itself. One component file per run — the
|
|
15
|
+
`/fito-push-knowledge` orchestrator loops over the generated files, so every store (and every
|
|
16
|
+
stop) is an explicit, per-component action.
|
|
18
17
|
|
|
19
18
|
## Prerequisites
|
|
20
19
|
|
|
21
20
|
- **Fito login** — `/fito-login`. Knowledge writes are bearer-authenticated; the script fails
|
|
22
21
|
with that guidance when no session exists.
|
|
23
|
-
- **Backend reachable**, with the knowledge vocabulary seeded and the
|
|
22
|
+
- **Backend reachable**, with the knowledge vocabulary seeded and the file's technology
|
|
24
23
|
provisioned — every push pulls the registered `Template`s for the component type and the
|
|
25
24
|
technology whose `kind` selects among them.
|
|
26
25
|
|
|
27
|
-
##
|
|
28
|
-
|
|
29
|
-
| Env var | Default | Purpose |
|
|
30
|
-
|---|---|---|
|
|
31
|
-
| `FITO_API_BASE_URL` | `http://localhost:8080` | Backend origin |
|
|
32
|
-
|
|
33
|
-
## Push one payload
|
|
26
|
+
## Store one component file
|
|
34
27
|
|
|
35
28
|
```bash
|
|
36
|
-
node <fito-knowledge-push skill dir>/push.js <
|
|
29
|
+
node <fito-knowledge-push skill dir>/push.js <component-file> [--version <label>]
|
|
37
30
|
```
|
|
38
31
|
|
|
39
|
-
`<
|
|
32
|
+
`<component-file>` is one generator output (`{metadata, content}` JSON, e.g.
|
|
40
33
|
`./output/3-generate/concept_content/1-dependency-injection.json`). The script validates the
|
|
41
|
-
|
|
34
|
+
file's shape, resolves the registered template — by component type and by the technology's `kind`,
|
|
42
35
|
which selects the variant when a type has more than one — maps it onto the write contract
|
|
43
|
-
(`technology`, `templateId`, `name`, `version`, `content`),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
**Done when** it prints `✓ Created <canonical-reference> — "<name>" (version <v>)` — record
|
|
48
|
-
that reference for the flow's final report.
|
|
49
|
-
|
|
50
|
-
## Similar components (advisory probe) — the author decides
|
|
51
|
-
|
|
52
|
-
Before storing, the plain push probes for existing components similar to the payload — including
|
|
53
|
-
genuine near-duplicates *reframed* below the hard duplicate bar, which the 409 gate alone would
|
|
54
|
-
let coexist unseen (the Task 8.6 smoke-run finding). On any match the script exits **non-zero**
|
|
55
|
-
with nothing stored, printing each match with its similarity and the choices:
|
|
36
|
+
(`technology`, `templateId`, `name`, `version`, `content`), runs the **similar-components check**
|
|
37
|
+
(nothing stored yet — see the next section), and POSTs `POST /knowledge/{type}`. `--version`
|
|
38
|
+
labels the component's revision; omitted, the backend defaults `1.0.0`.
|
|
56
39
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
- **skip** — push nothing; move to the next payload.
|
|
60
|
-
- **proceed** — `--proceed`: store an independent component that will **coexist** with the
|
|
61
|
-
matches. This is the author's call after seeing the similarities; a match at the hard duplicate
|
|
62
|
-
bar still rejects the proceed with the near-duplicate 409 and its override echo.
|
|
40
|
+
**Done when** it prints `✓ Stored "<name>" as <reference id> (revision <label>), from
|
|
41
|
+
<component-file>` — record that reference id for the flow's final report.
|
|
63
42
|
|
|
64
|
-
|
|
65
|
-
decision point exactly like the 409.
|
|
43
|
+
## Stops — the author decides
|
|
66
44
|
|
|
67
|
-
|
|
45
|
+
A stop exits **non-zero** with nothing stored. Its message is written for the author and ends at
|
|
46
|
+
the line `--- Commands for the agent ---`: show the author everything above that line word for
|
|
47
|
+
word, ask with exactly the choices it lists, and run the command below the line that matches the
|
|
48
|
+
author's choice. Never pick for the author, and never re-run without their choice.
|
|
68
49
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
- **
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
**skip**: the payload is already in the vocabulary.
|
|
93
|
-
|
|
94
|
-
**Done when** the author's chosen re-run prints `✓ Created …` (or the author chose skip).
|
|
50
|
+
| Stop | Why it stops | Choice → flag |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| **Similar components** | the similar-components check (the backend's near-duplicate probe) found components above the soft similarity floor — including near-duplicates *reframed* below the hard duplicate bar, which the 409 gate alone would let coexist unseen (the Task 8.6 smoke-run finding) | Link `--link`, Supersede `--supersede`, Skip (none), Create new component `--proceed` |
|
|
53
|
+
| **Duplicate** | the backend refused the create as a near-duplicate (409 `duplicateId`) | Link `--link`, Supersede `--supersede`, Skip (none), Create new component `--override` |
|
|
54
|
+
| **Revision label** | a Supersede ran without `--version`, or with a label that is not SemVer or not newer than the target's revision | re-run with the author's label as `--version` |
|
|
55
|
+
| **Newer revision** | the Supersede target already has a successor (409 `supersededBy`) — version chains are linear | re-run `--supersede` against the newest revision |
|
|
56
|
+
|
|
57
|
+
- **Link** stores an alternative definition of the match; **Supersede** stores its next revision.
|
|
58
|
+
Both are preferred over Create new component.
|
|
59
|
+
- **Create new component** stores an independent component that will **coexist** with the match.
|
|
60
|
+
After `--proceed`, a match at the hard duplicate bar still refuses it with the Duplicate stop.
|
|
61
|
+
`--override` echoes the exact reported reference as `overrideAcknowledging` — the false-positive
|
|
62
|
+
escape; a blind or stale echo does not bypass the check.
|
|
63
|
+
- **Supersede** needs a revision label newer than the target's — the backend would otherwise store
|
|
64
|
+
`1.0.0`, the same label as a first revision. The stops' Supersede command carries no label, so
|
|
65
|
+
its first run prints the Revision label stop, which asks the author for one. A target whose own
|
|
66
|
+
revision is not SemVer accepts any SemVer label.
|
|
67
|
+
|
|
68
|
+
**Re-pushing an already-pushed file** (an interrupted or repeated run over the same folder) stops
|
|
69
|
+
on the component created from that very file earlier (same name, matching content). The expected
|
|
70
|
+
choice there is **Skip**: the component is already in Fito.
|
|
71
|
+
|
|
72
|
+
**Done when** the author's chosen re-run prints `✓ Stored …` (or the author chose Skip).
|
|
95
73
|
|
|
96
74
|
## Other failures
|
|
97
75
|
|
|
98
|
-
Malformed
|
|
99
|
-
|
|
100
|
-
|
|
76
|
+
Malformed files, an unknown technology, and field-schema violations (422 — the backend itemizes
|
|
77
|
+
the offending fields) fail with the reason printed (`✗ …`). The script never retries by itself and
|
|
78
|
+
is safe to re-run — each run POSTs at most once.
|
|
101
79
|
|
|
102
|
-
**
|
|
103
|
-
guard on its source), and the flow never edits one to make it pass — a wrong
|
|
104
|
-
|
|
80
|
+
**Component files are read-only inputs.** `push.js` only ever reads them (tripwired by a static
|
|
81
|
+
guard on its source), and the flow never edits one to make it pass — a wrong file is surfaced to
|
|
82
|
+
the author, whose fix is regeneration, not an in-place patch.
|
|
105
83
|
|
|
106
84
|
## Files
|
|
107
85
|
|
|
108
86
|
| File | Role |
|
|
109
87
|
|---|---|
|
|
110
|
-
| `push.ts` | CLI + `runPush` testable core — read/validate
|
|
88
|
+
| `push.ts` | CLI + `runPush` testable core — read/validate the file, resolve session + template, probe, check a supersede's label, POST, render the stops' messages |
|
|
111
89
|
|
|
112
|
-
|
|
90
|
+
File→request mapping and template resolution live in
|
|
113
91
|
[`shared/knowledge-components/push-payload.ts`](../../shared/knowledge-components/push-payload.ts);
|
|
114
|
-
transport in [the fito-api client](../../shared/fito-api/README.md)
|
|
92
|
+
transport in [the fito-api client](../../shared/fito-api/README.md); the SemVer label check in
|
|
93
|
+
[`shared/semver/`](../../shared/semver/semver.ts).
|