@firstdraft.com/cli 0.1.0-alpha.2 → 0.2.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 +52 -235
- package/RELEASING.md +210 -0
- package/SECURITY.md +18 -0
- package/docs/README.md +60 -0
- package/docs/commands.md +220 -0
- package/docs/errors.md +87 -0
- package/docs/release-history.md +32 -0
- package/package.json +5 -2
- package/src/api-response.js +3 -3
- package/src/cli.js +14 -7
- package/src/commands/plan-compile.js +10 -1
- package/src/commands/plan-publish.js +150 -1
- package/src/commands/plan-status.js +311 -9
- package/src/compilation-artifact.js +1 -1
- package/src/plan-compile-progress.js +125 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const PREFIX = "First Draft: ";
|
|
2
|
+
|
|
3
|
+
const PUBLICATION_MESSAGES = new Map([
|
|
4
|
+
["preparing_repository", "Preparing private GitHub repository..."],
|
|
5
|
+
["creating_repository", "Creating private GitHub repository..."],
|
|
6
|
+
[
|
|
7
|
+
"preparing_repository_reconciliation",
|
|
8
|
+
"Preparing to verify GitHub repository creation...",
|
|
9
|
+
],
|
|
10
|
+
["reconciling_repository", "Verifying GitHub repository creation..."],
|
|
11
|
+
["preparing_artifact", "Preparing compiled application..."],
|
|
12
|
+
["publishing_artifact", "Publishing compiled application to GitHub..."],
|
|
13
|
+
[
|
|
14
|
+
"preparing_publication_reconciliation",
|
|
15
|
+
"Preparing to verify GitHub publication...",
|
|
16
|
+
],
|
|
17
|
+
["reconciling_publication", "Verifying GitHub publication..."],
|
|
18
|
+
["completed", "GitHub publication complete."],
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {object} AnalysisProgress
|
|
23
|
+
* @property {"analysis"} phase
|
|
24
|
+
* @property {"waiting" | "valid"} status
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {object} CompilationProgress
|
|
29
|
+
* @property {"compilation"} phase
|
|
30
|
+
* @property {"waiting"} status
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {object} PublicationProgress
|
|
35
|
+
* @property {"publication"} phase
|
|
36
|
+
* @property {"queued" | "running" | "succeeded" | "failed" | "cancelled"} compilationStatus
|
|
37
|
+
* @property {string} publicationPhase
|
|
38
|
+
* @property {string | null} retryAt
|
|
39
|
+
* @property {number} retryCount
|
|
40
|
+
* @property {string | null} reasonCode
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @typedef {AnalysisProgress | CompilationProgress | PublicationProgress} PlanCompileProgress
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Convert deliberately narrow lifecycle observations into stable progress.
|
|
49
|
+
* This boundary never receives response projections, identifiers, hashes,
|
|
50
|
+
* repository names, URLs, or local state.
|
|
51
|
+
*
|
|
52
|
+
* @param {{write: (text: string) => unknown}} writer
|
|
53
|
+
* @returns {(progress: PlanCompileProgress) => void}
|
|
54
|
+
*/
|
|
55
|
+
export function createPlanCompileProgressReporter(writer) {
|
|
56
|
+
let compilationSucceeded = false;
|
|
57
|
+
/** @type {string | null} */
|
|
58
|
+
let previousProgress = null;
|
|
59
|
+
|
|
60
|
+
/** @param {string} message */
|
|
61
|
+
function write(message) {
|
|
62
|
+
writer.write(`${PREFIX}${message}\n`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return (progress) => {
|
|
66
|
+
const serialized = JSON.stringify(progress);
|
|
67
|
+
if (serialized === previousProgress) return;
|
|
68
|
+
previousProgress = serialized;
|
|
69
|
+
|
|
70
|
+
if (progress.phase === "analysis") {
|
|
71
|
+
write(
|
|
72
|
+
progress.status === "waiting"
|
|
73
|
+
? "Analyzing Foundation Plan..."
|
|
74
|
+
: "Foundation Plan analysis valid.",
|
|
75
|
+
);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (progress.phase === "compilation") {
|
|
80
|
+
write("Compiling application...");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (progress.compilationStatus === "succeeded" && !compilationSucceeded) {
|
|
85
|
+
write("Application compiled.");
|
|
86
|
+
compilationSucceeded = true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (progress.publicationPhase === "compiling") return;
|
|
90
|
+
if (progress.publicationPhase === "failed") {
|
|
91
|
+
write(
|
|
92
|
+
progress.compilationStatus === "failed"
|
|
93
|
+
? "Application compilation failed."
|
|
94
|
+
: "GitHub publication failed.",
|
|
95
|
+
);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (progress.publicationPhase === "cancelled") {
|
|
99
|
+
write(
|
|
100
|
+
progress.compilationStatus === "cancelled"
|
|
101
|
+
? "Application compilation cancelled."
|
|
102
|
+
: "GitHub publication cancelled.",
|
|
103
|
+
);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (progress.publicationPhase === "github_preflight") {
|
|
107
|
+
write(githubPreflightMessage(progress));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const message = PUBLICATION_MESSAGES.get(progress.publicationPhase);
|
|
112
|
+
if (message !== undefined) write(message);
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** @param {PublicationProgress} progress */
|
|
117
|
+
function githubPreflightMessage(progress) {
|
|
118
|
+
if (progress.retryCount === 0) return "Checking GitHub access...";
|
|
119
|
+
|
|
120
|
+
const retry =
|
|
121
|
+
progress.retryAt === null
|
|
122
|
+
? "automatic retries paused; operator recovery required"
|
|
123
|
+
: `next retry: ${progress.retryAt}`;
|
|
124
|
+
return `Checking GitHub access (reason: ${progress.reasonCode}; retry count: ${progress.retryCount}; ${retry}).`;
|
|
125
|
+
}
|