fito-tui 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/agents/fito-performance-reviewer.md +6 -5
  2. package/extensions/fito-startup.js +27 -3
  3. package/extensions/fito-startup.ts +39 -7
  4. package/package.json +3 -3
  5. package/prompts/fito-auth-refresh.md +1 -1
  6. package/prompts/fito-case-edit.md +2 -2
  7. package/prompts/fito-case-generate.md +1 -1
  8. package/prompts/fito-case-open.md +6 -5
  9. package/prompts/fito-create-or-update-competence.md +2 -2
  10. package/prompts/fito-create-or-update-technology.md +5 -5
  11. package/prompts/fito-delete-competence.md +2 -2
  12. package/prompts/fito-evaluate.md +30 -22
  13. package/prompts/fito-login.md +3 -3
  14. package/prompts/fito-logout.md +1 -1
  15. package/prompts/fito-publish-case.md +3 -3
  16. package/prompts/fito-push-knowledge.md +1 -1
  17. package/prompts/fito-submit.md +55 -36
  18. package/skills/fito-auth/SKILL.md +8 -7
  19. package/skills/fito-auth/browser.js +3 -2
  20. package/skills/fito-auth/browser.ts +3 -2
  21. package/skills/fito-auth/login.js +22 -6
  22. package/skills/fito-auth/login.ts +23 -6
  23. package/skills/fito-case-author/SKILL.md +4 -4
  24. package/skills/fito-case-author/checkout.js +22 -5
  25. package/skills/fito-case-author/checkout.ts +22 -5
  26. package/skills/fito-case-runner/SKILL.md +24 -7
  27. package/skills/fito-case-runner/github.js +20 -2
  28. package/skills/fito-case-runner/github.ts +21 -2
  29. package/skills/fito-case-runner/open.js +3 -3
  30. package/skills/fito-case-runner/open.ts +3 -3
  31. package/skills/fito-case-runner/runner.js +12 -1
  32. package/skills/fito-case-runner/runner.ts +15 -0
  33. package/skills/fito-case-runner/submit.js +1 -1
  34. package/skills/fito-case-runner/submit.ts +1 -1
  35. package/skills/fito-case-runner/temp-file.js +16 -0
  36. package/skills/fito-case-runner/temp-file.ts +17 -0
  37. package/skills/fito-competence-write/SKILL.md +3 -3
  38. package/skills/fito-competence-write/delete.js +1 -1
  39. package/skills/fito-competence-write/delete.ts +1 -1
  40. package/skills/fito-evaluator/SKILL.md +7 -6
  41. package/skills/fito-evaluator/criterion-exec.js +113 -17
  42. package/skills/fito-evaluator/criterion-exec.ts +110 -18
  43. package/skills/fito-evaluator/evaluate-automated.js +7 -3
  44. package/skills/fito-evaluator/evaluate-automated.ts +7 -3
  45. package/skills/fito-knowledge-push/SKILL.md +1 -1
  46. package/skills/fito-knowledge-push/push.js +8 -8
  47. package/skills/fito-knowledge-push/push.ts +8 -8
  48. package/skills/fito-source-ingestion/SKILL.md +4 -4
  49. package/skills/fito-technology-write/SKILL.md +2 -2
  50. package/skills/fito-technology-write/create.js +2 -2
  51. package/skills/fito-technology-write/create.ts +2 -2
@@ -9,27 +9,27 @@ Fito. Drive the steps below in order.
9
9
  If no case id was given, ask the learner for it first — the case's UUID, the same
10
10
  id they opened with `/fito-case-open` — and don't run anything until you have it.
11
11
 
12
- The submit step pushes whatever is **committed** on the case's working branch, so
13
- first make sure their work is committed. If there are uncommitted changes in
14
- `~/.fito/cases/$1/`, tell the learner to commit them on the working branch before
15
- continuing.
16
-
17
12
  ## 1. Record the submission (push + open the PR)
18
13
 
19
14
  Use the `fito-case-runner` skill (read its `SKILL.md`), then run:
20
15
 
21
16
  ```bash
22
- node <fito-case-runner skill dir>/submit.js $1
17
+ node "<fito-case-runner skill dir>/submit.js" $1
23
18
  ```
24
19
 
25
20
  This pushes the working branch to the learner's fork, opens a pull request against
26
- the case's submission target branch, and records the submission with Fito. Stream
27
- the output. It is safe to re-run: it reuses an already-open PR and re-recording the
28
- same PR is idempotent.
21
+ the case's submission target branch, and records the submission with Fito. It pushes
22
+ only what is **committed**, so it first refuses a checkout with work that is not.
23
+ Stream the output. It is safe to re-run: it reuses an already-open PR and
24
+ re-recording the same PR is idempotent.
29
25
 
30
26
  **Note the submission id** it prints (`Submission recorded with Fito (id: <uuid>)`) —
