fito-tui 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/agents/fito-case-source-planner.md +42 -13
  2. package/agents/fito-performance-reviewer.md +19 -8
  3. package/agents/fito-tutor.md +2 -1
  4. package/extensions/fito-fetch-tools.js +63 -7
  5. package/extensions/fito-fetch-tools.ts +70 -7
  6. package/extensions/fito-startup.js +32 -5
  7. package/extensions/fito-startup.ts +44 -8
  8. package/package.json +3 -3
  9. package/prompts/fito-auth-refresh.md +1 -1
  10. package/prompts/fito-case-design.md +71 -16
  11. package/prompts/fito-case-edit.md +2 -2
  12. package/prompts/fito-case-generate.md +30 -11
  13. package/prompts/fito-case-open.md +20 -12
  14. package/prompts/fito-case-plan-source.md +13 -6
  15. package/prompts/fito-create-or-update-competence.md +2 -2
  16. package/prompts/fito-create-or-update-technology.md +5 -5
  17. package/prompts/fito-delete-competence.md +2 -2
  18. package/prompts/fito-evaluate.md +30 -22
  19. package/prompts/fito-generate-domain-concepts.md +1 -1
  20. package/prompts/fito-generate-execution-facts.md +1 -1
  21. package/prompts/fito-generate-usage-scenarios.md +1 -1
  22. package/prompts/fito-login.md +3 -3
  23. package/prompts/fito-logout.md +1 -1
  24. package/prompts/fito-publish-case.md +3 -3
  25. package/prompts/fito-push-knowledge.md +1 -1
  26. package/prompts/fito-submit.md +55 -36
  27. package/shared/case-briefing/briefing.js +1 -0
  28. package/shared/case-briefing/briefing.ts +1 -0
  29. package/skills/fito-auth/SKILL.md +8 -7
  30. package/skills/fito-auth/browser.js +3 -2
  31. package/skills/fito-auth/browser.ts +3 -2
  32. package/skills/fito-auth/login.js +22 -6
  33. package/skills/fito-auth/login.ts +23 -6
  34. package/skills/fito-case-author/SKILL.md +12 -10
  35. package/skills/fito-case-author/checkout.js +22 -5
  36. package/skills/fito-case-author/checkout.ts +22 -5
  37. package/skills/fito-case-author/github-publish.js +29 -2
  38. package/skills/fito-case-author/github-publish.ts +30 -2
  39. package/skills/fito-case-author/publish.js +36 -3
  40. package/skills/fito-case-author/publish.ts +46 -2
  41. package/skills/fito-case-runner/SKILL.md +24 -7
  42. package/skills/fito-case-runner/github.js +20 -2
  43. package/skills/fito-case-runner/github.ts +21 -2
  44. package/skills/fito-case-runner/open.js +3 -3
  45. package/skills/fito-case-runner/open.ts +3 -3
  46. package/skills/fito-case-runner/runner.js +12 -1
  47. package/skills/fito-case-runner/runner.ts +15 -0
  48. package/skills/fito-case-runner/submit.js +1 -1
  49. package/skills/fito-case-runner/submit.ts +1 -1
  50. package/skills/fito-case-runner/temp-file.js +16 -0
  51. package/skills/fito-case-runner/temp-file.ts +17 -0
  52. package/skills/fito-competence-write/SKILL.md +3 -3
  53. package/skills/fito-competence-write/delete.js +1 -1
  54. package/skills/fito-competence-write/delete.ts +1 -1
  55. package/skills/fito-evaluator/SKILL.md +7 -6
  56. package/skills/fito-evaluator/criterion-exec.js +113 -17
  57. package/skills/fito-evaluator/criterion-exec.ts +110 -18
  58. package/skills/fito-evaluator/evaluate-automated.js +7 -3
  59. package/skills/fito-evaluator/evaluate-automated.ts +7 -3
  60. package/skills/fito-knowledge-push/SKILL.md +1 -1
  61. package/skills/fito-knowledge-push/push.js +8 -8
  62. package/skills/fito-knowledge-push/push.ts +8 -8
  63. package/skills/fito-source-ingestion/SKILL.md +4 -4
  64. package/skills/fito-technology-write/SKILL.md +2 -2
  65. package/skills/fito-technology-write/create.js +2 -2
  66. package/skills/fito-technology-write/create.ts +2 -2
  67. package/skills/fito-url-content-fetcher/SKILL.md +53 -16
@@ -56,9 +56,24 @@ export function ghCurrentLoginCommand(): ShellCommand {
56
56
  return { command: "gh", args: ["api", "user", "--jq", ".login"] };
57
57
  }
