toolcraft 0.0.10 → 0.0.12
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 +1 -0
- package/dist/cli.js +274 -160
- package/dist/mcp.d.ts +6 -0
- package/dist/mcp.js +3 -3
- package/dist/renderer.d.ts +8 -2
- package/dist/renderer.js +71 -12
- package/node_modules/@poe-code/design-system/dist/components/help-formatter-plain.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/components/help-formatter-plain.js +132 -0
- package/node_modules/@poe-code/design-system/dist/components/help-formatter.d.ts +13 -0
- package/node_modules/@poe-code/design-system/dist/components/help-formatter.js +116 -7
- package/node_modules/@poe-code/design-system/dist/components/index.d.ts +2 -2
- package/node_modules/@poe-code/design-system/dist/components/index.js +1 -1
- package/node_modules/@poe-code/design-system/dist/components/text.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/components/text.js +8 -0
- package/node_modules/@poe-code/design-system/dist/index.d.ts +3 -2
- package/node_modules/@poe-code/design-system/dist/index.js +2 -1
- package/node_modules/@poe-code/task-list/README.md +49 -5
- package/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.d.ts +19 -0
- package/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.js +62 -0
- package/node_modules/@poe-code/task-list/dist/backends/gh-issues.d.ts +13 -0
- package/node_modules/@poe-code/task-list/dist/backends/gh-issues.js +627 -0
- package/node_modules/@poe-code/task-list/dist/backends/markdown-dir.js +253 -41
- package/node_modules/@poe-code/task-list/dist/backends/utils.d.ts +7 -1
- package/node_modules/@poe-code/task-list/dist/backends/utils.js +21 -0
- package/node_modules/@poe-code/task-list/dist/backends/yaml-file.js +171 -16
- package/node_modules/@poe-code/task-list/dist/index.d.ts +3 -1
- package/node_modules/@poe-code/task-list/dist/index.js +1 -1
- package/node_modules/@poe-code/task-list/dist/open.d.ts +4 -2
- package/node_modules/@poe-code/task-list/dist/open.js +27 -3
- package/node_modules/@poe-code/task-list/dist/types.d.ts +51 -3
- package/node_modules/@poe-code/task-list/dist/types.js +25 -0
- package/node_modules/@poe-code/task-list/package.json +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Runner } from "@poe-code/process-runner";
|
|
2
|
+
export interface GhClientOptions {
|
|
3
|
+
token: string;
|
|
4
|
+
endpoint?: string;
|
|
5
|
+
fetch?: typeof fetch;
|
|
6
|
+
}
|
|
7
|
+
export interface GhClient {
|
|
8
|
+
graphql<T>(query: string, variables: Record<string, unknown>): Promise<T>;
|
|
9
|
+
}
|
|
10
|
+
export declare function createGhClient(options: GhClientOptions): GhClient;
|
|
11
|
+
export interface ResolveAuthOptions {
|
|
12
|
+
explicitToken?: string;
|
|
13
|
+
runner?: Runner;
|
|
14
|
+
}
|
|
15
|
+
export declare function resolveAuth(options: ResolveAuthOptions): Promise<string>;
|
|
16
|
+
export interface ResolveEndpointOptions {
|
|
17
|
+
env?: Record<string, string | undefined>;
|
|
18
|
+
}
|
|
19
|
+
export declare function resolveEndpoint(options?: ResolveEndpointOptions): string;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { text } from "node:stream/consumers";
|
|
2
|
+
import { createHostRunner } from "@poe-code/process-runner";
|
|
3
|
+
const DEFAULT_ENDPOINT = "https://api.github.com/graphql";
|
|
4
|
+
const USER_AGENT = "poe-code-task-list/0.0.1";
|
|
5
|
+
const AUTH_ERROR = "gh auth token failed; install gh, run 'gh auth login', or pass auth: { token }";
|
|
6
|
+
export function createGhClient(options) {
|
|
7
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
8
|
+
const endpoint = options.endpoint || DEFAULT_ENDPOINT;
|
|
9
|
+
return {
|
|
10
|
+
async graphql(query, variables) {
|
|
11
|
+
const response = await fetchImpl(endpoint, {
|
|
12
|
+
method: "POST",
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: `Bearer ${options.token}`,
|
|
15
|
+
"Content-Type": "application/json",
|
|
16
|
+
"User-Agent": USER_AGENT
|
|
17
|
+
},
|
|
18
|
+
body: JSON.stringify({ query, variables })
|
|
19
|
+
});
|
|
20
|
+
const body = await response.text();
|
|
21
|
+
if (response.status !== 200) {
|
|
22
|
+
throw new Error(`GitHub GraphQL request failed with status ${response.status}: ${body}`);
|
|
23
|
+
}
|
|
24
|
+
const parsed = JSON.parse(body);
|
|
25
|
+
const firstError = parsed.errors?.[0];
|
|
26
|
+
if (firstError !== undefined) {
|
|
27
|
+
throw new Error(firstError.message ?? "GitHub GraphQL request failed");
|
|
28
|
+
}
|
|
29
|
+
return parsed.data;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export async function resolveAuth(options) {
|
|
34
|
+
if (options.explicitToken !== undefined) {
|
|
35
|
+
return options.explicitToken;
|
|
36
|
+
}
|
|
37
|
+
const runner = options.runner ?? createHostRunner();
|
|
38
|
+
const handle = runner.exec({
|
|
39
|
+
command: "gh",
|
|
40
|
+
args: ["auth", "token"],
|
|
41
|
+
stdout: "pipe",
|
|
42
|
+
stderr: "pipe"
|
|
43
|
+
});
|
|
44
|
+
const [stdout, , result] = await Promise.all([
|
|
45
|
+
handle.stdout === null ? Promise.resolve("") : text(handle.stdout),
|
|
46
|
+
handle.stderr === null ? Promise.resolve("") : text(handle.stderr),
|
|
47
|
+
handle.result
|
|
48
|
+
]);
|
|
49
|
+
const token = stdout.trim();
|
|
50
|
+
if (result.exitCode !== 0 || token.length === 0) {
|
|
51
|
+
throw new Error(AUTH_ERROR);
|
|
52
|
+
}
|
|
53
|
+
return token;
|
|
54
|
+
}
|
|
55
|
+
export function resolveEndpoint(options = {}) {
|
|
56
|
+
const env = options.env ?? process.env;
|
|
57
|
+
const host = env.GH_HOST;
|
|
58
|
+
if (host !== undefined && host !== "" && host !== "github.com") {
|
|
59
|
+
return `https://${host}/api/graphql`;
|
|
60
|
+
}
|
|
61
|
+
return DEFAULT_ENDPOINT;
|
|
62
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TaskDefaults, TaskList } from "../types.js";
|
|
2
|
+
export interface GhIssuesBackendDeps {
|
|
3
|
+
repo: string;
|
|
4
|
+
project: {
|
|
5
|
+
owner: string;
|
|
6
|
+
number: number;
|
|
7
|
+
};
|
|
8
|
+
defaults: Required<TaskDefaults>;
|
|
9
|
+
token: string;
|
|
10
|
+
endpoint: string;
|
|
11
|
+
fetch?: typeof fetch;
|
|
12
|
+
}
|
|
13
|
+
export declare function ghIssuesBackend(deps: GhIssuesBackendDeps): Promise<TaskList>;
|