fito-tui 0.3.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 (63) 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 +7 -3
  5. package/prompts/fito-auth-refresh.md +4 -4
  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 +4 -4
  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/shared/fito-session/credentials.js +27 -15
  19. package/shared/fito-session/credentials.ts +33 -15
  20. package/shared/fito-session/session.js +7 -5
  21. package/shared/fito-session/session.ts +10 -7
  22. package/skills/fito-auth/SKILL.md +14 -13
  23. package/skills/fito-auth/auth-refresh.js +3 -2
  24. package/skills/fito-auth/auth-refresh.ts +3 -2
  25. package/skills/fito-auth/browser.js +3 -2
  26. package/skills/fito-auth/browser.ts +3 -2
  27. package/skills/fito-auth/login.js +24 -8
  28. package/skills/fito-auth/login.ts +25 -8
  29. package/skills/fito-auth/logout.js +3 -2
  30. package/skills/fito-auth/logout.ts +3 -2
  31. package/skills/fito-case-author/SKILL.md +4 -4
  32. package/skills/fito-case-author/checkout.js +22 -5
  33. package/skills/fito-case-author/checkout.ts +22 -5
  34. package/skills/fito-case-author/publish-version.js +1 -1
  35. package/skills/fito-case-author/publish-version.ts +1 -1
  36. package/skills/fito-case-author/publish.js +1 -1
  37. package/skills/fito-case-author/publish.ts +1 -1
  38. package/skills/fito-case-runner/SKILL.md +24 -7
  39. package/skills/fito-case-runner/github.js +20 -2
  40. package/skills/fito-case-runner/github.ts +21 -2
  41. package/skills/fito-case-runner/open.js +3 -3
  42. package/skills/fito-case-runner/open.ts +3 -3
  43. package/skills/fito-case-runner/runner.js +12 -1
  44. package/skills/fito-case-runner/runner.ts +15 -0
  45. package/skills/fito-case-runner/submit.js +1 -1
  46. package/skills/fito-case-runner/submit.ts +1 -1
  47. package/skills/fito-case-runner/temp-file.js +16 -0
  48. package/skills/fito-case-runner/temp-file.ts +17 -0
  49. package/skills/fito-competence-write/SKILL.md +3 -3
  50. package/skills/fito-competence-write/delete.js +1 -1
  51. package/skills/fito-competence-write/delete.ts +1 -1
  52. package/skills/fito-evaluator/SKILL.md +7 -6
  53. package/skills/fito-evaluator/criterion-exec.js +113 -17
  54. package/skills/fito-evaluator/criterion-exec.ts +110 -18
  55. package/skills/fito-evaluator/evaluate-automated.js +7 -3
  56. package/skills/fito-evaluator/evaluate-automated.ts +7 -3
  57. package/skills/fito-knowledge-push/SKILL.md +1 -1
  58. package/skills/fito-knowledge-push/push.js +8 -8
  59. package/skills/fito-knowledge-push/push.ts +8 -8
  60. package/skills/fito-source-ingestion/SKILL.md +4 -4
  61. package/skills/fito-technology-write/SKILL.md +2 -2
  62. package/skills/fito-technology-write/create.js +2 -2
  63. package/skills/fito-technology-write/create.ts +2 -2
@@ -1,14 +1,16 @@
1
1
  /**
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
- * browser to POST the freshly minted token pair back, and writes it to
5
- * `~/.fito/credentials` (0600). Run from this skill's directory: `node login.js`.
4
+ * browser to POST the freshly minted token pair back, and writes it to this Fito's
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";
11
- import { type Credentials, writeCredentials } from "../../shared/fito-session/credentials.ts";
13
+ import { type Credentials, credentialsFileName, writeCredentials } from "../../shared/fito-session/credentials.ts";
12
14
  import { fitoUrl } from "../../shared/fito-url/fito-url.ts";
13
15
 
14
16
  /** Web origin hosting the login page: the address of the Fito this TUI uses. */
@@ -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/credentials (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
+ }
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * `/fito-logout` CLI entrypoint. Best-effort revokes the refresh token
3
- * server-side, then deletes `~/.fito/credentials`. Idempotent: succeeds even when
4
- * no credentials are present. Run from this skill's directory: `node logout.js`.
3
+ * server-side, then deletes this Fito's `~/.fito/credentials-<host>`.
4
+ * Idempotent: succeeds even when no credentials are present. Run from this
5
+ * skill's directory: `node logout.js`.
5
6
  */
6
7
  import { createFitoApiClient } from "../../shared/fito-api/client.js";
7
8
  import { deleteCredentials, readCredentials } from "../../shared/fito-session/credentials.js";
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * `/fito-logout` CLI entrypoint. Best-effort revokes the refresh token
3
- * server-side, then deletes `~/.fito/credentials`. Idempotent: succeeds even when
4
- * no credentials are present. Run from this skill's directory: `node logout.js`.
3
+ * server-side, then deletes this Fito's `~/.fito/credentials-<host>`.
4
+ * Idempotent: succeeds even when no credentials are present. Run from this
5
+ * skill's directory: `node logout.js`.
5
6
  */
6
7
  import { createFitoApiClient } from "../../shared/fito-api/client.ts";
7
8
  import { deleteCredentials, readCredentials } from "../../shared/fito-session/credentials.ts";
@@ -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 {
@@ -166,7 +166,7 @@ export async function runPublishVersion(options) {
166
166
  throw new Error(`${origin.reason}.\nThis directory is an initial publish, not an update — run /fito-publish-case's ` +
167
167
  "initial path (publish.js) instead.");
168
168
  }
169
- const session = await resolveFitoSession(client, home);
169
+ const session = await resolveFitoSession(client, home, fitoUrl(env));
170
170
  const detail = await client.getCase(origin.caseId, session.tokens.accessToken);
171
171
  gateStatus(detail, "publishVersion");
172
172
  // The strictly-greater guard, before the push: the current version is the chain's maximum, so a
@@ -272,7 +272,7 @@ export async function runPublishVersion(options: RunPublishVersionOptions): Prom
272
272
  );
273
273
  }
274
274
 
275
- const session = await resolveFitoSession(client, home);
275
+ const session = await resolveFitoSession(client, home, fitoUrl(env));
276
276
  const detail = await client.getCase(origin.caseId, session.tokens.accessToken);
277
277
  gateStatus(detail, "publishVersion");
278
278
 
@@ -76,7 +76,7 @@ export async function runPublish(options) {
76
76
  "executed outside Fito), then re-run.");
77
77
  }
78
78
  const ghLogin = (await run(ghCurrentLoginCommand())).trim();
79
- const session = await resolveFitoSession(client, home);
79
+ const session = await resolveFitoSession(client, home, fitoUrl(env));
80
80
  // Decision 4 (2026-07-08): a gh↔Fito identity mismatch warns and stops for the author's explicit
81
81
  // confirmation — never refuses outright (publishing under an org is supported).
82
82
  const linkedLogin = session.user.githubLogin ?? null;
@@ -151,7 +151,7 @@ export async function runPublish(options: RunPublishOptions): Promise<RunPublish
151
151
  }
152
152
 
153
153
  const ghLogin = (await run(ghCurrentLoginCommand())).trim();
154
- const session = await resolveFitoSession(client, home);
154
+ const session = await resolveFitoSession(client, home, fitoUrl(env));
155
155
 
156
156
  // Decision 4 (2026-07-08): a gh↔Fito identity mismatch warns and stops for the author's explicit
157
157
  // confirmation — never refuses outright (publishing under an org is supported).
@@ -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