58
58
 
59
- /** `gh repo view <slug> --json name` — the existence probe; a re-run must never create a duplicate repo. */
59
+ /**
60
+ * `gh repo view <slug> --json isEmpty` — the existence probe (a re-run must never create a
61
+ * duplicate repo), which also tells whether the repo has no branch yet: `parseRepoIsEmpty` reads it.
62
+ */
60
63
  export function ghRepoViewCommand(slug: string): ShellCommand {
61
- return { command: "gh", args: ["repo", "view", slug, "--json", "name"] };
64
+ return { command: "gh", args: ["repo", "view", slug, "--json", "isEmpty"] };
65
+ }
66
+
67
+ /** Read `gh repo view --json isEmpty`'s stdout: whether the repo has no branch yet. */
68
+ export function parseRepoIsEmpty(stdout: string): boolean {
69
+ let parsed: unknown;
70
+ try {
71
+ parsed = JSON.parse(stdout);
72
+ } catch (error) {
73
+ const detail = error instanceof Error ? error.message : String(error);
74
+ throw new Error(`gh repo view returned malformed JSON: ${detail}`);
75
+ }
76
+ return (parsed as { isEmpty?: unknown }).isEmpty === true;
62
77
  }
63
78
 
64
79
  /** `gh repo create <slug> --public --description <text>` — create the case repo (MVP is public-only), titled for its storefront; no clone, no push. */
@@ -66,6 +81,19 @@ export function ghRepoCreateCommand(slug: string, description: string): ShellCom
66
81
  return { command: "gh", args: ["repo", "create", slug, "--public", "--description", description] };
67
82
  }
68
83
 
84
+ /**
85
+ * `gh repo edit <slug> --default-branch main` — name `main` the default branch of a repo whose
86
+ * first push was this run's (Task 17.23). Left to itself, GitHub picks the default branch from the
87
+ * first push by a rule it does not document: the same push made `main` the default for one account
88
+ * and the solution branch for another (Task 17b.3, F1), and a solution-branch default shows the
89
+ * solution on the repo's page and checks it out on a plain `git clone`. Runs after the push, since
90
+ * GitHub cannot name a branch that does not exist yet. Needs admin rights on the repo, which
91
+ * GitHub gives whoever creates it — an organization member included.
92
+ */
93
+ export function ghRepoSetDefaultBranchCommand(slug: string): ShellCommand {
94
+ return { command: "gh", args: ["repo", "edit", slug, "--default-branch", "main"] };
95
+ }
96
+
69
97
  /** `git status --porcelain` — the clean-tree guard: what was validated must be exactly what is pushed. */
70
98
  export function gitStatusPorcelainCommand(): ShellCommand {
71
99
  return { command: "git", args: ["status", "--porcelain"] };
@@ -10,7 +10,8 @@
10
10
  * file) → local guards (clean tree, solution branch) → gh login + Fito session → identity check →
11
11
  * published-guard → reconcile the solution branch's `.case/` with the canonical branch's (Task
12
12
  * 9a.7 parity) → create the GitHub repo if absent → push `main` + the frozen `vX.Y.Z` branch/tag
13
- * + the `case/solution-vX.Y.Z` branch → `POST /cases` (draft) → `POST /cases/{id}/publish`.
13
+ * + the `case/solution-vX.Y.Z` branch → make `main` the default branch of a repo that had no
14
+ * branch before the push → `POST /cases` (draft) → `POST /cases/{id}/publish`.
14
15
  *
15
16
  * Failure leaves the local checkout intact for fix-and-retry: backend rejections surface their
16
17
  * problem detail **verbatim**, the minted draft id is remembered in `~/.fito/publish-state.json`
@@ -26,7 +27,7 @@ import { validateCaseContent } from "../../shared/case-validation/case-schema.js
26
27
  import { FitoApiError, createFitoApiClient } from "../../shared/fito-api/client.js";
27
28
  import { resolveFitoSession } from "../../shared/fito-session/session.js";
28
29
  import { fitoApiUrl, fitoUrl } from "../../shared/fito-url/fito-url.js";