31
27
  you need it in step 4.
32
28
 
29
+ - If it reports changes that are not committed, nothing was pushed. Relay the files
30
+ it lists, and tell the learner to commit them on the working branch — or delete
31
+ the ones that are not part of their work — then re-run `/fito-submit $1`. Stop
32
+ here until they do.
33
33
  - If it reports the PR is open but recording the submission failed, the PR is on
34
34
  GitHub but Fito did not record it — have the learner re-run `/fito-submit $1`,
35
35
  which reuses the PR and retries the record.
@@ -49,18 +49,20 @@ you need it in step 4.
49
49
  Use the `fito-evaluator` skill (read its `SKILL.md`), then run:
50
50
 
51
51
  ```bash
52
- node <fito-evaluator skill dir>/evaluate-automated.js $1
52
+ node "<fito-evaluator skill dir>/evaluate-automated.js" $1
53
53
  ```
54
54
 
55
- Stream the output. In `~/.fito/cases/$1/` it runs the automated criteria's commands
56
- and the hybrid criteria's gate commands, and prints one **evaluation report**: the
57
- automated evidence, the `ai` criteria + their prompt hints, the `hybrid` gate
58
- evidence, and any `human` criteria under **Needs human review**.
55
+ Stream the output. In the case's checkout it runs the automated criteria's commands
56
+ and the hybrid criteria's gate commands, and prints one **evaluation report**. Its
57
+ first line, `Case checkout: <path>`, is the checkout's absolute path: every later
58
+ step uses that path, exactly as printed. Then come the automated evidence, the `ai`
59
+ criteria + their prompt hints, the `hybrid` gate evidence, and any `human` criteria
60
+ under **Needs human review**.
59
61
 
60
62
  If the report has **no scorable criteria** (nothing automated, ai, or hybrid), there
61
63
  is no rubric to score — skip the rubric steps (3–4) and go straight to the quiz
62
- (step 5). If there is also no `~/.fito/cases/$1/.case/quiz.yaml`, tell the learner
63
- the submission is recorded but has nothing to score, and stop. (The PR and
64
+ (step 5). If the checkout also has no `.case/quiz.yaml`, tell the learner the
65
+ submission is recorded but has nothing to score, and stop. (The PR and
64
66
  submission from step 1 still stand.)
65
67
 
66
68
  ## 3. Score the report
@@ -69,8 +71,8 @@ Delegate to the `fito-performance-reviewer` **subagent** via the `fito_delegate`
69
71
  tool. Hand it **both**:
70
72
 
71
73
  - the **full evaluation report** from step 2, and
72
- - the **case checkout path** `~/.fito/cases/$1/`, which it needs to score the `ai`
73
- and `hybrid` criteria from the learner's actual changes.
74
+ - the **case checkout path** from the report's first line, which it needs to score
75
+ the `ai` and `hybrid` criteria from the learner's actual changes.
74
76
 
75
77
  It returns, as a fenced ```json array, one object per criterion —
76
78
  `criterionId`, `knowledgeComponent`, `bloomLevel`, `evaluationType`, `score`
@@ -84,12 +86,17 @@ This delegation blocks — you read the child's summary from the tool result.
84
86
  ## 4. Record the evaluation with Fito
85
87
 
86
88
  Save the subagent's JSON array **exactly as returned** (just the array from the
87
- fenced ```json block) to a temporary file outside the checkout — e.g. write it to
88
- `$(mktemp)` and note the path — the submission id from step 1 and that path are the
89
- two arguments:
89
+ fenced ```json block) to a new temp file. Get the file's path with:
90
90
 
91
91
  ```bash
92
- node <fito-case-runner skill dir>/submit-evaluation.js <submission-id> <results-file>
92
+ node "<fito-case-runner skill dir>/temp-file.js"
93
+ ```
94
+
95
+ Write the array to the path it prints, exactly as printed. The submission id from
96
+ step 1 and that path are the two arguments:
97
+
98
+ ```bash
99
+ node "<fito-case-runner skill dir>/submit-evaluation.js" <submission-id> "<results-file>"
93
100
  ```
94
101
 
95
102
  This POSTs the scores to Fito (`POST /submissions/{id}/results`), which records the
@@ -106,7 +113,7 @@ submission's results, so re-running `/fito-submit $1` re-evaluates and re-record
106
113
 
107
114
  ## 5. Administer and record the quiz (if the case has one)
108
115
 
109
- If `~/.fito/cases/$1/.case/quiz.yaml` exists, the case has a knowledge-check quiz;
116
+ If the checkout has a `.case/quiz.yaml`, the case has a knowledge-check quiz;
110
117
  administer, score, and record it against the submission from step 1. If the file is
111
118
  absent, skip this step.
112
119
 
@@ -117,31 +124,43 @@ absent, skip this step.
117
124
  for scoring only. Collect the learner's `multiple_choice` answers as a
118
125
  `{ "<questionId>": "<choiceId>" }` map, and hold their `short_answer` /
119
126
  `code_snippet` answers for the reviewer.
120
- 2. **Score the `multiple_choice` questions in code.** Write the MC answers map to a
121
- temp file (e.g. `$(mktemp)`), then run:
127
+ 2. **Score the `multiple_choice` questions in code.** Get a new temp file's path
128
+ with:
122
129
 
123
130
  ```bash
