@4ge/cli 0.1.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/LICENSE +21 -0
- package/README.md +228 -0
- package/bin/dev.js +3 -0
- package/bin/run.js +3 -0
- package/dist/base.js +398 -0
- package/dist/commands/auth/login.js +197 -0
- package/dist/commands/auth/logout.js +31 -0
- package/dist/commands/auth/profile/delete.js +34 -0
- package/dist/commands/auth/profile/list.js +32 -0
- package/dist/commands/auth/profile/use.js +30 -0
- package/dist/commands/auth/status.js +107 -0
- package/dist/commands/config/get.js +37 -0
- package/dist/commands/config/index.js +9 -0
- package/dist/commands/config/manage.js +165 -0
- package/dist/commands/config/set.js +42 -0
- package/dist/commands/config/show.js +46 -0
- package/dist/commands/epic/index.js +10 -0
- package/dist/commands/epic/list.js +91 -0
- package/dist/commands/epic/pull.js +137 -0
- package/dist/commands/epic/show.js +67 -0
- package/dist/commands/epic/update.js +104 -0
- package/dist/commands/feature/index.js +2 -0
- package/dist/commands/feature/list.js +93 -0
- package/dist/commands/feature/pull.js +122 -0
- package/dist/commands/feature/show.js +60 -0
- package/dist/commands/feature/update.js +103 -0
- package/dist/commands/idea/create.js +88 -0
- package/dist/commands/idea/graduate.js +89 -0
- package/dist/commands/idea/index.js +5 -0
- package/dist/commands/idea/list.js +83 -0
- package/dist/commands/idea/show.js +86 -0
- package/dist/commands/idea/update.js +108 -0
- package/dist/commands/init.js +354 -0
- package/dist/commands/login.js +5 -0
- package/dist/commands/plan/index.js +10 -0
- package/dist/commands/plan/pull.js +104 -0
- package/dist/commands/plan/versions.js +64 -0
- package/dist/commands/project/create.js +84 -0
- package/dist/commands/project/index.js +9 -0
- package/dist/commands/project/info.js +74 -0
- package/dist/commands/project/list.js +78 -0
- package/dist/commands/project/pull.js +127 -0
- package/dist/commands/project/update.js +104 -0
- package/dist/commands/root.js +13 -0
- package/dist/commands/skill/index.js +8 -0
- package/dist/commands/skill/install.js +71 -0
- package/dist/commands/story/index.js +10 -0
- package/dist/commands/story/list.js +81 -0
- package/dist/commands/story/pull.js +125 -0
- package/dist/commands/story/show.js +57 -0
- package/dist/commands/story/update.js +103 -0
- package/dist/commands/template/create.js +72 -0
- package/dist/commands/template/delete.js +62 -0
- package/dist/commands/template/feature/create.js +70 -0
- package/dist/commands/template/feature/delete.js +75 -0
- package/dist/commands/template/feature/list.js +69 -0
- package/dist/commands/template/feature/update.js +82 -0
- package/dist/commands/template/info.js +52 -0
- package/dist/commands/template/list.js +76 -0
- package/dist/commands/template/pull.js +99 -0
- package/dist/commands/template/update.js +71 -0
- package/dist/commands/whoami.js +5 -0
- package/dist/core/api/action-hints.js +17 -0
- package/dist/core/api/index.js +3 -0
- package/dist/core/api/retry.js +95 -0
- package/dist/core/api/validate-response.js +41 -0
- package/dist/core/auth/api-client.js +156 -0
- package/dist/core/auth/config.js +3 -0
- package/dist/core/auth/credentials.js +143 -0
- package/dist/core/auth/email-auth.js +30 -0
- package/dist/core/auth/errors.js +20 -0
- package/dist/core/auth/index.js +6 -0
- package/dist/core/auth/realtime.js +82 -0
- package/dist/core/auth/resolution.js +63 -0
- package/dist/core/auth/state.js +9 -0
- package/dist/core/auth/token-refresh.js +100 -0
- package/dist/core/config/defaults.js +31 -0
- package/dist/core/config/index.js +3 -0
- package/dist/core/config/parser.js +213 -0
- package/dist/core/config/schema.js +29 -0
- package/dist/core/project/markdown.js +37 -0
- package/dist/core/skill/installer.js +59 -0
- package/dist/core/skill/paths.js +52 -0
- package/dist/generated/api/client/client.gen.js +217 -0
- package/dist/generated/api/client/index.js +6 -0
- package/dist/generated/api/client/types.gen.js +2 -0
- package/dist/generated/api/client/utils.gen.js +231 -0
- package/dist/generated/api/client.gen.js +3 -0
- package/dist/generated/api/core/auth.gen.js +14 -0
- package/dist/generated/api/core/bodySerializer.gen.js +57 -0
- package/dist/generated/api/core/params.gen.js +103 -0
- package/dist/generated/api/core/pathSerializer.gen.js +114 -0
- package/dist/generated/api/core/queryKeySerializer.gen.js +99 -0
- package/dist/generated/api/core/serverSentEvents.gen.js +136 -0
- package/dist/generated/api/core/types.gen.js +2 -0
- package/dist/generated/api/core/utils.gen.js +87 -0
- package/dist/generated/api/index.js +2 -0
- package/dist/generated/api/sdk.gen.js +556 -0
- package/dist/generated/api/types.gen.js +2 -0
- package/dist/generated/api/zod.gen.js +1262 -0
- package/dist/ui/components/action-hints.js +33 -0
- package/dist/ui/components/cli-header.js +91 -0
- package/dist/ui/components/confirm-prompt.js +28 -0
- package/dist/ui/components/data-table.js +35 -0
- package/dist/ui/components/detail-view.js +5 -0
- package/dist/ui/components/error-display.js +5 -0
- package/dist/ui/components/prompt-layout.js +6 -0
- package/dist/ui/components/select-prompt.js +28 -0
- package/dist/ui/components/spinner.js +14 -0
- package/dist/ui/components/success-message.js +5 -0
- package/dist/ui/components/text-input.js +29 -0
- package/dist/ui/hooks/use-action-hints.js +21 -0
- package/dist/ui/hooks/use-status.js +22 -0
- package/dist/ui/index.js +15 -0
- package/dist/ui/prompt-helpers.js +55 -0
- package/dist/ui/render.js +9 -0
- package/package.json +89 -0
- package/skills/4ge-cli.md +113 -0
- package/usage.md +320 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
export function createSseClient({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
|
|
3
|
+
let lastEventId;
|
|
4
|
+
const sleep = sseSleepFn ??
|
|
5
|
+
((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
6
|
+
const createStream = async function* () {
|
|
7
|
+
let retryDelay = sseDefaultRetryDelay ?? 3000;
|
|
8
|
+
let attempt = 0;
|
|
9
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
10
|
+
while (true) {
|
|
11
|
+
if (signal.aborted)
|
|
12
|
+
break;
|
|
13
|
+
attempt++;
|
|
14
|
+
const headers = options.headers instanceof Headers
|
|
15
|
+
? options.headers
|
|
16
|
+
: new Headers(options.headers);
|
|
17
|
+
if (lastEventId !== undefined) {
|
|
18
|
+
headers.set("Last-Event-ID", lastEventId);
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const requestInit = {
|
|
22
|
+
redirect: "follow",
|
|
23
|
+
...options,
|
|
24
|
+
body: options.serializedBody,
|
|
25
|
+
headers,
|
|
26
|
+
signal,
|
|
27
|
+
};
|
|
28
|
+
let request = new Request(url, requestInit);
|
|
29
|
+
if (onRequest) {
|
|
30
|
+
request = await onRequest(url, requestInit);
|
|
31
|
+
}
|
|
32
|
+
// fetch must be assigned here, otherwise it would throw the error:
|
|
33
|
+
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
34
|
+
const _fetch = options.fetch ?? globalThis.fetch;
|
|
35
|
+
const response = await _fetch(request);
|
|
36
|
+
if (!response.ok)
|
|
37
|
+
throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
38
|
+
if (!response.body)
|
|
39
|
+
throw new Error("No body in SSE response");
|
|
40
|
+
const reader = response.body
|
|
41
|
+
.pipeThrough(new TextDecoderStream())
|
|
42
|
+
.getReader();
|
|
43
|
+
let buffer = "";
|
|
44
|
+
const abortHandler = () => {
|
|
45
|
+
try {
|
|
46
|
+
reader.cancel();
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// noop
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
signal.addEventListener("abort", abortHandler);
|
|
53
|
+
try {
|
|
54
|
+
while (true) {
|
|
55
|
+
const { done, value } = await reader.read();
|
|
56
|
+
if (done)
|
|
57
|
+
break;
|
|
58
|
+
buffer += value;
|
|
59
|
+
buffer = buffer.replace(/\r\n?/g, "\n"); // normalize line endings
|
|
60
|
+
const chunks = buffer.split("\n\n");
|
|
61
|
+
buffer = chunks.pop() ?? "";
|
|
62
|
+
for (const chunk of chunks) {
|
|
63
|
+
const lines = chunk.split("\n");
|
|
64
|
+
const dataLines = [];
|
|
65
|
+
let eventName;
|
|
66
|
+
for (const line of lines) {
|
|
67
|
+
if (line.startsWith("data:")) {
|
|
68
|
+
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
69
|
+
}
|
|
70
|
+
else if (line.startsWith("event:")) {
|
|
71
|
+
eventName = line.replace(/^event:\s*/, "");
|
|
72
|
+
}
|
|
73
|
+
else if (line.startsWith("id:")) {
|
|
74
|
+
lastEventId = line.replace(/^id:\s*/, "");
|
|
75
|
+
}
|
|
76
|
+
else if (line.startsWith("retry:")) {
|
|
77
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
78
|
+
if (!Number.isNaN(parsed)) {
|
|
79
|
+
retryDelay = parsed;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
let data;
|
|
84
|
+
let parsedJson = false;
|
|
85
|
+
if (dataLines.length) {
|
|
86
|
+
const rawData = dataLines.join("\n");
|
|
87
|
+
try {
|
|
88
|
+
data = JSON.parse(rawData);
|
|
89
|
+
parsedJson = true;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
data = rawData;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (parsedJson) {
|
|
96
|
+
if (responseValidator) {
|
|
97
|
+
await responseValidator(data);
|
|
98
|
+
}
|
|
99
|
+
if (responseTransformer) {
|
|
100
|
+
data = await responseTransformer(data);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
onSseEvent?.({
|
|
104
|
+
data,
|
|
105
|
+
event: eventName,
|
|
106
|
+
id: lastEventId,
|
|
107
|
+
retry: retryDelay,
|
|
108
|
+
});
|
|
109
|
+
if (dataLines.length) {
|
|
110
|
+
yield data;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
signal.removeEventListener("abort", abortHandler);
|
|
117
|
+
reader.releaseLock();
|
|
118
|
+
}
|
|
119
|
+
break; // exit loop on normal completion
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
// connection failed or aborted; retry after delay
|
|
123
|
+
onSseError?.(error);
|
|
124
|
+
if (sseMaxRetryAttempts !== undefined &&
|
|
125
|
+
attempt >= sseMaxRetryAttempts) {
|
|
126
|
+
break; // stop after firing error
|
|
127
|
+
}
|
|
128
|
+
// exponential backoff: double retry each attempt, cap at 30s
|
|
129
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
|
|
130
|
+
await sleep(backoff);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const stream = createStream();
|
|
135
|
+
return { stream };
|
|
136
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from "./pathSerializer.gen.js";
|
|
3
|
+
export const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
4
|
+
export const defaultPathSerializer = ({ path, url: _url }) => {
|
|
5
|
+
let url = _url;
|
|
6
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
7
|
+
if (matches) {
|
|
8
|
+
for (const match of matches) {
|
|
9
|
+
let explode = false;
|
|
10
|
+
let name = match.substring(1, match.length - 1);
|
|
11
|
+
let style = "simple";
|
|
12
|
+
if (name.endsWith("*")) {
|
|
13
|
+
explode = true;
|
|
14
|
+
name = name.substring(0, name.length - 1);
|
|
15
|
+
}
|
|
16
|
+
if (name.startsWith(".")) {
|
|
17
|
+
name = name.substring(1);
|
|
18
|
+
style = "label";
|
|
19
|
+
}
|
|
20
|
+
else if (name.startsWith(";")) {
|
|
21
|
+
name = name.substring(1);
|
|
22
|
+
style = "matrix";
|
|
23
|
+
}
|
|
24
|
+
const value = path[name];
|
|
25
|
+
if (value === undefined || value === null) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (Array.isArray(value)) {
|
|
29
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (typeof value === "object") {
|
|
33
|
+
url = url.replace(match, serializeObjectParam({
|
|
34
|
+
explode,
|
|
35
|
+
name,
|
|
36
|
+
style,
|
|
37
|
+
value: value,
|
|
38
|
+
valueOnly: true,
|
|
39
|
+
}));
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (style === "matrix") {
|
|
43
|
+
url = url.replace(match, `;${serializePrimitiveParam({
|
|
44
|
+
name,
|
|
45
|
+
value: value,
|
|
46
|
+
})}`);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
50
|
+
url = url.replace(match, replaceValue);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return url;
|
|
54
|
+
};
|
|
55
|
+
export const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
|
|
56
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
57
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
58
|
+
if (path) {
|
|
59
|
+
url = defaultPathSerializer({ path, url });
|
|
60
|
+
}
|
|
61
|
+
let search = query ? querySerializer(query) : "";
|
|
62
|
+
if (search.startsWith("?")) {
|
|
63
|
+
search = search.substring(1);
|
|
64
|
+
}
|
|
65
|
+
if (search) {
|
|
66
|
+
url += `?${search}`;
|
|
67
|
+
}
|
|
68
|
+
return url;
|
|
69
|
+
};
|
|
70
|
+
export function getValidRequestBody(options) {
|
|
71
|
+
const hasBody = options.body !== undefined;
|
|
72
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
73
|
+
if (isSerializedBody) {
|
|
74
|
+
if ("serializedBody" in options) {
|
|
75
|
+
const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== "";
|
|
76
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
77
|
+
}
|
|
78
|
+
// not all clients implement a serializedBody property (i.e., client-axios)
|
|
79
|
+
return options.body !== "" ? options.body : null;
|
|
80
|
+
}
|
|
81
|
+
// plain/text body
|
|
82
|
+
if (hasBody) {
|
|
83
|
+
return options.body;
|
|
84
|
+
}
|
|
85
|
+
// no body was provided
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
export { cliAuthCallback, cliAuthEmailLogin, cliAuthLogin, cliAuthRefresh, cliAuthStatus, createIdea, createProject, createTemplate, createTemplateFeature, deleteTemplate, deleteTemplateFeature, getEpicDetail, getEpicTree, getFeatureDetail, getFeatureTree, getLatestPlanVersion, getPlanMetadata, getPlanTree, getPlanVersionDetail, getPlanVersions, getProjectDetail, getStoryDetail, getStoryTree, getTemplateDetail, graduateIdea, listEpics, listFeatures, listIdeas, listProjects, listStories, listTemplateFeatures, listTemplates, listWorkspaces, updateEpic, updateFeature, updateIdea, updateProject, updateStory, updateTemplate, updateTemplateFeature, } from "./sdk.gen.js";
|