29
- import { caseRepoHttpsUrl, ghAuthStatusCommand, ghCurrentLoginCommand, ghRepoCreateCommand, ghRepoViewCommand, gitCaseParityDiffCommand, gitCheckoutCommand, gitCommitCaseParityCommand, gitCurrentBranchCommand, gitListLocalBranchCommand, gitPushCaseRefsCommand, gitRestoreCaseDirCommand, gitStatusPorcelainCommand, parseRepoArg, withoutAuthoringHarnessPaths, } from "./github-publish.js";
30
+ import { caseRepoHttpsUrl, ghAuthStatusCommand, ghCurrentLoginCommand, ghRepoCreateCommand, ghRepoSetDefaultBranchCommand, ghRepoViewCommand, gitCaseParityDiffCommand, gitCheckoutCommand, gitCommitCaseParityCommand, gitCurrentBranchCommand, gitListLocalBranchCommand, gitPushCaseRefsCommand, gitRestoreCaseDirCommand, gitStatusPorcelainCommand, parseRepoArg, parseRepoIsEmpty, withoutAuthoringHarnessPaths, } from "./github-publish.js";
30
31
  import { buildCaseWritePayloads, readCasePublishFacts } from "./publish-payload.js";
31
32
  import { clearPublishState, readPublishState, writePublishState } from "./publish-state.js";
32
33
  /** A backend rejection of the register/publish call: the problem detail verbatim, plus the retry id. */
@@ -112,14 +113,19 @@ export async function runPublish(options) {
112
113
  const caseReconciled = await reconcileSolutionBranchCase(run, facts.solutionBranch);
113
114
  // Create the repo only when absent — a fix-and-retry re-run must never create a duplicate.
114
115
  let repoCreated = false;
116
+ let repoView;
115
117
  try {
116
- await run(ghRepoViewCommand(slug));
118
+ repoView = await run(ghRepoViewCommand(slug));
117
119
  }
118
120
  catch {
119
121
  await run(ghRepoCreateCommand(slug, facts.title));
120
122
  repoCreated = true;
121
123
  }
124
+ // A repo with no branch yet takes its default branch from the push below: one this run created,
125
+ // or one a failed earlier run created and never pushed to. A repo with branches keeps its own.
126
+ const repoWasEmpty = repoView === undefined || parseRepoIsEmpty(repoView);
122
127
  await run(gitPushCaseRefsCommand(repositoryUrl, facts.versionRef, facts.solutionBranch));
128
+ const defaultBranchWarning = repoWasEmpty ? await setDefaultBranchMain(run, slug) : undefined;
123
129
  // Register (or reuse the draft id): POST /cases is not idempotent, so the minted id is
124
130
  // remembered in ~/.fito/publish-state.json until the publish succeeds.
125
131
  const rememberedId = options.caseId ?? readPublishState(repositoryUrl, apiBaseUrl, home);
@@ -147,12 +153,33 @@ export async function runPublish(options) {
147
153
  repositoryUrl,
148
154
  versionRef: facts.versionRef,
149
155
  repoCreated,
156
+ defaultBranchSet: repoWasEmpty && defaultBranchWarning === undefined,
150
157
  caseReconciled,
151
158
  ghLogin,
152
159
  title: facts.title,
153
160
  webUrl: `${fitoUrl(env)}/cases/${caseId}`,
161
+ ...(defaultBranchWarning === undefined ? {} : { defaultBranchWarning }),
154
162
  };
155
163
  }