124
- node <fito-case-runner skill dir>/score-quiz-mc.js $1 <answers-file>
131
+ node "<fito-case-runner skill dir>/temp-file.js"
132
+ ```
133
+
134
+ Write the MC answers map to the path it prints, exactly as printed, then run:
135
+
136
+ ```bash
137
+ node "<fito-case-runner skill dir>/score-quiz-mc.js" $1 "<answers-file>"
125
138
  ```
126
139
 
127
140
  Capture its JSON array of scored `multiple_choice` questions (`[]` if the quiz
128
141
  has none).
129
142
  3. **Score the `short_answer` / `code_snippet` questions via the reviewer.** If the
130
143
  quiz has any, delegate to the `fito-performance-reviewer` **subagent** via
131
- the `fito_delegate` tool, handing it the **case checkout path**
132
- `~/.fito/cases/$1/` (it reads `.case/quiz.yaml` — including the `evaluation`
133
- block — itself) and the **learner's answers** to those questions, keyed by
134
- question id. It returns, as a fenced ```json array, one object per question —
144
+ the `fito_delegate` tool, handing it the **case checkout path** from the report's
145
+ first line (it reads `.case/quiz.yaml` — including the `evaluation` block —
146
+ itself) and the **learner's answers** to those questions, keyed by question
147
+ id. It returns, as a fenced ```json array, one object per question —
135
148
  `questionId`, `knowledgeComponents`, `bloomLevel`, `score` (0–3, or `null` for a
136
149
  question needing human review), and `justification`. Do not score anything yourself.
137
150
  This delegation blocks — you read the child's summary from the tool result.
138
151
  4. **Record the quiz result with Fito.** Merge the code-scored (step 2) and
139
- reviewer-scored (step 3) questions into one JSON array of per-question scores,
140
- write it to a temp file outside the checkout (e.g. `$(mktemp)`) — the submission id
141
- from step 1 and that path are the two arguments:
152
+ reviewer-scored (step 3) questions into one JSON array of per-question scores.
153
+ Get a new temp file's path with:
154
+
155
+ ```bash
156
+ node "<fito-case-runner skill dir>/temp-file.js"
157
+ ```
158
+
159
+ Write the array to the path it prints, exactly as printed. The submission id from
160
+ step 1 and that path are the two arguments:
142
161
 
143
162
  ```bash
144
- node <fito-case-runner skill dir>/submit-quiz-result.js <submission-id> <scores-file>
163
+ node "<fito-case-runner skill dir>/submit-quiz-result.js" <submission-id> "<scores-file>"
145
164
  ```
146
165
 
147
166
  This POSTs to `POST /submissions/{id}/quiz-result`, which records the scores,
@@ -166,7 +185,7 @@ and, if you administered a quiz (step 5), the `knowledgeComponents` of every que
166
185
  in the merged quiz array you recorded — then run:
167
186
 
168
187
  ```bash
169
- node <fito-case-runner skill dir>/case-component-names.js $1 <component-id...>
188
+ node "<fito-case-runner skill dir>/case-component-names.js" $1 <component-id...>
170
189
  ```
171
190
 
172
191
  passing those ids. It prints one `<id>\t<label>` line per id, where `<label>` is
@@ -182,7 +201,7 @@ component names could not be resolved (the backend may be unavailable).
182
201
  Get Fito's address, for the links in the summary:
183
202
 
184
203
  ```bash
185
- node <fito-case-runner skill dir>/fito-url.js
204
+ node "<fito-case-runner skill dir>/fito-url.js"
186
205
  ```
187
206
 
188
207
  Then relay the subagent's **learner-facing summary** — one block per criterion: the
@@ -10,9 +10,10 @@ allowed-tools: bash
10
10
  # Fito Auth
11
11
 
12
12
  Handles the browser-based login handoff and the token store: one credentials file
13
- per Fito, `~/.fito/credentials-<host>` (file mode `0600`, dir `0700`). Backend
14
- access goes through the `fito-api` client (ADR-003); this skill never sees a
15
- password — the browser performs the login and hands back only the token pair.
13
+ per Fito, `~/.fito/credentials-<host>` (off Windows, file mode `0600` and dir
14
+ `0700`). Backend access goes through the `fito-api` client (ADR-003); this skill
15
+ never sees a password — the browser performs the login and hands back only the
16
+ token pair.
16
17
 
17
18
  Run the commands from wherever you are — each one below names this
18
19
  skill's directory itself.
@@ -20,7 +21,7 @@ skill's directory itself.
20
21
  ## Log in
21
22
 
22
23
  ```bash
