fito-tui 0.2.1 → 0.4.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/README.md +2 -86
- package/package.json +8 -4
- package/prompts/fito-auth-refresh.md +3 -3
- package/prompts/fito-evaluate.md +10 -5
- package/prompts/fito-login.md +3 -3
- package/prompts/fito-logout.md +3 -3
- package/prompts/fito-push-knowledge.md +61 -65
- package/prompts/fito-submit.md +7 -2
- package/shared/competences/competence-list.js +1 -1
- package/shared/competences/competence-list.ts +1 -1
- package/shared/fito-api/README.md +1 -1
- package/shared/fito-api/client.js +7 -11
- package/shared/fito-api/client.ts +8 -12
- package/shared/fito-session/credentials.js +27 -15
- package/shared/fito-session/credentials.ts +33 -15
- package/shared/fito-session/session.js +7 -5
- package/shared/fito-session/session.ts +10 -7
- package/shared/fito-url/fito-url.js +29 -0
- package/shared/fito-url/fito-url.ts +32 -0
- package/shared/knowledge-components/knowledge-fetch.js +1 -1
- package/shared/knowledge-components/knowledge-fetch.ts +1 -1
- package/shared/knowledge-components/knowledge-search.js +1 -1
- package/shared/knowledge-components/knowledge-search.ts +1 -1
- package/shared/knowledge-components/technology-fetch.js +1 -1
- package/shared/knowledge-components/technology-fetch.ts +1 -1
- package/{skills/fito-case-author → shared/semver}/semver.js +8 -0
- package/{skills/fito-case-author → shared/semver}/semver.ts +9 -0
- package/skills/fito-auth/SKILL.md +12 -19
- package/skills/fito-auth/auth-refresh.js +3 -2
- package/skills/fito-auth/auth-refresh.ts +3 -2
- package/skills/fito-auth/login.js +7 -6
- package/skills/fito-auth/login.ts +7 -6
- package/skills/fito-auth/logout.js +3 -2
- package/skills/fito-auth/logout.ts +3 -2
- package/skills/fito-case-author/SKILL.md +1 -3
- package/skills/fito-case-author/publish-version.js +5 -5
- package/skills/fito-case-author/publish-version.ts +7 -7
- package/skills/fito-case-author/publish.js +5 -5
- package/skills/fito-case-author/publish.ts +7 -7
- package/skills/fito-case-runner/SKILL.md +10 -6
- package/skills/fito-case-runner/case-component-names.ts +1 -1
- package/skills/fito-case-runner/fito-url.js +8 -0
- package/skills/fito-case-runner/fito-url.ts +9 -0
- package/skills/fito-case-runner/open.ts +1 -1
- package/skills/fito-competence-write/SKILL.md +0 -6
- package/skills/fito-knowledge-push/SKILL.md +55 -76
- package/skills/fito-knowledge-push/push.js +169 -77
- package/skills/fito-knowledge-push/push.ts +210 -84
- package/skills/fito-source-ingestion/SKILL.md +0 -6
- package/skills/fito-source-ingestion/authoring-check.ts +1 -1
- package/skills/fito-technology-write/SKILL.md +0 -6
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
* (Task 8.7): similar existing components — even below the hard 409 bar — stop the push with
|
|
6
6
|
* their similarities and the choices printed, before anything is stored; `--proceed` is the
|
|
7
7
|
* author's decision to store anyway and skips the probe. Then it creates-and-publishes; on a
|
|
8
|
-
* near-duplicate 409 it stops and prints the duplicate
|
|
9
|
-
*
|
|
8
|
+
* near-duplicate 409 it stops and prints the duplicate and the choices — it never resolves a 409 or
|
|
9
|
+
* a probe stop itself. Each stop prints a message in the author's words above [AGENT_MARKER], which
|
|
10
|
+
* the `/fito-push-knowledge` orchestrator shows word for word, and one command per choice below it.
|
|
10
11
|
* The author's explicit choice comes back as a re-run with exactly one flag: `--link`
|
|
11
|
-
* (alternative definition of the duplicate), `--supersede` (the duplicate's new
|
|
12
|
-
* `--version`
|
|
13
|
-
* exact reference the 409 reported), or `--proceed`. Skipping is
|
|
12
|
+
* (alternative definition of the duplicate), `--supersede` (the duplicate's new revision; requires
|
|
13
|
+
* a `--version` label newer than the duplicate's), `--override` (store an independent
|
|
14
|
+
* near-duplicate, echoing the exact reference the 409 reported), or `--proceed`. Skipping is
|
|
15
|
+
* simply not re-running.
|
|
14
16
|
*
|
|
15
17
|
* `runPush` is the testable core (injectable client/home); `main` is the thin CLI wrapper.
|
|
16
18
|
*/
|
|
@@ -34,15 +36,18 @@ import {
|
|
|
34
36
|
type GeneratorPayload,
|
|
35
37
|
} from "../../shared/knowledge-components/push-payload.ts";
|
|
36
38
|
import { parseKnowledgeReference } from "../../shared/knowledge-components/reference.ts";
|
|
39
|
+
import { isSemVer, isStrictlyGreaterSemVer } from "../../shared/semver/semver.ts";
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
42
|
* The fito-api surface this flow needs: the session lookup, the template read, the technology read
|
|
40
|
-
* (whose `kind` selects the template variant — Task 9c.2), the
|
|
43
|
+
* (whose `kind` selects the template variant — Task 9c.2), the component read (a supersede's
|
|
44
|
+
* target, for its current revision), the advisory probe, and the three writes.
|
|
41
45
|
*/
|
|
42
46
|
type PushClient = Pick<
|
|
43
47
|
FitoApiClient,
|
|
44
48
|
| "meWithRefresh"
|
|
45
49
|
| "getKnowledgeTemplates"
|
|
50
|
+
| "getKnowledgeComponent"
|
|
46
51
|
| "getTechnology"
|
|
47
52
|
| "probeNearDuplicates"
|
|
48
53
|
| "createKnowledgeComponent"
|
|
@@ -70,7 +75,10 @@ export interface RunPushOptions {
|
|
|
70
75
|
* explicit author decision).
|
|
71
76
|
*/
|
|
72
77
|
proceed?: boolean;
|
|
73
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Component revision label; omitted → the backend defaults `1.0.0`. Required on a supersede, and
|
|
80
|
+
* newer than the target's revision there — see [revisionLabelProblem].
|
|
81
|
+
*/
|
|
74
82
|
version?: string;
|
|
75
83
|
home?: string;
|
|
76
84
|
client?: PushClient;
|
|
@@ -79,11 +87,20 @@ export interface RunPushOptions {
|
|
|
79
87
|
/**
|
|
80
88
|
* A push run's result: `created` carries the persisted component; `near-misses` means the
|
|
81
89
|
* advisory probe found similar existing components and nothing was stored — the author chooses
|
|
82
|
-
* how to continue (link / supersede / proceed / skip)
|
|
90
|
+
* how to continue (link / supersede / proceed / skip); `revision-label-refused` means a supersede's
|
|
91
|
+
* label is missing or not newer than its target's revision, and nothing was stored.
|
|
83
92
|
*/
|
|
84
93
|
export type PushOutcome =
|
|
85
94
|
| { kind: "created"; component: KnowledgeComponent }
|
|
86
|
-
| { kind: "near-misses"; matches: NearDuplicateMatch[] }
|
|
95
|
+
| { kind: "near-misses"; matches: NearDuplicateMatch[] }
|
|
96
|
+
| ({ kind: "revision-label-refused" } & RevisionLabelRefusal);
|
|
97
|
+
|
|
98
|
+
/** Why a supersede's revision label was refused, with the target it was checked against. */
|
|
99
|
+
export interface RevisionLabelRefusal {
|
|
100
|
+
problem: "missing" | "not-a-version" | "not-newer";
|
|
101
|
+
label?: string;
|
|
102
|
+
target: KnowledgeComponent;
|
|
103
|
+
}
|
|
87
104
|
|
|
88
105
|
/**
|
|
89
106
|
* Push one payload: read + validate it, resolve the Fito session and the registered template — by
|
|
@@ -126,6 +143,11 @@ export async function runPush(options: RunPushOptions): Promise<PushOutcome> {
|
|
|
126
143
|
}
|
|
127
144
|
case "supersede": {
|
|
128
145
|
const target = resolveTarget(resolution.target, payload);
|
|
146
|
+
const current = await client.getKnowledgeComponent(target.type, target.slug);
|
|
147
|
+
const problem = revisionLabelProblem(options.version, current.version);
|
|
148
|
+
if (problem) {
|
|
149
|
+
return { kind: "revision-label-refused", problem, label: options.version, target: current };
|
|
150
|
+
}
|
|
129
151
|
return created(client.createNewVersion(tokens.accessToken, target.type, target.slug, input));
|
|
130
152
|
}
|
|
131
153
|
case "override": {
|
|
@@ -139,6 +161,19 @@ export async function runPush(options: RunPushOptions): Promise<PushOutcome> {
|
|
|
139
161
|
}
|
|
140
162
|
}
|
|
141
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Check a supersede's revision label against the target's current revision. Without a label the
|
|
166
|
+
* backend would store `1.0.0` — the same label as a first revision — so the two revisions could not
|
|
167
|
+
* be told apart. A target whose own revision is not SemVer cannot be compared, so any SemVer label
|
|
168
|
+
* passes there; refusing would block that component's revisions forever.
|
|
169
|
+
*/
|
|
170
|
+
function revisionLabelProblem(label: string | undefined, current: string): RevisionLabelRefusal["problem"] | undefined {
|
|
171
|
+
if (!label) return "missing";
|
|
172
|
+
if (!isSemVer(label)) return "not-a-version";
|
|
173
|
+
if (isSemVer(current) && !isStrictlyGreaterSemVer(label, current)) return "not-newer";
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
|
|
142
177
|
/**
|
|
143
178
|
* Parse a resolution target reference and require its type to match the payload's: a link is an
|
|
144
179
|
* alternative definition (same type by the domain model) and a supersede is a version of the same
|
|
@@ -158,117 +193,203 @@ function resolveTarget(reference: string, payload: GeneratorPayload): { type: Ge
|
|
|
158
193
|
/** Load one generator payload file, failing with an actionable message on any malformed input. */
|
|
159
194
|
function readPayload(payloadPath: string): GeneratorPayload {
|
|
160
195
|
if (!existsSync(payloadPath)) {
|
|
161
|
-
throw new Error(`No
|
|
196
|
+
throw new Error(`No file at ${payloadPath}.`);
|
|
162
197
|
}
|
|
163
198
|
let raw: string;
|
|
164
199
|
try {
|
|
165
200
|
raw = readFileSync(payloadPath, "utf8");
|
|
166
201
|
} catch (error) {
|
|
167
202
|
const detail = error instanceof Error ? error.message : String(error);
|
|
168
|
-
throw new Error(`Could not read
|
|
203
|
+
throw new Error(`Could not read ${payloadPath}: ${detail}`);
|
|
169
204
|
}
|
|
170
205
|
let parsed: unknown;
|
|
171
206
|
try {
|
|
172
207
|
parsed = JSON.parse(raw);
|
|
173
208
|
} catch {
|
|
174
|
-
throw new Error(
|
|
209
|
+
throw new Error(`${payloadPath} is not valid JSON.`);
|
|
175
210
|
}
|
|
176
211
|
const result = generatorPayloadSchema.safeParse(parsed);
|
|
177
212
|
if (!result.success) {
|
|
178
213
|
throw new Error(
|
|
179
|
-
|
|
214
|
+
`${payloadPath} is not a generated component file. Generate it again.\n Details: ${result.error.message}`,
|
|
180
215
|
);
|
|
181
216
|
}
|
|
182
217
|
return result.data;
|
|
183
218
|
}
|
|
184
219
|
|
|
220
|
+
/** A component file being pushed, and its component's name when the file could be read. */
|
|
221
|
+
export interface PushFile {
|
|
222
|
+
path: string;
|
|
223
|
+
componentName?: string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** The pushed file, named by its component when it reads cleanly — for the messages only. */
|
|
227
|
+
function pushFileOf(payloadPath: string): PushFile {
|
|
228
|
+
try {
|
|
229
|
+
return { path: payloadPath, componentName: readPayload(payloadPath).metadata.name };
|
|
230
|
+
} catch {
|
|
231
|
+
return { path: payloadPath };
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** How every message names a file: `"Name" (path)`, or the path alone when the name is unknown. */
|
|
236
|
+
function describeFile(file: PushFile): string {
|
|
237
|
+
return file.componentName === undefined ? file.path : `"${file.componentName}" (${file.path})`;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* The line that ends every message for the author. The orchestrator shows the author everything
|
|
242
|
+
* above it, word for word, and runs the command below it that matches the author's choice.
|
|
243
|
+
*/
|
|
244
|
+
export const AGENT_MARKER = "--- Commands for the agent ---";
|
|
245
|
+
|
|
246
|
+
/** The next major revision after [current] — the example a label refusal suggests. */
|
|
247
|
+
function nextMajorRevision(current: string): string {
|
|
248
|
+
return isSemVer(current) ? `${Number(current.split(".")[0]) + 1}.0.0` : "2.0.0";
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** The longest choice name: every description, and every command for the agent, starts after it. */
|
|
252
|
+
const CHOICE_WIDTH = "Create new component".length;
|
|
253
|
+
|
|
254
|
+
/** One choice in a stop: its name and description for the author, and the command the agent runs. */
|
|
255
|
+
interface Choice {
|
|
256
|
+
name: string;
|
|
257
|
+
/** Continuation lines align under the first. */
|
|
258
|
+
description: string[];
|
|
259
|
+
/** None for Skip, which runs nothing. */
|
|
260
|
+
command?: string;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** The question and its choices for the author, then the marker and one command per choice for the agent. */
|
|
264
|
+
function renderChoices(choices: Choice[]): string[] {
|
|
265
|
+
const indent = " ".repeat(2 + CHOICE_WIDTH + 2);
|
|
266
|
+
const forAuthor = choices.flatMap(({ name, description: [first, ...rest] }) => [
|
|
267
|
+
` ${name.padEnd(CHOICE_WIDTH)} ${first}`,
|
|
268
|
+
...rest.map((line) => `${indent}${line}`),
|
|
269
|
+
]);
|
|
270
|
+
const forAgent = choices.flatMap(({ name, command }) =>
|
|
271
|
+
command === undefined ? [] : [`${name.padEnd(CHOICE_WIDTH)} ${command}`],
|
|
272
|
+
);
|
|
273
|
+
return ["What do you want to do?", ...forAuthor, "", AGENT_MARKER, ...forAgent];
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** Render a refused supersede label into the message for the author, plus the re-run for the agent. */
|
|
277
|
+
export function renderRevisionLabelRefusal(refusal: RevisionLabelRefusal, payloadPath: string): string {
|
|
278
|
+
const { problem, label, target } = refusal;
|
|
279
|
+
const example = nextMajorRevision(target.version);
|
|
280
|
+
const forAuthor =
|
|
281
|
+
problem === "missing"
|
|
282
|
+
? [
|
|
283
|
+
`Supersede needs a revision label for the new revision of "${target.name}".`,
|
|
284
|
+
`Its current revision is ${target.version}. Give a newer label, for example ${example}.`,
|
|
285
|
+
]
|
|
286
|
+
: problem === "not-a-version"
|
|
287
|
+
? [`The label "${label}" is not a revision number. Use the form X.Y.Z, for example ${example}.`]
|
|
288
|
+
: [
|
|
289
|
+
`The label ${label} is not newer than the current revision of "${target.name}", ${target.version}.`,
|
|
290
|
+
`Give a newer label, for example ${example}.`,
|
|
291
|
+
];
|
|
292
|
+
return [
|
|
293
|
+
...forAuthor,
|
|
294
|
+
"",
|
|
295
|
+
AGENT_MARKER,
|
|
296
|
+
`Supersede node push.js ${payloadPath} --supersede '${target.id}' --version <label>`,
|
|
297
|
+
].join("\n");
|
|
298
|
+
}
|
|
299
|
+
|
|
185
300
|
/**
|
|
186
|
-
* Render a knowledge write 409 into the
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* supersede at the chain head the backend reported.
|
|
301
|
+
* Render a knowledge write 409 into the message for the author, or `undefined` when the error is
|
|
302
|
+
* not one of the two conflicts. The duplicate stop names the duplicate and the four choices, with
|
|
303
|
+
* Create new component's consequence stated in its description; the superseded-target stop offers
|
|
304
|
+
* to supersede the newest revision the backend reported.
|
|
191
305
|
*/
|
|
192
|
-
export function renderPushConflict(error: FitoApiError,
|
|
306
|
+
export function renderPushConflict(error: FitoApiError, file: PushFile): string | undefined {
|
|
193
307
|
if (error.duplicateId) {
|
|
194
308
|
const ref = error.duplicateId;
|
|
195
309
|
return [
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
` duplicate: ${ref}`,
|
|
310
|
+
`${describeFile(file)} was not stored.`,
|
|
311
|
+
`It is almost the same as ${ref}, which Fito already has.`,
|
|
199
312
|
"",
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
313
|
+
...renderChoices([
|
|
314
|
+
{
|
|
315
|
+
name: "Link",
|
|
316
|
+
description: [`Store it as an alternative definition of ${ref}.`],
|
|
317
|
+
command: `node push.js ${file.path} --link '${ref}'`,
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
name: "Supersede",
|
|
321
|
+
description: [`Store it as the next revision of ${ref}.`],
|
|
322
|
+
command: `node push.js ${file.path} --supersede '${ref}'`,
|
|
323
|
+
},
|
|
324
|
+
{ name: "Skip", description: ["Store nothing for this file."] },
|
|
325
|
+
{
|
|
326
|
+
name: "Create new component",
|
|
327
|
+
description: ["Store it as a separate component. Fito will then have two", "almost identical components."],
|
|
328
|
+
command: `node push.js ${file.path} --override '${ref}'`,
|
|
329
|
+
},
|
|
330
|
+
]),
|
|
210
331
|
].join("\n");
|
|
211
332
|
}
|
|
212
333
|
if (error.supersededBy) {
|
|
213
334
|
const head = error.supersededBy;
|
|
214
335
|
return [
|
|
215
|
-
`
|
|
336
|
+
`The component you chose to supersede already has a newer revision: ${head}.`,
|
|
337
|
+
"A new revision must follow the newest one. Do you want to supersede that one?",
|
|
216
338
|
"",
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
"Version chains are linear — a new version must target the chain head. Offer the author",
|
|
220
|
-
"a re-run against the reported successor:",
|
|
221
|
-
` node push.js ${payloadPath} --supersede '${head}' [--version <label>]`,
|
|
339
|
+
AGENT_MARKER,
|
|
340
|
+
`Supersede node push.js ${file.path} --supersede '${head}'`,
|
|
222
341
|
].join("\n");
|
|
223
342
|
}
|
|
224
343
|
return undefined;
|
|
225
344
|
}
|
|
226
345
|
|
|
346
|
+
/** A backend refusal that is not a conflict: which component was not stored, and the backend's reason. */
|
|
347
|
+
export function renderFailure(error: FitoApiError, file: PushFile): string {
|
|
348
|
+
return `✗ ${describeFile(file)} was not stored: ${error.message}`;
|
|
349
|
+
}
|
|
350
|
+
|
|
227
351
|
/**
|
|
228
|
-
* Render the advisory probe's near-misses into the
|
|
229
|
-
*
|
|
230
|
-
* has been stored when this block prints.
|
|
352
|
+
* Render the advisory probe's near-misses into the message for the author. Similarities are shown
|
|
353
|
+
* so the author can judge how close each match really is. Nothing has been stored when it prints.
|
|
231
354
|
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* because only a same-line match is one the hard gate would refuse: linking to a cross-line match
|
|
236
|
-
* would mint the `alternativeDefinitionOf` edge ADR-011 §7 forbids for divergence across majors,
|
|
237
|
-
* and superseding one is worse still — a new version inherits its predecessor's version scope, so
|
|
238
|
-
* the component would silently land on the wrong line.
|
|
355
|
+
* The backend reports only matches sharing a major line with the candidate, so every match is one
|
|
356
|
+
* link or supersede can target, and the commands target the closest. Called only with at least one
|
|
357
|
+
* match: an empty probe report stores the component.
|
|
239
358
|
*/
|
|
240
|
-
export function renderNearMisses(matches: NearDuplicateMatch[],
|
|
359
|
+
export function renderNearMisses(matches: NearDuplicateMatch[], file: PushFile): string {
|
|
360
|
+
const nameWidth = Math.max(...matches.map((match) => match.name.length + 2));
|
|
241
361
|
const listed = matches.map((match) => {
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
return (
|
|
245
|
-
` ${match.similarity.toFixed(2)} ${match.id} — "${match.name}" ` +
|
|
246
|
-
`(revision ${match.version}, applies to ${appliesTo} — ${scope})`
|
|
247
|
-
);
|
|
362
|
+
const similarity = `${Math.round(match.similarity * 100)}%`.padStart(4);
|
|
363
|
+
return ` ${similarity} similar ${`"${match.name}"`.padEnd(nameWidth)} ${match.id}`;
|
|
248
364
|
});
|
|
249
|
-
const
|
|
250
|
-
// With no same-line match there is nothing to link or supersede against: the gate would admit
|
|
251
|
-
// this candidate, and §7 says divergence across majors is separate components, not links.
|
|
252
|
-
const resolutions =
|
|
253
|
-
closestSameLine === undefined
|
|
254
|
-
? [" every match above is on a different major line, so none is a duplicate of this candidate"]
|
|
255
|
-
: [
|
|
256
|
-
` link node push.js ${payloadPath} --link '${closestSameLine.id}'`,
|
|
257
|
-
" store as an alternative definition of the closest same-line match (preferred)",
|
|
258
|
-
` supersede node push.js ${payloadPath} --supersede '${closestSameLine.id}' [--version <label>]`,
|
|
259
|
-
" store as the closest same-line match's new version (preferred)",
|
|
260
|
-
];
|
|
365
|
+
const closest = matches[0];
|
|
261
366
|
return [
|
|
262
|
-
|
|
367
|
+
`${describeFile(file)} was not stored.`,
|
|
368
|
+
"Fito already has components that are similar to it:",
|
|
263
369
|
"",
|
|
264
370
|
...listed,
|
|
265
371
|
"",
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
372
|
+
...renderChoices([
|
|
373
|
+
{
|
|
374
|
+
name: "Link",
|
|
375
|
+
description: [`Store it as an alternative definition of "${closest.name}".`],
|
|
376
|
+
command: `node push.js ${file.path} --link '${closest.id}'`,
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
name: "Supersede",
|
|
380
|
+
description: [`Store it as the next revision of "${closest.name}" (now revision ${closest.version}).`],
|
|
381
|
+
command: `node push.js ${file.path} --supersede '${closest.id}'`,
|
|
382
|
+
},
|
|
383
|
+
{ name: "Skip", description: ["Store nothing for this file."] },
|
|
384
|
+
{
|
|
385
|
+
name: "Create new component",
|
|
386
|
+
description: [
|
|
387
|
+
"Store it as a separate component, next to the similar ones.",
|
|
388
|
+
"If it is almost the same as one of them, Fito asks you again.",
|
|
389
|
+
],
|
|
390
|
+
command: `node push.js ${file.path} --proceed`,
|
|
391
|
+
},
|
|
392
|
+
]),
|
|
272
393
|
].join("\n");
|
|
273
394
|
}
|
|
274
395
|
|
|
@@ -305,24 +426,24 @@ function parseArgs(argv: string[]): RunPushOptions | undefined {
|
|
|
305
426
|
}
|
|
306
427
|
|
|
307
428
|
/**
|
|
308
|
-
* The success line. It names the
|
|
309
|
-
*
|
|
310
|
-
*
|
|
429
|
+
* The success line. It names the file alongside the stored reference id, so the orchestrator's
|
|
430
|
+
* file→reference ledger can be reconstructed from the transcript alone — the stateless answer to
|
|
431
|
+
* "which files are already stored?" on an interrupted flow.
|
|
311
432
|
*/
|
|
312
433
|
export function describeOutcome(
|
|
313
434
|
created: KnowledgeComponent,
|
|
314
435
|
payloadPath: string,
|
|
315
436
|
resolution?: PushResolution,
|
|
316
437
|
): string {
|
|
317
|
-
const headline = `✓
|
|
438
|
+
const headline = `✓ Stored "${created.name}" as ${created.id} (revision ${created.version}), from ${payloadPath}`;
|
|
318
439
|
if (!resolution) return headline;
|
|
319
440
|
switch (resolution.kind) {
|
|
320
441
|
case "link":
|
|
321
|
-
return `${headline}\n
|
|
442
|
+
return `${headline}\n It is an alternative definition of ${resolution.target}.`;
|
|
322
443
|
case "supersede":
|
|
323
|
-
return `${headline}\n
|
|
444
|
+
return `${headline}\n It is the next revision of ${resolution.target}.`;
|
|
324
445
|
case "override":
|
|
325
|
-
return `${headline}\n
|
|
446
|
+
return `${headline}\n It is a separate component, next to ${resolution.duplicate}.`;
|
|
326
447
|
}
|
|
327
448
|
}
|
|
328
449
|
|
|
@@ -336,15 +457,20 @@ async function main(): Promise<void> {
|
|
|
336
457
|
try {
|
|
337
458
|
const outcome = await runPush(options);
|
|
338
459
|
if (outcome.kind === "near-misses") {
|
|
339
|
-
console.error(renderNearMisses(outcome.matches, options.payloadPath));
|
|
460
|
+
console.error(renderNearMisses(outcome.matches, pushFileOf(options.payloadPath)));
|
|
461
|
+
process.exitCode = 1;
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
if (outcome.kind === "revision-label-refused") {
|
|
465
|
+
console.error(renderRevisionLabelRefusal(outcome, options.payloadPath));
|
|
340
466
|
process.exitCode = 1;
|
|
341
467
|
return;
|
|
342
468
|
}
|
|
343
469
|
console.log(describeOutcome(outcome.component, options.payloadPath, options.resolution));
|
|
344
470
|
} catch (error) {
|
|
345
471
|
if (error instanceof FitoApiError) {
|
|
346
|
-
const
|
|
347
|
-
console.error(
|
|
472
|
+
const file = pushFileOf(options.payloadPath);
|
|
473
|
+
console.error(renderPushConflict(error, file) ?? renderFailure(error, file));
|
|
348
474
|
} else {
|
|
349
475
|
console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
|
|
350
476
|
}
|
|
@@ -14,12 +14,6 @@ allowed-tools: bash
|
|
|
14
14
|
|
|
15
15
|
Run the scripts with `node <file>.js`. Both are stateless and safe to re-run.
|
|
16
16
|
|
|
17
|
-
## Configuration
|
|
18
|
-
|
|
19
|
-
| Env var | Default | Purpose |
|
|
20
|
-
|---|---|---|
|
|
21
|
-
| `FITO_API_BASE_URL` | `http://localhost:8080` | Backend origin (registry lookup — check only) |
|
|
22
|
-
|
|
23
17
|
## Build a source bundle
|
|
24
18
|
|
|
25
19
|
```bash
|
|
@@ -77,7 +77,7 @@ export interface CheckOptions {
|
|
|
77
77
|
/** The checkout to classify; defaults to the current directory. */
|
|
78
78
|
dir?: string;
|
|
79
79
|
exec?: Executor;
|
|
80
|
-
/** Backend client (registry lookup); defaults to the real one (reads `
|
|
80
|
+
/** Backend client (registry lookup); defaults to the real one (reads `FITO_URL`). */
|
|
81
81
|
client?: Pick<FitoApiClient, "listCases">;
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -30,12 +30,6 @@ existing row stores no descriptions, so most update runs follow a create.
|
|
|
30
30
|
- **A confirmed payload** — `./output/2-technology/technology.yaml`, drafted by the
|
|
31
31
|
`fito-technology-generator` subagent and confirmed by the author. Both scripts read it verbatim.
|
|
32
32
|
|
|
33
|
-
## Configuration
|
|
34
|
-
|
|
35
|
-
| Env var | Default | Purpose |
|
|
36
|
-
|---|---|---|
|
|
37
|
-
| `FITO_API_BASE_URL` | `http://localhost:8080` | Backend origin |
|
|
38
|
-
|
|
39
33
|
## Create or resolve the technology
|
|
40
34
|
|
|
41
35
|
```bash
|