164
+ /**
165
+ * Name `main` the default branch of a repo this run pushed to first (Task 17.23). Never fatal: the
166
+ * default branch is what the repo's page shows and a plain `git clone` checks out, and no Fito
167
+ * command reads it. And a stop would be worse than the warning — a re-run finds the repo no
168
+ * longer empty and skips this step without a word. Returns the warning on a failure.
169
+ */
170
+ async function setDefaultBranchMain(run, slug) {
171
+ const command = ghRepoSetDefaultBranchCommand(slug);
172
+ try {
173
+ await run(command);
174
+ return undefined;
175
+ }
176
+ catch (error) {
177
+ const reason = error instanceof Error ? error.message : String(error);
178
+ return (`Fito couldn't make main the repo's default branch (${reason.trimEnd()})\n` +
179
+ ` GitHub picked one itself, and it may be the solution branch.\n` +
180
+ ` Set it yourself: ${command.command} ${command.args.join(" ")}`);
181
+ }
182
+ }
156
183
  /**
157
184
  * Enforce the `.case/` parity invariant (Task 9a.7, F9): `.case/` describes the case, not the
158
185
  * branch — but plan-source finalizes `artifacts.yaml` on the canonical branch after the solution
@@ -256,8 +283,14 @@ async function main() {
256
283
  console.log("✓ Reconciled the solution branch's .case/ with main (it had diverged) before the push.");
257
284
  }
258
285
  console.log(`✓ Pushed main, ${result.versionRef} (branch + tag), and the solution branch.`);
286
+ if (result.defaultBranchSet) {
287
+ console.log("✓ Made main the repo's default branch.");
288
+ }
259
289
  console.log(`✓ Published "${result.title}" — backend case id: ${result.caseId} (${result.status}).`);
260
290
  console.log(`✓ Listed at: ${result.webUrl}`);
291
+ if (result.defaultBranchWarning) {
292
+ console.error(`⚠ ${result.defaultBranchWarning}`);
293
+ }
261
294
  }
262
295
  catch (error) {
263
296
  if (error instanceof PublishRejectedError) {
@@ -10,7 +10,8 @@
10
10
  * file) → local guards (clean tree, solution branch) → gh login + Fito session → identity check →
11
11
  * published-guard → reconcile the solution branch's `.case/` with the canonical branch's (Task
12
12
  * 9a.7 parity) → create the GitHub repo if absent → push `main` + the frozen `vX.Y.Z` branch/tag
13
- * + the `case/solution-vX.Y.Z` branch → `POST /cases` (draft) → `POST /cases/{id}/publish`.
13
+ * + the `case/solution-vX.Y.Z` branch → make `main` the default branch of a repo that had no
14
+ * branch before the push → `POST /cases` (draft) → `POST /cases/{id}/publish`.
14
15
  *
15
16
  * Failure leaves the local checkout intact for fix-and-retry: backend rejections surface their
16
17
  * problem detail **verbatim**, the minted draft id is remembered in `~/.fito/publish-state.json`
@@ -35,6 +36,7 @@ import {
35
36
  ghAuthStatusCommand,
36
37
  ghCurrentLoginCommand,
37
38
  ghRepoCreateCommand,
39
+ ghRepoSetDefaultBranchCommand,
38
40
  ghRepoViewCommand,
39
41
  gitCaseParityDiffCommand,
40
42
  gitCheckoutCommand,
@@ -45,6 +47,7 @@ import {
45
47
  gitRestoreCaseDirCommand,
46
48
  gitStatusPorcelainCommand,
47
49
  parseRepoArg,
50
+ parseRepoIsEmpty,
48
51
  withoutAuthoringHarnessPaths,
49
52
  } from "./github-publish.ts";
50
53
  import type { ShellCommand } from "./github-publish.ts";
@@ -84,12 +87,19 @@ export interface RunPublishResult {
84
87
  versionRef: string;
85
88
  /** Whether this run created the GitHub repo (false: it already existed and was reused). */
86
89
  repoCreated: boolean;
90
+ /** Whether this run made `main` the default branch — of a repo that had no branch before its push (Task 17.23). */
91
+ defaultBranchSet: boolean;
87
92
  /** Whether the solution branch's `.case/` had diverged and was reconciled before the push (Task 9a.7). */
88
93
  caseReconciled: boolean;
89
94
  ghLogin: string;
90
95
  title: string;
91
96
  /** The case's web address, under Fito's — where it is now listed and openable. */
92
97
  webUrl: string;
98
+ /**
99
+ * Set when making `main` the default branch failed — the case is published all the same. The
100
+ * caller prints this as a warning, never an error (the `refreshWarning` precedent).
101
+ */
102
+ defaultBranchWarning?: string;
93
103
  }
94
104
 
95
105
  /** A backend rejection of the register/publish call: the problem detail verbatim, plus the retry id. */
@@ -197,14 +207,19 @@ export async function runPublish(options: RunPublishOptions): Promise<RunPublish
197
207
 
198
208
  // Create the repo only when absent — a fix-and-retry re-run must never create a duplicate.
199
209
  let repoCreated = false;
210
+ let repoView: string | undefined;
200
211
  try {
201
- await run(ghRepoViewCommand(slug));
212
+ repoView = await run(ghRepoViewCommand(slug));
202
213
  } catch {
203
214
  await run(ghRepoCreateCommand(slug, facts.title));
204
215
  repoCreated = true;
205
216
  }
217
+ // A repo with no branch yet takes its default branch from the push below: one this run created,
218
+ // or one a failed earlier run created and never pushed to. A repo with branches keeps its own.
219
+ const repoWasEmpty = repoView === undefined || parseRepoIsEmpty(repoView);
206
220
 
207
221
  await run(gitPushCaseRefsCommand(repositoryUrl, facts.versionRef, facts.solutionBranch));
222
+ const defaultBranchWarning = repoWasEmpty ? await setDefaultBranchMain(run, slug) : undefined;
208
223
 
209
224
  // Register (or reuse the draft id): POST /cases is not idempotent, so the minted id is
210
225
  // remembered in ~/.fito/publish-state.json until the publish succeeds.
@@ -234,13 +249,36 @@ export async function runPublish(options: RunPublishOptions): Promise<RunPublish
234
249
  repositoryUrl,