23
- node <fito-auth skill dir>/login.js
24
+ node "<fito-auth skill dir>/login.js"
24
25
  ```
25
26
 
26
27
  Starts a loopback server on an ephemeral port, opens the system browser to Fito's
@@ -32,7 +33,7 @@ auth flow (email/password or "Continue with GitHub") in the browser.
32
33
  ## Log out
33
34
 
34
35
  ```bash
35
- node <fito-auth skill dir>/logout.js
36
+ node "<fito-auth skill dir>/logout.js"
36
37
  ```
37
38
 
38
39
  Best-effort revokes the refresh token server-side, then deletes this Fito's
@@ -41,7 +42,7 @@ credentials file. Idempotent — succeeds even when not logged in.
41
42
  ## Refresh
42
43
 
43
44
  ```bash
44
- node <fito-auth skill dir>/auth-refresh.js
45
+ node "<fito-auth skill dir>/auth-refresh.js"
45
46
  ```
46
47
 
47
48
  Exchanges the stored refresh token for a fresh token pair via `POST /auth/refresh`
@@ -55,7 +56,7 @@ and rewrites this Fito's credentials file. Fails if not logged in.
55
56
  | `browser.ts` | Per-platform system-browser launcher |
56
57
  | `login.ts` / `logout.ts` / `auth-refresh.ts` | CLI entrypoints (above) |
57
58
 
58
- The credentials store (read/write/delete, `0600`, Zod-validated) lives in the
59
+ The credentials store (read/write/delete, Zod-validated) lives in the
59
60
  shared [`fito-session`](../../shared/fito-session/credentials.ts) module, reused by `fito-case-runner`.
60
61
 
61
62
  See [the fito-api client](../../shared/fito-api/README.md) for how backend calls are made.
@@ -5,8 +5,9 @@ export function browserOpenCommand(platform, url) {
5
5
  case "darwin":
6
6
  return { command: "open", args: [url] };
7
7
  case "win32":
8
- // `start` is a cmd builtin; the empty "" is the (required) window-title arg.
9
- return { command: "cmd", args: ["/c", "start", "", url] };
8
+ // No shell: `cmd /c start` cut the URL at its first `&`, losing the port and the handoff
9
+ // secret (Phase 17a, finding 1). pi's own browser opener uses this form.
10
+ return { command: "rundll32", args: ["url.dll,FileProtocolHandler", url] };
10
11
  default:
11
12
  return { command: "xdg-open", args: [url] };
12
13
  }
@@ -20,8 +20,9 @@ export function browserOpenCommand(platform: Platform, url: string): BrowserComm
20
20
  case "darwin":
21
21
  return { command: "open", args: [url] };
22
22
  case "win32":
23
- // `start` is a cmd builtin; the empty "" is the (required) window-title arg.
24
- return { command: "cmd", args: ["/c", "start", "", url] };
23
+ // No shell: `cmd /c start` cut the URL at its first `&`, losing the port and the handoff
24
+ // secret (Phase 17a, finding 1). pi's own browser opener uses this form.
25
+ return { command: "rundll32", args: ["url.dll,FileProtocolHandler", url] };
25
26
  default:
26
27
  return { command: "xdg-open", args: [url] };
27
28
  }
@@ -2,9 +2,11 @@
2
2
  * `/fito-login` CLI entrypoint. Starts a loopback server, opens the system
3
3
  * browser to the web `/auth/login?return_to=tui&port=<port>` page, waits for the
4
4
  * browser to POST the freshly minted token pair back, and writes it to this Fito's
5
- * `~/.fito/credentials-<host>` (0600). Run from this skill's directory: `node login.js`.
5
+ * `~/.fito/credentials-<host>` (0600 off Windows). Run from this skill's directory: `node login.js`.
6
6
  */
7
7
  import * as crypto from "node:crypto";
8
+ import * as path from "node:path";
9
+ import { fileURLToPath } from "node:url";
8
10
  import { openBrowser } from "./browser.js";
9
11
  import { startCallbackServer } from "./callback-server.js";
10
12
  import { credentialsFileName, writeCredentials } from "../../shared/fito-session/credentials.js";
@@ -13,6 +15,15 @@ import { fitoUrl } from "../../shared/fito-url/fito-url.js";
13
15
  const WEB_ORIGIN = fitoUrl();
14
16
  /** How long to wait for the browser handoff before giving up. */
15
17
  const TIMEOUT_MS = 5 * 60 * 1000;
18
+ /**
19
+ * The line printed once the credentials are saved. It names the file mode off Windows only: there
20
+ * `chmod` sets no mode, and the user folder's own access list protects the file (Phase 17a,
21
+ * findings 12 and 13).
22
+ */
23
+ export function loginSuccessMessage(fileName, platform = process.platform) {
24
+ const mode = platform === "win32" ? "" : " (mode 0600)";
25
+ return `✓ Logged in. Credentials saved to ~/.fito/${fileName}${mode}.`;
26
+ }
16
27
  async function main() {
17
28
  // Single-use secret binding this login to the browser handoff: the page must echo it
18
29
  // back, so a malicious page that guesses the loopback port cannot inject tokens.
@@ -26,13 +37,18 @@ async function main() {
26
37
  const tokens = await server.waitForTokens();
27
38
  const credentials = { ...tokens, savedAt: new Date().toISOString() };
28
39
  writeCredentials(credentials);
29
- console.log(`✓ Logged in. Credentials saved to ~/.fito/${credentialsFileName()} (mode 0600).`);
40
+ console.log(loginSuccessMessage(credentialsFileName()));
30
41
  }
31
42
  finally {
32
43
  server.close();
33
44
  }
34
45
  }
35
- main().catch((error) => {
36
- console.error(`✗ Login failed: ${error instanceof Error ? error.message : String(error)}`);
37
- process.exitCode = 1;
38
- });
46
+ /** Only auto-invoke the CLI when run directly (`node login.js`), not when imported. */
47
+ const entry = process.argv[1];
48
+ const isMainModule = !!entry && path.resolve(entry) === fileURLToPath(import.meta.url);
49
+ if (isMainModule) {
50
+ main().catch((error) => {
51
+ console.error(`✗ Login failed: ${error instanceof Error ? error.message : String(error)}`);
52
+ process.exitCode = 1;
53
+ });
54
+ }
@@ -2,9 +2,11 @@
2
2
  * `/fito-login` CLI entrypoint. Starts a loopback server, opens the system
3
3
  * browser to the web `/auth/login?return_to=tui&port=<port>` page, waits for the
4
4
  * browser to POST the freshly minted token pair back, and writes it to this Fito's
5
- * `~/.fito/credentials-<host>` (0600). Run from this skill's directory: `node login.js`.
5
+ * `~/.fito/credentials-<host>` (0600 off Windows). Run from this skill's directory: `node login.js`.
6
6
  */
7
7
  import * as crypto from "node:crypto";
8
+ import * as path from "node:path";
9
+ import { fileURLToPath } from "node:url";
8
10
 
9
11
  import { openBrowser } from "./browser.ts";
10
12
  import { startCallbackServer } from "./callback-server.ts";
@@ -16,6 +18,16 @@ const WEB_ORIGIN = fitoUrl();
16
18
  /** How long to wait for the browser handoff before giving up. */
17
19
  const TIMEOUT_MS = 5 * 60 * 1000;
18
20
 
21
+ /**
22
+ * The line printed once the credentials are saved. It names the file mode off Windows only: there
23
+ * `chmod` sets no mode, and the user folder's own access list protects the file (Phase 17a,
24
+ * findings 12 and 13).
25
+ */
26
+ export function loginSuccessMessage(fileName: string, platform: NodeJS.Platform = process.platform): string {
27
+ const mode = platform === "win32" ? "" : " (mode 0600)";
28
+ return `✓ Logged in. Credentials saved to ~/.fito/${fileName}${mode}.`;
29
+ }
30
+
19
31
  async function main(): Promise<void> {
20
32
  // Single-use secret binding this login to the browser handoff: the page must echo it
21
33
  // back, so a malicious page that guesses the loopback port cannot inject tokens.
@@ -31,13 +43,18 @@ async function main(): Promise<void> {
31
43
  const tokens = await server.waitForTokens();
32
44
  const credentials: Credentials = { ...tokens, savedAt: new Date().toISOString() };
33
45
  writeCredentials(credentials);
34
- console.log(`✓ Logged in. Credentials saved to ~/.fito/${credentialsFileName()} (mode 0600).`);
46
+ console.log(loginSuccessMessage(credentialsFileName()));
35
47
  } finally {
36
48
  server.close();
37
49
  }
38
50
  }
39
51
 
40
- main().catch((error: unknown) => {
41
- console.error(`✗ Login failed: ${error instanceof Error ? error.message : String(error)}`);
42
- process.exitCode = 1;
43
- });
52
+ /** Only auto-invoke the CLI when run directly (`node login.js`), not when imported. */
53
+ const entry = process.argv[1];
54
+ const isMainModule = !!entry && path.resolve(entry) === fileURLToPath(import.meta.url);
55
+ if (isMainModule) {
56
+ main().catch((error: unknown) => {
57
+ console.error(`✗ Login failed: ${error instanceof Error ? error.message : String(error)}`);
58
+ process.exitCode = 1;
59
+ });
60
+ }
@@ -21,7 +21,7 @@ skill's directory itself.
21
21
  ## Validate a case working directory
22
22
 
23
23
  ```bash
