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.
- package/agents/fito-case-source-planner.md +42 -13
- package/agents/fito-performance-reviewer.md +19 -8
- package/agents/fito-tutor.md +2 -1
- package/extensions/fito-fetch-tools.js +63 -7
- package/extensions/fito-fetch-tools.ts +70 -7
- package/extensions/fito-startup.js +32 -5
- package/extensions/fito-startup.ts +44 -8
- package/package.json +3 -3
- package/prompts/fito-auth-refresh.md +1 -1
- package/prompts/fito-case-design.md +71 -16
- package/prompts/fito-case-edit.md +2 -2
- package/prompts/fito-case-generate.md +30 -11
- package/prompts/fito-case-open.md +20 -12
- package/prompts/fito-case-plan-source.md +13 -6
- package/prompts/fito-create-or-update-competence.md +2 -2
- package/prompts/fito-create-or-update-technology.md +5 -5
- package/prompts/fito-delete-competence.md +2 -2
- package/prompts/fito-evaluate.md +30 -22
- package/prompts/fito-generate-domain-concepts.md +1 -1
- package/prompts/fito-generate-execution-facts.md +1 -1
- package/prompts/fito-generate-usage-scenarios.md +1 -1
- package/prompts/fito-login.md +3 -3
- package/prompts/fito-logout.md +1 -1
- package/prompts/fito-publish-case.md +3 -3
- package/prompts/fito-push-knowledge.md +1 -1
- package/prompts/fito-submit.md +55 -36
- package/shared/case-briefing/briefing.js +1 -0
- package/shared/case-briefing/briefing.ts +1 -0
- package/skills/fito-auth/SKILL.md +8 -7
- package/skills/fito-auth/browser.js +3 -2
- package/skills/fito-auth/browser.ts +3 -2
- package/skills/fito-auth/login.js +22 -6
- package/skills/fito-auth/login.ts +23 -6
- package/skills/fito-case-author/SKILL.md +12 -10
- package/skills/fito-case-author/checkout.js +22 -5
- package/skills/fito-case-author/checkout.ts +22 -5
- package/skills/fito-case-author/github-publish.js +29 -2
- package/skills/fito-case-author/github-publish.ts +30 -2
- package/skills/fito-case-author/publish.js +36 -3
- package/skills/fito-case-author/publish.ts +46 -2
- package/skills/fito-case-runner/SKILL.md +24 -7
- package/skills/fito-case-runner/github.js +20 -2
- package/skills/fito-case-runner/github.ts +21 -2
- package/skills/fito-case-runner/open.js +3 -3
- package/skills/fito-case-runner/open.ts +3 -3
- package/skills/fito-case-runner/runner.js +12 -1
- package/skills/fito-case-runner/runner.ts +15 -0
- package/skills/fito-case-runner/submit.js +1 -1
- package/skills/fito-case-runner/submit.ts +1 -1
- package/skills/fito-case-runner/temp-file.js +16 -0
- package/skills/fito-case-runner/temp-file.ts +17 -0
- package/skills/fito-competence-write/SKILL.md +3 -3
- package/skills/fito-competence-write/delete.js +1 -1
- package/skills/fito-competence-write/delete.ts +1 -1
- package/skills/fito-evaluator/SKILL.md +7 -6
- package/skills/fito-evaluator/criterion-exec.js +113 -17
- package/skills/fito-evaluator/criterion-exec.ts +110 -18
- package/skills/fito-evaluator/evaluate-automated.js +7 -3
- package/skills/fito-evaluator/evaluate-automated.ts +7 -3
- package/skills/fito-knowledge-push/SKILL.md +1 -1
- package/skills/fito-knowledge-push/push.js +8 -8
- package/skills/fito-knowledge-push/push.ts +8 -8
- package/skills/fito-source-ingestion/SKILL.md +4 -4
- package/skills/fito-technology-write/SKILL.md +2 -2
- package/skills/fito-technology-write/create.js +2 -2
- package/skills/fito-technology-write/create.ts +2 -2
- package/skills/fito-url-content-fetcher/SKILL.md +53 -16
|
@@ -41,7 +41,7 @@ checkout). Then resolve **which publish this is** — using the `fito-case-autho
|
|
|
41
41
|
skill (read its `SKILL.md`):
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
node <fito-case-author skill dir>/publish-version.js <case-dir> --probe
|
|
44
|
+
node "<fito-case-author skill dir>/publish-version.js" "<case-dir>" --probe
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
- **`route: initial`** — the directory is not a registered case's checkout:
|
|
@@ -122,7 +122,7 @@ anything is pushed.)
|
|
|
122
122
|
## 5. Run the publish
|
|
123
123
|
|
|
124
124
|
```bash
|
|
125
|
-
node <fito-case-author skill dir>/publish.js <case-dir> --repo <owner>/<name> --overview <case-dir>/.authoring/description-overview.md
|
|
125
|
+
node "<fito-case-author skill dir>/publish.js" "<case-dir>" --repo <owner>/<name> --overview "<case-dir>/.authoring/description-overview.md"
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
Add `--case-id <uuid>` when one is known (passed in, or printed by a previous
|
|
@@ -235,7 +235,7 @@ tree is clean.
|
|
|
235
235
|
## 10. Run the version publish and relay — verbatim
|
|
236
236
|
|
|
237
237
|
```bash
|
|
238
|
-
node <fito-case-author skill dir>/publish-version.js <case-dir> --change-description <case-dir>/.authoring/change-description.md --overview <case-dir>/.authoring/description-overview.md
|
|
238
|
+
node "<fito-case-author skill dir>/publish-version.js" "<case-dir>" --change-description "<case-dir>/.authoring/change-description.md" --overview "<case-dir>/.authoring/description-overview.md"
|
|
239
239
|
```
|
|
240
240
|
|
|
241
241
|
One run re-validates the tree, preflights the frozen reference set against
|
|
@@ -46,7 +46,7 @@ force an outcome — this rule exists because that happened.)*
|
|
|
46
46
|
For each component file, in order, run:
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
node <fito-knowledge-push skill dir>/push.js <component-file>
|
|
49
|
+
node "<fito-knowledge-push skill dir>/push.js" "<component-file>"
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
- **Stored** (`✓ Stored …`) — record the reference id and move to the next file.
|
package/prompts/fito-submit.md
CHANGED
|
@@ -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.
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
56
|
-
and the hybrid criteria's gate commands, and prints one **evaluation report
|
|
57
|
-
|
|
58
|
-
|
|
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
|
|
63
|
-
|
|
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**
|
|
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
|
|
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>/
|
|
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
|
|
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.**
|
|
121
|
-
|
|
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>/
|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
141
|
-
|
|
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
|
|
@@ -62,6 +62,7 @@ const KEY_DOCUMENTS = {
|
|
|
62
62
|
starter_state: [
|
|
63
63
|
{ file: "starter_state/description.md", kind: "markdown" },
|
|
64
64
|
{ file: "starter_state/known_state.yaml", kind: "yaml" },
|
|
65
|
+
{ file: "starter_state/setup_instructions.md", kind: "markdown" },
|
|
65
66
|
],
|
|
66
67
|
knowledge_refs: [
|
|
67
68
|
{ file: "learning_objectives.yaml", kind: "yaml" },
|
|
@@ -96,6 +96,7 @@ const KEY_DOCUMENTS: Record<BriefingKey, readonly DocumentEntry[]> = {
|
|
|
96
96
|
starter_state: [
|
|
97
97
|
{ file: "starter_state/description.md", kind: "markdown" },
|
|
98
98
|
{ file: "starter_state/known_state.yaml", kind: "yaml" },
|
|
99
|
+
{ file: "starter_state/setup_instructions.md", kind: "markdown" },
|
|
99
100
|
],
|
|
100
101
|
knowledge_refs: [
|
|
101
102
|
{ file: "learning_objectives.yaml", kind: "yaml" },
|
|
@@ -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
|
|
14
|
-
access goes through the `fito-api` client (ADR-003); this skill
|
|
15
|
-
password — the browser performs the login and hands back only the
|
|
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,
|
|
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`
|
|
9
|
-
|
|
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`
|
|
24
|
-
|
|
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(
|
|
40
|
+
console.log(loginSuccessMessage(credentialsFileName()));
|
|
30
41
|
}
|
|
31
42
|
finally {
|
|
32
43
|
server.close();
|
|
33
44
|
}
|
|
34
45
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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(
|
|
46
|
+
console.log(loginSuccessMessage(credentialsFileName()));
|
|
35
47
|
} finally {
|
|
36
48
|
server.close();
|
|
37
49
|
}
|
|
38
50
|
}
|
|
39
51
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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,15 +56,16 @@ 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
|
|
63
63
|
makes it a published Fito case in one run: re-validates the tree, pushes `main` + the frozen
|
|
64
64
|
`vX.Y.Z` branch/tag + the `case/solution-vX.Y.Z` branch to the GitHub repo (created if absent,
|
|
65
|
-
public, under the Case Creator's account or a chosen org),
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
public, under the Case Creator's account or a chosen org), makes `main` the repo's default branch
|
|
66
|
+
when the repo had no branch before the push, then registers (`POST /cases`) and publishes
|
|
67
|
+
(`POST /cases/{id}/publish`) with the backend. Requires an authenticated `gh` **and** a Fito login
|
|
68
|
+
(`/fito-login`).
|
|
68
69
|
|
|
69
70
|
- `--repo` — `<owner>/<name>`, or a bare `<name>`: the owner then comes from
|
|
70
71
|
`FITO_PUBLISH_GITHUB_OWNER`, else the authenticated `gh` login.
|
|
@@ -80,8 +81,9 @@ idempotent), and the local checkout is never modified. Backend rejections print
|
|
|
80
81
|
**verbatim** — relay it unchanged; the fix is the author's call (a missing knowledge component →
|
|
81
82
|
the knowledge pipeline + `/fito-push-knowledge`; a wrong `.case/` value → `/fito-case-generate`).
|
|
82
83
|
|
|
83
|
-
**Done when** it prints the backend case id + `PUBLISHED` and the web URL
|
|
84
|
-
|
|
84
|
+
**Done when** it prints the backend case id + `PUBLISHED` and the web URL, with any `⚠` line
|
|
85
|
+
relayed together with the command it names — or the stop/rejection was relayed verbatim with its
|
|
86
|
+
re-run affordance (`--case-id` / `--accept-gh-mismatch`).
|
|
85
87
|
|
|
86
88
|
It refuses: a dirty tree (what is validated must be exactly what is pushed), a missing local
|
|
87
89
|
solution branch (build it per `/fito-case-plan-source` first), and a URL that is already a
|
|
@@ -90,7 +92,7 @@ published case (updating published cases is the version publish below — their
|
|
|
90
92
|
## Check a published case out for editing
|
|
91
93
|
|
|
92
94
|
```bash
|
|
93
|
-
node <fito-case-author skill dir>/checkout.js <case-id> [--dir <target>]
|
|
95
|
+
node "<fito-case-author skill dir>/checkout.js" <case-id> [--dir "<target>"]
|
|
94
96
|
```
|
|
95
97
|
|
|
96
98
|
The beginning of the update workflow (ADR-009), driven by `/fito-case-edit`: a **direct clone**
|
|
@@ -116,7 +118,7 @@ refusal was relayed, verbatim, with its named route.
|
|
|
116
118
|
## Publish a new version of a published case
|
|
117
119
|
|
|
118
120
|
```bash
|
|
119
|
-
node <fito-case-author skill dir>/publish-version.js <case-working-dir> --change-description <file> --overview <file>
|
|
121
|
+
node "<fito-case-author skill dir>/publish-version.js" "<case-working-dir>" --change-description "<file>" --overview "<file>"
|
|
120
122
|
```
|
|
121
123
|
|
|
122
124
|
The end of the update workflow (ADR-009), driven by `/fito-publish-case` from an **edited,
|
|
@@ -167,7 +169,7 @@ registrations — it never guesses which case the checkout is).
|
|
|
167
169
|
| `checkout.ts` | CLI entrypoint — `runCheckout` core: fetch → status gate → direct clone of `main` → orient |
|
|
168
170
|
| `publish-version.ts` | CLI entrypoint — `runPublishVersion` core: validate → staleness guards → origin route → frozen-set preflight → push → `POST /cases/{id}/versions`; `--probe` resolves initial vs update |
|
|
169
171
|
| `publish-payload.ts` | Pure `.case/` → register/publish/version wire-payload mapping (+ publish facts) |
|
|
170
|
-
| `github-publish.ts` | Pure `gh`/`git` command builders (repo create, explicit-refspec push, guards) |
|
|
172
|
+
| `github-publish.ts` | Pure `gh`/`git` command builders (repo create, default branch, explicit-refspec push, guards) |
|
|
171
173
|
| `status-gate.ts` | One home for the case-status policy (ADR-009): the status → allow/refuse/hint mapping behind `checkout.ts`, `runPublishVersion`, and the probe's deprecated route |
|
|
172
174
|
| `publish-state.ts` | `~/.fito/publish-state.json` — the draft-id retry store |
|
|
173
175
|
| — | The real `gh`/`git` executor is the shared `../../shared/shell-exec/exec.ts` (ADR-006) |
|
|
@@ -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
|
|
29
|
-
* is the Task 9.7 contract (the publish flow lands
|
|
30
|
-
* a repo somehow missing it fails loudly here
|
|
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 {
|
|
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
|
|
73
|
-
* is the Task 9.7 contract (the publish flow lands
|
|
74
|
-
* a repo somehow missing it fails loudly here
|
|
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 {
|
|
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 {
|
|
@@ -39,14 +39,41 @@ export function ghAuthStatusCommand() {
|
|
|
39
39
|
export function ghCurrentLoginCommand() {
|
|
40
40
|
return { command: "gh", args: ["api", "user", "--jq", ".login"] };
|
|
41
41
|
}
|
|
42
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* `gh repo view <slug> --json isEmpty` — the existence probe (a re-run must never create a
|
|
44
|
+
* duplicate repo), which also tells whether the repo has no branch yet: `parseRepoIsEmpty` reads it.
|
|
45
|
+
*/
|
|
43
46
|
export function ghRepoViewCommand(slug) {
|
|
44
|
-
return { command: "gh", args: ["repo", "view", slug, "--json", "
|
|
47
|
+
return { command: "gh", args: ["repo", "view", slug, "--json", "isEmpty"] };
|
|
48
|
+
}
|
|
49
|
+
/** Read `gh repo view --json isEmpty`'s stdout: whether the repo has no branch yet. */
|
|
50
|
+
export function parseRepoIsEmpty(stdout) {
|
|
51
|
+
let parsed;
|
|
52
|
+
try {
|
|
53
|
+
parsed = JSON.parse(stdout);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
57
|
+
throw new Error(`gh repo view returned malformed JSON: ${detail}`);
|
|
58
|
+
}
|
|
59
|
+
return parsed.isEmpty === true;
|
|
45
60
|
}
|
|
46
61
|
/** `gh repo create <slug> --public --description <text>` — create the case repo (MVP is public-only), titled for its storefront; no clone, no push. */
|
|
47
62
|
export function ghRepoCreateCommand(slug, description) {
|
|
48
63
|
return { command: "gh", args: ["repo", "create", slug, "--public", "--description", description] };
|
|
49
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* `gh repo edit <slug> --default-branch main` — name `main` the default branch of a repo whose
|
|
67
|
+
* first push was this run's (Task 17.23). Left to itself, GitHub picks the default branch from the
|
|
68
|
+
* first push by a rule it does not document: the same push made `main` the default for one account
|
|
69
|
+
* and the solution branch for another (Task 17b.3, F1), and a solution-branch default shows the
|
|
70
|
+
* solution on the repo's page and checks it out on a plain `git clone`. Runs after the push, since
|
|
71
|
+
* GitHub cannot name a branch that does not exist yet. Needs admin rights on the repo, which
|
|
72
|
+
* GitHub gives whoever creates it — an organization member included.
|
|
73
|
+
*/
|
|
74
|
+
export function ghRepoSetDefaultBranchCommand(slug) {
|
|
75
|
+
return { command: "gh", args: ["repo", "edit", slug, "--default-branch", "main"] };
|
|
76
|
+
}
|
|
50
77
|
/** `git status --porcelain` — the clean-tree guard: what was validated must be exactly what is pushed. */
|
|
51
78
|
export function gitStatusPorcelainCommand() {
|
|
52
79
|
return { command: "git", args: ["status", "--porcelain"] };
|