235
250
  versionRef: facts.versionRef,
236
251
  repoCreated,
252
+ defaultBranchSet: repoWasEmpty && defaultBranchWarning === undefined,
237
253
  caseReconciled,
238
254
  ghLogin,
239
255
  title: facts.title,
240
256
  webUrl: `${fitoUrl(env)}/cases/${caseId}`,
257
+ ...(defaultBranchWarning === undefined ? {} : { defaultBranchWarning }),
241
258
  };
242
259
  }
243
260
 
261
+ /**
262
+ * Name `main` the default branch of a repo this run pushed to first (Task 17.23). Never fatal: the
263
+ * default branch is what the repo's page shows and a plain `git clone` checks out, and no Fito
264
+ * command reads it. And a stop would be worse than the warning — a re-run finds the repo no
265
+ * longer empty and skips this step without a word. Returns the warning on a failure.
266
+ */
267
+ async function setDefaultBranchMain(run: (command: ShellCommand) => Promise<string>, slug: string): Promise<string | undefined> {
268
+ const command = ghRepoSetDefaultBranchCommand(slug);
269
+ try {
270
+ await run(command);
271
+ return undefined;
272
+ } catch (error) {
273
+ const reason = error instanceof Error ? error.message : String(error);
274
+ return (
275
+ `Fito couldn't make main the repo's default branch (${reason.trimEnd()})\n` +
276
+ ` GitHub picked one itself, and it may be the solution branch.\n` +
277
+ ` Set it yourself: ${command.command} ${command.args.join(" ")}`
278
+ );
279
+ }
280
+ }
281
+
244
282
  /**
245
283
  * Enforce the `.case/` parity invariant (Task 9a.7, F9): `.case/` describes the case, not the
246
284
  * branch — but plan-source finalizes `artifacts.yaml` on the canonical branch after the solution
@@ -364,8 +402,14 @@ async function main(): Promise<void> {
364
402
  console.log("✓ Reconciled the solution branch's .case/ with main (it had diverged) before the push.");
365
403
  }
366
404
  console.log(`✓ Pushed main, ${result.versionRef} (branch + tag), and the solution branch.`);
405
+ if (result.defaultBranchSet) {
406
+ console.log("✓ Made main the repo's default branch.");
407
+ }
367
408
  console.log(`✓ Published "${result.title}" — backend case id: ${result.caseId} (${result.status}).`);
368
409
  console.log(`✓ Listed at: ${result.webUrl}`);
410
+ if (result.defaultBranchWarning) {
411
+ console.error(`⚠ ${result.defaultBranchWarning}`);
412
+ }
369
413
  } catch (error) {
370
414
  if (error instanceof PublishRejectedError) {
371
415
  console.error(`✗ The backend rejected the publish (HTTP ${error.status}):\n ${error.message}`);
@@ -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] };
@@ -76,9 +76,20 @@ export function forkCloneUrl(login: string, repo: string): string {
76
76
  return `https://github.com/${login}/${repo}.git`;
77
77
  }
78
78
 
79
- /** `git clone <url> <dir>` — clone the fork into the explicit per-case working directory. */
79
+ /**
80
+ * `git clone -c core.autocrlf=input -c core.longpaths=true <url> <dir>` — clone the fork into the
81
+ * explicit per-case working directory. Git for Windows checks files out with CRLF, which can break a
82
+ * case's shell script in a rubric command, and refuses a path over 260 characters (Phase 17a,
83
+ * finding 7 and N2). `input` checks out LF and stores a CRLF file as LF at commit; `longpaths` lifts
84
+ * the limit and means nothing elsewhere. `git clone -c` stores both keys in the new repository, so
85
+ * every later git command there keeps them. The author's clone carries the same two keys
86
+ * (`fito-case-author`'s `gitCloneMainCommand`).
87
+ */
80
88
  export function gitCloneCommand(cloneUrl: string, targetDir: string): ShellCommand {
81
- return { command: "git", args: ["clone", cloneUrl, targetDir] };
89
+ return {
90
+ command: "git",
91
+ args: ["clone", "-c", "core.autocrlf=input", "-c", "core.longpaths=true", cloneUrl, targetDir],
92
+ };
82
93
  }
83
94
 
84
95
  /**
@@ -167,6 +178,14 @@ export function isDivergedPush(message: string): boolean {
167
178
  return /non-fast-forward|fetch first|! \[rejected\]/i.test(message);
168
179
  }
169
180
 
181
+ /**
182
+ * `git status --porcelain` — the submit guard's view of what is not committed: changed files and
183
+ * new ones, but not what `.gitignore` lists. Every line blocks a submit (Task 17a.2).
184
+ */
185
+ export function gitStatusPorcelainCommand(): ShellCommand {
186
+ return { command: "git", args: ["status", "--porcelain"] };
187
+ }
188
+
170
189
  /** `git push -u origin <studentBranch>` — publish the student branch to the fork. */