24
- node <fito-case-author skill dir>/validate.js <case-working-dir>
24
+ node "<fito-case-author skill dir>/validate.js" "<case-working-dir>"
25
25
  ```
26
26
 
27
27
  `<case-working-dir>` is the case repo root (the directory containing `.case/`). Runs the shared
@@ -56,7 +56,7 @@ at publish (Task 3.3), and git tag/branch reachability is the backend ping — n
56
56
  ## Publish a case
57
57
 
58
58
  ```bash
59
- node <fito-case-author skill dir>/publish.js <case-working-dir> --repo <owner>/<name> --overview <file> [--case-id <uuid>] [--accept-gh-mismatch]
59
+ node "<fito-case-author skill dir>/publish.js" "<case-working-dir>" --repo <owner>/<name> --overview "<file>" [--case-id <uuid>] [--accept-gh-mismatch]
60
60
  ```
61
61
 
62
62
  Takes a **finished** case tree (source work done, solution branch built, everything committed) and
@@ -90,7 +90,7 @@ published case (updating published cases is the version publish below — their
90
90
  ## Check a published case out for editing
91
91
 
92
92
  ```bash
93
- node <fito-case-author skill dir>/checkout.js <case-id> [--dir <target>]
93
+ node "<fito-case-author skill dir>/checkout.js" <case-id> [--dir "<target>"]
94
94
  ```
95
95
 
96
96
  The beginning of the update workflow (ADR-009), driven by `/fito-case-edit`: a **direct clone**
@@ -116,7 +116,7 @@ refusal was relayed, verbatim, with its named route.
116
116
  ## Publish a new version of a published case
117
117
 
118
118
  ```bash
