fito-tui 0.5.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 +15 -5
- 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 +5 -2
- package/extensions/fito-startup.ts +5 -1
- package/package.json +1 -1
- package/prompts/fito-case-design.md +71 -16
- package/prompts/fito-case-generate.md +29 -10
- package/prompts/fito-case-open.md +17 -10
- package/prompts/fito-case-plan-source.md +13 -6
- 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/shared/case-briefing/briefing.js +1 -0
- package/shared/case-briefing/briefing.ts +1 -0
- package/skills/fito-case-author/SKILL.md +8 -6
- 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-url-content-fetcher/SKILL.md +53 -16
|
@@ -76,7 +76,14 @@ unless marked optional:
|
|
|
76
76
|
`exemplary` met well. They never climb from one Bloom level to the next.
|
|
77
77
|
`achieved` defines the award — a score of 2 or 3 records the criterion's
|
|
78
78
|
`bloom_level`, and 0 or 1 records `NOT_ACHIEVED` — so expand it with the
|
|
79
|
-
most care.
|
|
79
|
+
most care. Expand an `automated` criterion's rungs only into outcomes its
|
|
80
|
+
command's exit code and output show: the reviewer scores it from that output
|
|
81
|
+
alone, so detail the command does not print — a named call in the code, which
|
|
82
|
+
test covers a behavior, an explanation — makes a rung no learner can earn.
|
|
83
|
+
When a sketch already asks for such detail, raise it with the author, with
|
|
84
|
+
the two repairs: rewrite the rung as an outcome the command shows, or move
|
|
85
|
+
that judgement to an `ai` criterion.
|
|
86
|
+
Weights must sum to exactly 100; each `evaluation_method`
|
|
80
87
|
completed — `automated` needs `command` + `passing_condition` (real gate
|
|
81
88
|
commands from the proposal, never guessed), `ai` needs a `prompt_hint`. On
|
|
82
89
|
greenfield, where no source tree exists yet, derive the `automated` command
|
|
@@ -101,6 +108,15 @@ unless marked optional:
|
|
|
101
108
|
(`failing_tests`, `known_errors`, `build_status`, …); it carries no `branch`
|
|
102
109
|
field — `.case/` describes the case on every ref, so a branch value can
|
|
103
110
|
never be branch-correct (SPEC deviation #5).
|
|
111
|
+
- `starter_state/setup_instructions.md` (optional) — what the learner installs
|
|
112
|
+
before the first build, which they read when the case opens. Write it from
|
|
113
|
+
the proposal's `toolchain` entries with `provided_by: learner`: each tool,
|
|
114
|
+
its minimum line, and "or newer" (e.g. "JDK 21 or newer"). Write it exactly
|
|
115
|
+
when the toolchain has a `learner` entry: the build fetches every `project`
|
|
116
|
+
tool itself, so a toolchain of `project` entries alone leaves the learner
|
|
117
|
+
nothing to install. An entry that does not name who provides it — from a
|
|
118
|
+
proposal written before the field existed — is settled with the author
|
|
119
|
+
first.
|
|
104
120
|
- `solution/notes.md` — the evaluator-only rationale: the intended approach
|
|
105
121
|
and what each rubric criterion should see; refined again after the source
|
|
106
122
|
work. `solution/notes-template.md` — the blank authoring scaffold of the
|
|
@@ -150,11 +166,12 @@ Four rules bind the content:
|
|
|
150
166
|
Then present the contract for the author's review — a **digest**, not a file
|
|
151
167
|
dump: type and duration, the learning objectives and prerequisites (ids + Bloom
|
|
152
168
|
levels), each rubric criterion with its weight and evaluation method, the
|
|
153
|
-
situation documents, whether a quiz rides along,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
169
|
+
situation documents, whether a quiz rides along, the tools
|
|
170
|
+
`setup_instructions.md` names (or that the case has none), and the **optional
|
|
171
|
+
fields the contract leaves empty**. Run step 5's validator command now and read
|
|
172
|
+
that last item from its `optionalFieldsNotUsed`, rather than judging emptiness
|
|
173
|
+
by eye — an optional field is the one thing the validator can never reject, so
|
|
174
|
+
it stays invisible unless the run reports it. **A failing run reports no inventory at
|
|
158
175
|
all**: apply step 5's failure loop here until the tree passes, so the digest
|
|
159
176
|
describes a valid contract and step 4 never commits a broken tree. Each unused
|
|
160
177
|
field is legal and often right; naming them here is what lets the author fill
|
|
@@ -162,10 +179,12 @@ one, or leave it, while the tree is still uncommitted. Walk through any file
|
|
|
162
179
|
the author asks to see, and iterate on their feedback **before anything is
|
|
163
180
|
committed** — the author owns every value in the contract.
|
|
164
181
|
|
|
165
|
-
**Done when** every file above exists in `.case/` (plus `quiz.yaml`
|
|
166
|
-
when the proposal has quiz items
|
|
167
|
-
|
|
168
|
-
|
|
182
|
+
**Done when** every required file above exists in `.case/` (plus `quiz.yaml`
|
|
183
|
+
exactly when the proposal has quiz items, and
|
|
184
|
+
`starter_state/setup_instructions.md` exactly when its toolchain has a
|
|
185
|
+
`learner` entry), the four rules hold, the validator exits 0 on the tree, and
|
|
186
|
+
the author has reviewed the digest — unused optional fields included — and
|
|
187
|
+
confirmed the contract.
|
|
169
188
|
|
|
170
189
|
## 4. Put the working directory on git
|
|
171
190
|
|
|
@@ -25,9 +25,12 @@ re-validates** the `.case/` checkout, and creates the working branch.
|
|
|
25
25
|
- If it prints a "case source malformed" report (structural errors and **no**
|
|
26
26
|
branch created), **stop here — do not orient.** Show the errors and the report
|
|
27
27
|
affordance; suggest re-running `/fito-case-open $1` later or reporting the case.
|
|
28
|
-
- It refuses to overwrite a non-empty existing checkout.
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
- It refuses to overwrite a non-empty existing checkout. This refusal is the
|
|
29
|
+
one non-zero exit that leads on to the briefing: ask the learner whether
|
|
30
|
+
that folder is their earlier opening of this case. If yes, point them at the
|
|
31
|
+
existing checkout, whose path the refusal prints, and `/fito-submit $1`, and
|
|
32
|
+
go on to step 2 with it. If no, relay the refusal and stop — the folder is
|
|
33
|
+
theirs to move or remove.
|
|
31
34
|
- If it refuses because the case is **deprecated**, relay its message verbatim
|
|
32
35
|
and stop — do not orient, and never work around the refusal with raw git
|
|
33
36
|
commands.
|
|
@@ -45,9 +48,10 @@ re-validates** the `.case/` checkout, and creates the working branch.
|
|
|
45
48
|
`gh auth login` with the Fito-linked GitHub account, then retry.
|
|
46
49
|
|
|
47
50
|
**Done when** it prints `Case opened at:` with the checkout path and `on branch
|
|
48
|
-
'<name>'` (or
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
'<name>'` (or the learner confirmed that the folder the refusal names is their
|
|
52
|
+
earlier opening of this case). On any other non-zero exit, stop here — do not
|
|
53
|
+
orient. Below, `<checkout>` is that path — the one after `Case opened at:`, or
|
|
54
|
+
the one the already-open refusal names — used exactly as printed.
|
|
51
55
|
|
|
52
56
|
## 2. Brief the learner on the case
|
|
53
57
|
|
|
@@ -65,11 +69,14 @@ Present, in this order:
|
|
|
65
69
|
learner reads it in context — a `ticket`, an `email`, a `log_output`, a
|
|
66
70
|
`chat_thread`, a `pull_request_description`, or plain `prose`. Do not reorder
|
|
67
71
|
or skip any.
|
|
68
|
-
3. **
|
|
72
|
+
3. **Setup** — if the file is present, `.case/starter_state/setup_instructions.md`:
|
|
73
|
+
the tools the learner installs before the first build, each at its minimum
|
|
74
|
+
line. It comes before the task, so the learner can install them first.
|
|
75
|
+
4. **Task** — `.case/task/objective.md` (the single goal). Then, **if the file is
|
|
69
76
|
present**, `.case/task/constraints.md` (rules the learner must follow) and, for
|
|
70
77
|
`tutorial` cases, `.case/task/steps.md`. Then summarize
|
|
71
78
|
`.case/task/deliverables.yaml` — the expected outputs.
|
|
72
|
-
|
|
79
|
+
5. **Artifacts** — point the learner at `.case/artifacts.yaml`, the annotated map
|
|
73
80
|
of relevant repo files (evidence / target / reference / scaffold). Call out the
|
|
74
81
|
`target` files they will most likely change.
|
|
75
82
|
|
|
@@ -77,8 +84,8 @@ Keep the briefing calm and precise — a knowledgeable peer handing off a case,
|
|
|
77
84
|
a pitch.
|
|
78
85
|
|
|
79
86
|
**Done when** every situation document has been rendered in order and the header,
|
|
80
|
-
|
|
81
|
-
all surfaced.
|
|
87
|
+
the setup instructions (when the case has them), task (objective + any
|
|
88
|
+
constraints/steps + deliverables), and key artifacts are all surfaced.
|
|
82
89
|
|
|
83
90
|
## 3. Ground the case in the knowledge vocabulary
|
|
84
91
|
|
|
@@ -40,7 +40,10 @@ case directory, else `./case-proposal.md` — where `/fito-case-design` writes
|
|
|
40
40
|
it by default. Name the file you found when you confirm the scenario. If
|
|
41
41
|
`--proposal` names a missing file, or neither default exists, ask the author
|
|
42
42
|
for the proposal's path; an author without one gives each technology's
|
|
43
|
-
declared major-line version and the toolchain instead.
|
|
43
|
+
declared major-line version and the toolchain instead. Every toolchain entry
|
|
44
|
+
names who provides it — `learner` or `project` — and the author settles any
|
|
45
|
+
entry that does not, such as one from a proposal written before the field
|
|
46
|
+
existed.
|
|
44
47
|
|
|
45
48
|
If the documents already exist under `.authoring/`, this is a revision run:
|
|
46
49
|
say so and ask what should change — the feedback rides along in step 2; never
|
|
@@ -58,9 +61,11 @@ scenario, the declared `{slug, version}` technology pairs and the
|
|
|
58
61
|
in its place), and (on a revision run) the author's feedback. The pairs
|
|
59
62
|
**version-scope** the planner's knowledge fetches (each component reads
|
|
60
63
|
for the case's declared major line, not another); the toolchain grounds a
|
|
61
|
-
greenfield scaffold
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
greenfield scaffold, and its `learner` entries — the tools the learner
|
|
65
|
+
installs — are the ones the build must accept at their line or newer. The
|
|
66
|
+
planner reads the `.case/` contract — the rubric gates,
|
|
67
|
+
`starter_state/known_state.yaml`, task, situation, `solution.yaml` — skims
|
|
68
|
+
the source on reuse, and writes the two documents into `.authoring/`.
|
|
64
69
|
|
|
65
70
|
This delegation blocks — you read the child's summary from the tool result.
|
|
66
71
|
|
|
@@ -75,8 +80,10 @@ hand.
|
|
|
75
80
|
## 3. Review with the author
|
|
76
81
|
|
|
77
82
|
Relay the worker's **digest** — scenario, both terminal states, plan-step
|
|
78
|
-
count, gates covered,
|
|
79
|
-
|
|
83
|
+
count, gates covered, the `learner` tools with their minimum lines, any plan
|
|
84
|
+
step that lifts a limit on one and any it flagged as a gap, any contract
|
|
85
|
+
conflict it surfaced, and its **toolchain cross-check** section — not a file
|
|
86
|
+
dump. Any mismatch there is **advisory** (a
|
|
80
87
|
declared toolchain contradicting a technology version's stated requirements,
|
|
81
88
|
e.g. Javalin 7 wanting Java 17+ against a Java 11 toolchain): surface it for
|
|
82
89
|
the author to reconcile the declaration — it is **not** a contract conflict, so
|
|
@@ -63,7 +63,7 @@ Parse `$ARGUMENTS` to extract:
|
|
|
63
63
|
|
|
64
64
|
> "Content template not found. The Fito package installation may be incomplete."
|
|
65
65
|
|
|
66
|
-
7. Pull the registered `Template` **field-schema** for the `concept` type from the backend Knowledge Repository — the authoritative field structure (keys, labels, types, requirements) the generated `content` must conform to. A component type carries **several** registered templates — one variant per technology kind, plus a shared `any` variant — and the subject technology's own `kind` selects which applies: an exact `tool` or `practice` match, otherwise the `any` variant. That is the `kind` resolved in step 2
|
|
66
|
+
7. Pull the registered `Template` **field-schema** for the `concept` type from the backend Knowledge Repository — the authoritative field structure (keys, labels, types, requirements) the generated `content` must conform to. Call the `fito_template_fetch` tool once, with the type `concept` and the technology slug (the read is public — no login). A component type carries **several** registered templates — one variant per technology kind, plus a shared `any` variant — and the subject technology's own `kind` selects which applies: an exact `tool` or `practice` match, otherwise the `any` variant. That is the `kind` resolved in step 2, and the tool reads it from the technology itself. The variant follows from the subject, so nothing names one directly; the push resolves it the same way, making this the schema the component is stored under. If the call fails, report the error **verbatim** and stop — the push checks every file against this same schema, so a guess here only moves the failure to the push.
|
|
67
67
|
|
|
68
68
|
8. Create the output directory if it does not exist.
|
|
69
69
|
|
|
@@ -63,7 +63,7 @@ Parse `$ARGUMENTS` to extract:
|
|
|
63
63
|
|
|
64
64
|
> "Content template not found. The Fito package installation may be incomplete."
|
|
65
65
|
|
|
66
|
-
7. Pull the registered `Template` **field-schema** for the `execution-fact` type from the backend Knowledge Repository — the authoritative field structure (keys, labels, types, requirements, the `optional_sections_included` trigger mechanism) the generated `content` must conform to. A component type carries **several** registered templates — one variant per technology kind, plus a shared `any` variant — and the subject technology's own `kind` selects which applies: an exact `tool` or `practice` match, otherwise the `any` variant. That is the `kind` resolved in step 2
|
|
66
|
+
7. Pull the registered `Template` **field-schema** for the `execution-fact` type from the backend Knowledge Repository — the authoritative field structure (keys, labels, types, requirements, the `optional_sections_included` trigger mechanism) the generated `content` must conform to. Call the `fito_template_fetch` tool once, with the type `execution-fact` and the technology slug (the read is public — no login). A component type carries **several** registered templates — one variant per technology kind, plus a shared `any` variant — and the subject technology's own `kind` selects which applies: an exact `tool` or `practice` match, otherwise the `any` variant. That is the `kind` resolved in step 2, and the tool reads it from the technology itself. The variant follows from the subject, so nothing names one directly; the push resolves it the same way, making this the schema the component is stored under. If the call fails, report the error **verbatim** and stop — the push checks every file against this same schema, so a guess here only moves the failure to the push.
|
|
67
67
|
|
|
68
68
|
8. Create the output directory if it does not exist.
|
|
69
69
|
|
|
@@ -63,7 +63,7 @@ Parse `$ARGUMENTS` to extract:
|
|
|
63
63
|
|
|
64
64
|
> "Content template not found. The Fito package installation may be incomplete."
|
|
65
65
|
|
|
66
|
-
7. Pull the registered `Template` **field-schema** for the `usage-scenario` type from the backend Knowledge Repository — the authoritative field structure (keys, labels, types, requirements) the generated `content` must conform to. A component type carries **several** registered templates — one variant per technology kind, plus a shared `any` variant — and the subject technology's own `kind` selects which applies: an exact `tool` or `practice` match, otherwise the `any` variant. That is the `kind` resolved in step 2
|
|
66
|
+
7. Pull the registered `Template` **field-schema** for the `usage-scenario` type from the backend Knowledge Repository — the authoritative field structure (keys, labels, types, requirements) the generated `content` must conform to. Call the `fito_template_fetch` tool once, with the type `usage-scenario` and the technology slug (the read is public — no login). A component type carries **several** registered templates — one variant per technology kind, plus a shared `any` variant — and the subject technology's own `kind` selects which applies: an exact `tool` or `practice` match, otherwise the `any` variant. That is the `kind` resolved in step 2, and the tool reads it from the technology itself. For this type the `any` row is the only one registered, so both kinds land on it; the variant follows from the subject, so nothing names one directly, and the push resolves it the same way, making this the schema the component is stored under. If the call fails, report the error **verbatim** and stop — the push checks every file against this same schema, so a guess here only moves the failure to the push.
|
|
67
67
|
|
|
68
68
|
8. Create the output directory if it does not exist.
|
|
69
69
|
|
|
@@ -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" },
|
|
@@ -62,9 +62,10 @@ node "<fito-case-author skill dir>/publish.js" "<case-working-dir>" --repo <owne
|
|
|
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
|
|
@@ -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) |
|
|
@@ -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"] };
|
|
@@ -56,9 +56,24 @@ export function ghCurrentLoginCommand(): ShellCommand {
|
|
|
56
56
|
return { command: "gh", args: ["api", "user", "--jq", ".login"] };
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
/**
|
|
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", "
|
|
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 →
|
|
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 →
|
|
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}`);
|