171
190
  export function gitPushCommand(studentBranch: string): ShellCommand {
172
191
  return { command: "git", args: ["push", "-u", "origin", studentBranch] };
@@ -60,10 +60,10 @@ export async function runOpen(options) {
60
60
  throw new Error(`Your fork already has a '${error.branch}' branch from a previous attempt on this case.\n` +
61
61
  `Choose how to continue, then re-run with that choice:\n` +
62
62
  ` resume the previous attempt — keeps its commits and its open pull request:\n` +
63
- ` node open.js ${options.caseId} --resume\n` +
63
+ ` node "open.js" ${options.caseId} --resume\n` +
64
64
  ` start over from the published case — deletes '${error.branch}' on your fork, ` +
65
65
  `closing its pull request; that attempt's unmerged work is lost:\n` +
66
- ` node open.js ${options.caseId} --start-over`);
66
+ ` node "open.js" ${options.caseId} --start-over`);
67
67
  }
68
68
  throw error;
69
69
  }
@@ -156,7 +156,7 @@ async function main() {
156
156
  console.log(`✓ Started over — your fork's previous '${result.branch}' was deleted (its PR closed).`);
157
157
  }
158
158
  console.log(`✓ Case opened at:\n ${result.workDir}\n on branch '${result.branch}'.`);
159
- console.log(` Make your changes there, then submit: node submit.js ${caseId}`);
159
+ console.log(` Make your changes there, then submit: node "submit.js" ${caseId}`);
160
160
  if (result.deprecationWarning) {
161
161
  console.error(`⚠ ${result.deprecationWarning}`);
162
162
  }
@@ -106,10 +106,10 @@ export async function runOpen(options: RunOpenOptions): Promise<RunOpenResult> {
106
106
  `Your fork already has a '${error.branch}' branch from a previous attempt on this case.\n` +
107
107
  `Choose how to continue, then re-run with that choice:\n` +
108
108
  ` resume the previous attempt — keeps its commits and its open pull request:\n` +
109
- ` node open.js ${options.caseId} --resume\n` +
109
+ ` node "open.js" ${options.caseId} --resume\n` +
110
110
  ` start over from the published case — deletes '${error.branch}' on your fork, ` +
111
111
  `closing its pull request; that attempt's unmerged work is lost:\n` +
112
- ` node open.js ${options.caseId} --start-over`,
112
+ ` node "open.js" ${options.caseId} --start-over`,
113
113
  );
114
114
  }
115
115
  throw error;
@@ -221,7 +221,7 @@ async function main(): Promise<void> {
221
221
  console.log(`✓ Started over — your fork's previous '${result.branch}' was deleted (its PR closed).`);
222
222
  }
223
223
  console.log(`✓ Case opened at:\n ${result.workDir}\n on branch '${result.branch}'.`);
224
- console.log(` Make your changes there, then submit: node submit.js ${caseId}`);
224
+ console.log(` Make your changes there, then submit: node "submit.js" ${caseId}`);
225
225
  if (result.deprecationWarning) {
226
226
  console.error(`⚠ ${result.deprecationWarning}`);
227
227
  }
@@ -1,5 +1,5 @@
1
1
  import { dirname } from "node:path";
2
- import { assertGithubPlatform, forkCloneUrl, ghAuthStatusCommand, ghCurrentLoginCommand, ghForkCommand, ghPrCreateCommand, ghPrListCommand, gitAddUpstreamRemoteCommand, gitCheckoutRefCommand, gitCheckoutTrackCommand, gitCloneCommand, gitCreateBranchCommand, gitDeleteRemoteBranchCommand, gitFetchUpstreamRefCommand, gitListRemoteBranchCommand, gitPushCommand, isDivergedPush, parseExistingPrUrl, parseGithubRepo, repoSlug, } from "./github.js";
2
+ import { assertGithubPlatform, forkCloneUrl, ghAuthStatusCommand, ghCurrentLoginCommand, ghForkCommand, ghPrCreateCommand, ghPrListCommand, gitAddUpstreamRemoteCommand, gitCheckoutRefCommand, gitCheckoutTrackCommand, gitCloneCommand, gitCreateBranchCommand, gitDeleteRemoteBranchCommand, gitFetchUpstreamRefCommand, gitListRemoteBranchCommand, gitPushCommand, gitStatusPorcelainCommand, isDivergedPush, parseExistingPrUrl, parseGithubRepo, repoSlug, } from "./github.js";
3
3
  import { formatValidationFailure } from "./report.js";