119
- node <fito-case-author skill dir>/publish-version.js <case-working-dir> --change-description <file> --overview <file>
119
+ node "<fito-case-author skill dir>/publish-version.js" "<case-working-dir>" --change-description "<file>" --overview "<file>"
120
120
  ```
121
121
 
122
122
  The end of the update workflow (ADR-009), driven by `/fito-publish-case` from an **edited,
@@ -25,12 +25,29 @@ import { parseGithubHttpsUrl } from "../../shared/github-url/parse.js";
25
25
  import { ghCurrentLoginCommand } from "./github-publish.js";
26
26
  import { gateStatus } from "./status-gate.js";
27
27
  /**
28
- * `git clone --branch main <url> <dir>` — the direct authoring clone. The explicit `--branch main`
29
- * is the Task 9.7 contract (the publish flow lands every case repo's development branch as `main`);
30
- * a repo somehow missing it fails loudly here instead of landing on an arbitrary default branch.
28
+ * `git clone -c core.autocrlf=input -c core.longpaths=true --branch main <url> <dir>` — the direct
29
+ * authoring clone. The explicit `--branch main` is the Task 9.7 contract (the publish flow lands
30
+ * every case repo's development branch as `main`); a repo somehow missing it fails loudly here
31
+ * instead of landing on an arbitrary default branch. The two keys are the learner's clone's
32
+ * (`fito-case-runner`'s `gitCloneCommand`, which says why): on Windows they give LF files, store a
33
+ * script an editor wrote with CRLF as LF, so it still runs for a Linux learner, and lift the
34
+ * 260-character path limit.
31
35
  */
32
36
  export function gitCloneMainCommand(repoUrl, targetDir) {
33
- return { command: "git", args: ["clone", "--branch", "main", repoUrl, targetDir] };
37
+ return {
38
+ command: "git",
39
+ args: [
40
+ "clone",
41
+ "-c",
42
+ "core.autocrlf=input",
43
+ "-c",
44
+ "core.longpaths=true",
45
+ "--branch",
46
+ "main",
47
+ repoUrl,
48
+ targetDir,
49
+ ],
50
+ };
34
51
  }
35
52
  /** Fetch case → status gate → guard the target dir → direct clone of main → ownership check → orient. */
36
53
  export async function runCheckout(options) {
@@ -115,7 +132,7 @@ export async function runCheckout(options) {
115
132
  const reason = error instanceof Error ? error.message : String(error);
116
133
  structuralWarning =
117
134
  `The checked-out .case/ tree does not read cleanly (${reason.trimEnd()})\n` +
118
- ` Run the validator before editing further: node validate.js ${targetDir}`;
135
+ ` Run the validator before editing further: node "validate.js" "${targetDir}"`;
119
136
  }
120
137
  return {
121
138
  caseId: options.caseId,
@@ -69,12 +69,29 @@ export interface RunCheckoutResult {
69
69
  }
70
70
 
71
71
  /**
72
- * `git clone --branch main <url> <dir>` — the direct authoring clone. The explicit `--branch main`
73
- * is the Task 9.7 contract (the publish flow lands every case repo's development branch as `main`);
74
- * a repo somehow missing it fails loudly here instead of landing on an arbitrary default branch.
72
+ * `git clone -c core.autocrlf=input -c core.longpaths=true --branch main <url> <dir>` — the direct
73
+ * authoring clone. The explicit `--branch main` is the Task 9.7 contract (the publish flow lands
74
+ * every case repo's development branch as `main`); a repo somehow missing it fails loudly here
75
+ * instead of landing on an arbitrary default branch. The two keys are the learner's clone's
76
+ * (`fito-case-runner`'s `gitCloneCommand`, which says why): on Windows they give LF files, store a
77
+ * script an editor wrote with CRLF as LF, so it still runs for a Linux learner, and lift the
78
+ * 260-character path limit.
75
79
  */
76
80
  export function gitCloneMainCommand(repoUrl: string, targetDir: string): ShellCommand {
77
- return { command: "git", args: ["clone", "--branch", "main", repoUrl, targetDir] };
81
+ return {
82
+ command: "git",
83
+ args: [
84
+ "clone",
85
+ "-c",
86
+ "core.autocrlf=input",
87
+ "-c",
88
+ "core.longpaths=true",
89
+ "--branch",
90
+ "main",
91
+ repoUrl,
92
+ targetDir,
93
+ ],
94
+ };
78
95
  }
79
96
 
80
97
  /** Fetch case → status gate → guard the target dir → direct clone of main → ownership check → orient. */
@@ -168,7 +185,7 @@ export async function runCheckout(options: RunCheckoutOptions): Promise<RunCheck
168
185
  const reason = error instanceof Error ? error.message : String(error);
169
186
  structuralWarning =
170
187
  `The checked-out .case/ tree does not read cleanly (${reason.trimEnd()})\n` +
171
- ` Run the validator before editing further: node validate.js ${targetDir}`;
188
+ ` Run the validator before editing further: node "validate.js" "${targetDir}"`;
172
189
  }
173
190
 
174
191
  return {
@@ -9,7 +9,7 @@ allowed-tools: bash
9
9
 
10
10
  # Fito Case Runner
11
11
 
12
- Run the scripts with `node <file>.js`. Both take the case's backend UUID and use a fixed
12
+ Run the scripts with `node "<file>.js"`. Both take the case's backend UUID and use a fixed
13
13
  per-case checkout at `~/.fito/cases/<case-id>/`, so open and submit always agree on the location.
14
14
 
15
15
  ## Prerequisites
@@ -26,7 +26,7 @@ per-case checkout at `~/.fito/cases/<case-id>/`, so open and submit always agree
26
26
  ## Open a case
27
27
 
28
28
  ```bash
29
- node <fito-case-runner skill dir>/open.js <case-id>
29
+ node "<fito-case-runner skill dir>/open.js" <case-id>
30
30
  ```
31
31
 
32
32
  `<case-id>` is the backend case UUID (cases carry no human-readable slug). Fetches the case, forks
@@ -57,20 +57,24 @@ attempt, the plain run stops (removing its own clone) and prints the two re-run
57
57
  and re-run with the **learner's** pick:
58
58
 
59
59
  ```bash
60
- node <fito-case-runner skill dir>/open.js <case-id> --resume # continue the previous attempt (keeps its commits + open PR)
61
- node <fito-case-runner skill dir>/open.js <case-id> --start-over # discard it — deletes the fork branch, closing its PR
60
+ node "<fito-case-runner skill dir>/open.js" <case-id> --resume # continue the previous attempt (keeps its commits + open PR)
61
+ node "<fito-case-runner skill dir>/open.js" <case-id> --start-over # discard it — deletes the fork branch, closing its PR
62
62
  ```
63
63
 
64
64
  ## Submit a case
65
65
 
66
66
  ```bash
67
- node <fito-case-runner skill dir>/submit.js <case-id>
67
+ node "<fito-case-runner skill dir>/submit.js" <case-id>
68
68
  ```
69
69
 
70
70
  Commit your work on the student branch first. Pushes that branch to the fork, opens a pull request
71
71
  against `submission.target_branch`, then **records the submission with the backend** (`POST
72
72
  /submissions`) so it can be evaluated.
73
73
 
74
+ The push carries commits only, so it first refuses — pushing nothing — a checkout with changes
75
+ that are not committed: changed files and new ones, not what `.gitignore` lists. It prints them;
76
+ relay them, and the learner commits them (or deletes the ones that are not their work) and re-runs.
77
+
74
78
  Before pushing, it confirms the **Fito-linked ↔ `gh`-authenticated** GitHub account match (Task 5.4):
75
79
  it refuses (creating no PR, recording nothing) if you are not logged in to Fito, if your Fito account
76
80
  has no linked GitHub identity, or if your local `gh` account differs from the linked one — with a
@@ -87,7 +91,7 @@ previous attempt) fails with guidance to re-open with `--resume`/`--start-over`
87
91
  ## Resolve knowledge-component names (for feedback)
88
92
 
89
93
  ```bash