4
4
  /** Upfront readiness: fail fast with an actionable message when `gh` is missing or unauthenticated. */
5
5
  export async function ensureGhReady(exec, cwd) {
@@ -93,6 +93,17 @@ export async function submitSolution(options) {
93
93
  const { pointer, targetDir, exec, readBranches, resolveLinkedGithubLogin, recordSubmission } = options;
94
94
  assertGithubPlatform(pointer.gitPlatform);
95
95
  const repo = parseGithubRepo(pointer.repositoryUrl);
96
+ // The push carries commits only, so work left uncommitted would be missing from the PR while the
97
+ // evaluation that follows scores the working tree as it stands (Task 17a.2). Every porcelain line
98
+ // blocks: on the learner's default route no tool writes into the checkout, unlike the author's
99
+ // case tree, whose publish gate exempts three such folders.
100
+ const uncommitted = (await exec(gitStatusPorcelainCommand(), { cwd: targetDir })).trimEnd();
101
+ if (uncommitted.length > 0) {
102
+ throw new Error(`Your checkout has changes that are not committed, so this submission would leave them out:\n` +
103
+ `${uncommitted}\n` +
104
+ `Nothing was pushed. Commit them on your working branch — or delete the ones that are not ` +
105
+ `part of your work — then submit again.`);
106
+ }
96
107
  await ensureGhReady(exec, targetDir);
97
108
  // The local gh account that will own the fork branch + the PR.
98
109
  const login = (await exec(ghCurrentLoginCommand(), { cwd: targetDir })).trim();
@@ -19,6 +19,7 @@ import {
19
19
  gitFetchUpstreamRefCommand,
20
20
  gitListRemoteBranchCommand,
21
21
  gitPushCommand,
22
+ gitStatusPorcelainCommand,
22
23
  isDivergedPush,
23
24
  parseExistingPrUrl,
24
25
  parseGithubRepo,
@@ -216,6 +217,20 @@ export async function submitSolution(options: SubmitSolutionOptions): Promise<Su
216
217
  assertGithubPlatform(pointer.gitPlatform);
217
218
  const repo = parseGithubRepo(pointer.repositoryUrl);
218
219
 
220
+ // The push carries commits only, so work left uncommitted would be missing from the PR while the
221
+ // evaluation that follows scores the working tree as it stands (Task 17a.2). Every porcelain line
222
+ // blocks: on the learner's default route no tool writes into the checkout, unlike the author's
223
+ // case tree, whose publish gate exempts three such folders.
224
+ const uncommitted = (await exec(gitStatusPorcelainCommand(), { cwd: targetDir })).trimEnd();
225
+ if (uncommitted.length > 0) {
226
+ throw new Error(
227
+ `Your checkout has changes that are not committed, so this submission would leave them out:\n` +
228
+ `${uncommitted}\n` +
229
+ `Nothing was pushed. Commit them on your working branch — or delete the ones that are not ` +
230
+ `part of your work — then submit again.`,
231
+ );
232
+ }
233
+
219
234
  await ensureGhReady(exec, targetDir);
220
235
 
221
236
  // The local gh account that will own the fork branch + the PR.
@@ -24,7 +24,7 @@ export async function runSubmit(options) {
24
24
  const detail = await fetchCaseDetail(client, options.caseId);
25
25
  const targetDir = caseWorkDir(options.caseId, home);
26
26
  if (!existsSync(targetDir)) {
27
- throw new Error(`No open case at:\n ${targetDir}\nRun open first: node open.js ${options.caseId}`);
27
+ throw new Error(`No open case at:\n ${targetDir}\nRun open first: node "open.js" ${options.caseId}`);
28
28
  }
29
29
  // The version pin comes from the local tree, not the case detail: after a case update the
30
30
  // backend serves the *current* version, while the learner solved this checkout's version.
@@ -41,7 +41,7 @@ export async function runSubmit(options: RunSubmitOptions): Promise<SubmitSoluti
41
41
  const targetDir = caseWorkDir(options.caseId, home);
42
42
 
43
43
  if (!existsSync(targetDir)) {
44
- throw new Error(`No open case at:\n ${targetDir}\nRun open first: node open.js ${options.caseId}`);
44
+ throw new Error(`No open case at:\n ${targetDir}\nRun open first: node "open.js" ${options.caseId}`);
45
45
  }
46
46
 
47
47
  // The version pin comes from the local tree, not the case detail: after a case update the
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `node temp-file.js` — make a new folder under the system temp folder and print the path of a file
3
+ * in it (Task 17a.2). `/fito-submit` and `/fito-evaluate` write a JSON file there, for
4
+ * `submit-evaluation.js`, `score-quiz-mc.js` or `submit-quiz-result.js` to read.
5
+ *
6
+ * It replaces `$(mktemp)`, which on Windows names two different files: Git Bash makes `/tmp/tmp.X`
7
+ * in the user's `Temp` folder, while Node and pi's `write` tool read `/tmp` as `C:\tmp`. The path is
8
+ * printed with `/`, which Git Bash, Node and pi's file tools all accept, so a model copying it into
9
+ * a command or a tool call has no `\` to lose or to escape. The folder stays behind, as a `mktemp`
10
+ * file did.
11
+ */
12
+ import { mkdtempSync } from "node:fs";
13
+ import * as os from "node:os";
14
+ import * as path from "node:path";
15
+ const dir = mkdtempSync(path.join(os.tmpdir(), "fito-"));
16
+ console.log(path.join(dir, "data.json").split(path.sep).join("/"));
@@ -0,0 +1,17 @@
1
+ /**
2
+ * `node temp-file.js` — make a new folder under the system temp folder and print the path of a file
3
+ * in it (Task 17a.2). `/fito-submit` and `/fito-evaluate` write a JSON file there, for
4
+ * `submit-evaluation.js`, `score-quiz-mc.js` or `submit-quiz-result.js` to read.
5
+ *
6
+ * It replaces `$(mktemp)`, which on Windows names two different files: Git Bash makes `/tmp/tmp.X`
7
+ * in the user's `Temp` folder, while Node and pi's `write` tool read `/tmp` as `C:\tmp`. The path is
8
+ * printed with `/`, which Git Bash, Node and pi's file tools all accept, so a model copying it into
9
+ * a command or a tool call has no `\` to lose or to escape. The folder stays behind, as a `mktemp`
10
+ * file did.
11
+ */
12
+ import { mkdtempSync } from "node:fs";
13
+ import * as os from "node:os";
14
+ import * as path from "node:path";
15
+
16
+ const dir = mkdtempSync(path.join(os.tmpdir(), "fito-"));
17
+ console.log(path.join(dir, "data.json").split(path.sep).join("/"));
@@ -30,7 +30,7 @@ itself.
30
30
  ## Create the competence
31
31
 
32
32
  ```bash
33
- node <fito-competence-write skill dir>/create.js <payload-file>
33
+ node "<fito-competence-write skill dir>/create.js" "<payload-file>"
34
34
  ```
35
35
 
36
36
  POSTs the payload to `POST /competences`. The author becomes the competence's owner.
@@ -60,7 +60,7 @@ seen the id — an edit or a delete addresses the competence by it.
60
60
  ## Edit the name or the description
61
61
 
62
62
  ```bash
63
- node <fito-competence-write skill dir>/update.js <competence-id> <payload-file> [--name] [--description]
63
+ node "<fito-competence-write skill dir>/update.js" <competence-id> "<payload-file>" [--name] [--description]
64
64
  ```
65
65
 
66
66
  PATCHes `/competences/{id}`, in place: the competence keeps its id, its elements and its learners'
@@ -94,7 +94,7 @@ on a no-axis run.
94
94
  ## Delete the competence and everything beneath it
95
95
 
96
96
  ```bash
97
- node <fito-competence-write skill dir>/delete.js <competence-id> [--confirm]
97
+ node "<fito-competence-write skill dir>/delete.js" <competence-id> [--confirm]
98
98
  ```
99
99
 
100
100
  Without `--confirm` nothing is deleted. The script reads the competence and prints what a delete would
@@ -74,7 +74,7 @@ export function describeStopped(result) {
74
74
  describeWhatGoes(result),
75
75
  "",
76
76
  "Nothing has been deleted. A delete needs the author's explicit confirmation:",
77
- ` node delete.js ${result.competence.id} --confirm`,
77
+ ` node "delete.js" ${result.competence.id} --confirm`,
78
78
  ].join("\n");
79
79
  }
80
80
  /** The success line: the competence deleted, and how much went with it. */
@@ -105,7 +105,7 @@ export function describeStopped(result: DeleteResult): string {
105
105
  describeWhatGoes(result),
106
106
  "",
107
107
  "Nothing has been deleted. A delete needs the author's explicit confirmation:",
108
- ` node delete.js ${result.competence.id} --confirm`,
108
+ ` node "delete.js" ${result.competence.id} --confirm`,
109
109
  ].join("\n");
110
110
  }
111
111