90
- node <fito-case-runner skill dir>/case-component-names.js <case-id> <component-id...>
94
+ node "<fito-case-runner skill dir>/case-component-names.js" <case-id> <component-id...>
91
95
  ```
92
96
 
93
97
  Resolves the canonical **names** of the given knowledge components for the `/fito-submit` and
@@ -99,12 +103,24 @@ rubric-only component. Pass the distinct `knowledgeComponent` ids from the revie
99
103
  ## Print Fito's address (for feedback links)
100
104
 
101
105
  ```bash
102
- node <fito-case-runner skill dir>/fito-url.js
106
+ node "<fito-case-runner skill dir>/fito-url.js"
103
107
  ```
104
108
 
105
109
  Prints one line: the address `/fito-submit` and `/fito-evaluate` put in front of each
106
110
  `/knowledge/...` link.
107
111
 
112
+ ## Get a temp file's path (for a JSON file a script reads)
113
+
114
+ ```bash
115
+ node "<fito-case-runner skill dir>/temp-file.js"
116
+ ```
117
+
118
+ Makes a new folder under the system temp folder and prints one line: the path of a file in it,
119
+ written with `/`. Write the JSON there and pass the same path, quoted, to `submit-evaluation.js`,
120
+ `score-quiz-mc.js` or `submit-quiz-result.js`. Use the path exactly as printed: Git Bash, Node and
121
+ your file tools all read it as the same file — on Windows a `/tmp/…` path names two different ones.
122
+ Run it once per file.
123
+
108
124
  ## Files
109
125
 
110
126
  | File | Role |
@@ -116,6 +132,7 @@ Prints one line: the address `/fito-submit` and `/fito-evaluate` put in front of
116
132
  | `case-detail.ts` | Fetch the case pointer + map API errors |
117
133
  | `case-component-names.ts` | Resolve KC names for feedback — fetch case detail, label each id `name (id)` (id fallback) |
118
134
  | `fito-url.ts` | Print Fito's address — the prefix of the feedback's `/knowledge/...` links |
135
+ | `temp-file.ts` | Print a new temp file's path, with `/` — where a JSON file for a script goes |
119
136
  | `report.ts` | Render the malformed-case backstop report |
120
137
  | — | The real `gh`/`git` executor is the shared `../../shared/shell-exec/exec.ts` (ADR-006) |
121
138
  | `workdir.ts` | Resolve `~/.fito/cases/<case-id>/` |
@@ -55,9 +55,20 @@ export function ghCurrentLoginCommand() {
55
55
  export function forkCloneUrl(login, repo) {
56
56
  return `https://github.com/${login}/${repo}.git`;
57
57
  }
58
- /** `git clone <url> <dir>` — clone the fork into the explicit per-case working directory. */
58
+ /**
59
+ * `git clone -c core.autocrlf=input -c core.longpaths=true <url> <dir>` — clone the fork into the
60
+ * explicit per-case working directory. Git for Windows checks files out with CRLF, which can break a
61
+ * case's shell script in a rubric command, and refuses a path over 260 characters (Phase 17a,
62
+ * finding 7 and N2). `input` checks out LF and stores a CRLF file as LF at commit; `longpaths` lifts
63
+ * the limit and means nothing elsewhere. `git clone -c` stores both keys in the new repository, so
64
+ * every later git command there keeps them. The author's clone carries the same two keys
65
+ * (`fito-case-author`'s `gitCloneMainCommand`).
66
+ */
59
67
  export function gitCloneCommand(cloneUrl, targetDir) {
60
- return { command: "git", args: ["clone", cloneUrl, targetDir] };
68
+ return {
69
+ command: "git",
70
+ args: ["clone", "-c", "core.autocrlf=input", "-c", "core.longpaths=true", cloneUrl, targetDir],
71
+ };
61
72
  }
62
73
  /**
63
74
  * `git remote add upstream <case-repo-url>` — wire the upstream case repo into the fork clone
@@ -137,6 +148,13 @@ export function gitDeleteRemoteBranchCommand(studentBranch) {
137
148
  export function isDivergedPush(message) {
138
149
  return /non-fast-forward|fetch first|! \[rejected\]/i.test(message);
139
150
  }
151
+ /**
152
+ * `git status --porcelain` — the submit guard's view of what is not committed: changed files and
153
+ * new ones, but not what `.gitignore` lists. Every line blocks a submit (Task 17a.2).
154
+ */
155
+ export function gitStatusPorcelainCommand() {
156
+ return { command: "git", args: ["status", "--porcelain"] };
157
+ }
140
158
  /** `git push -u origin <studentBranch>` — publish the student branch to the fork. */
141
159
  export function gitPushCommand(studentBranch) {
142
160
  return { command: "git", args: ["push", "-u", "origin", studentBranch] };