@brainervirus/workit-core 2.0.2 → 2.1.1
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 -2
- package/package.json +2 -3
- package/scripts/sync-runtime.sh +9 -5
- package/src/core/detect-hosts.ts +24 -22
- package/src/core/doctor.ts +11 -4
- package/src/core/host-install.ts +458 -0
- package/src/core/init.ts +1 -256
- package/src/core/policy-resolver.ts +0 -45
- package/src/core/registration.ts +3 -4
- package/src/core/repo-context.ts +1 -1
- package/src/core/rules.ts +1 -61
- package/src/core/setup.ts +203 -11
- package/src/core/templates.ts +1 -26
- package/src/core/vcs-config.ts +2 -8
- package/src/core/workspaces.ts +18 -17
- package/src/core/config-guard.ts +0 -27
- package/src/core/doc-render.ts +0 -14
- package/src/core/docs-layout.ts +0 -279
- package/src/core/docs-migration.ts +0 -639
- package/src/core/docs-repo.ts +0 -233
- package/src/core/docs-validate.ts +0 -393
- package/src/core/parse-sections.ts +0 -24
- package/src/core/ports/init-apply.ts +0 -15
- package/src/core/ports/init-status.ts +0 -4
- package/src/core/ports/init-toolkit-status.ts +0 -4
- package/src/core/ports/pr-create.ts +0 -30
- package/src/core/ports/present-ascii.ts +0 -10
- package/src/core/ports/present-flow.ts +0 -10
- package/src/core/ports/vcs-config.ts +0 -14
- package/src/core/ports/vcs-merged-style.ts +0 -5
- package/src/core/ports/vcs-verify-token.ts +0 -4
- package/src/core/ports/youtrack-api.ts +0 -19
- package/src/core/ports/youtrack-config.ts +0 -21
- package/src/core/ports/youtrack-greeting.ts +0 -10
- package/src/core/ports/youtrack-parse-duration.ts +0 -14
- package/src/core/ports/youtrack-token-create-url.ts +0 -4
- package/src/core/ports/youtrack-verify-token.ts +0 -12
- package/src/core/ports/youtrack-work-date-ms.ts +0 -10
- package/src/core/present.ts +0 -109
- package/src/core/repo-tool.ts +0 -12
- package/src/core/repo-tools.ts +0 -22
- package/src/core/sync-runtime.ts +0 -375
- package/src/core/verify-parse.ts +0 -29
- package/src/core/verify-project.ts +0 -181
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// CLI port of scripts/pr-create.sh — create | --build-body.
|
|
2
|
-
//
|
|
3
|
-
// Decision ae03c569 re-enabled hosted PR/MR creation with pre/post provider SHA
|
|
4
|
-
// verification and accepted the residual non-atomic source-SHA race. The legacy
|
|
5
|
-
// create mode still cannot mint the native action receipt, the one-time action
|
|
6
|
-
// reservation, or the target writer lease the shared contract requires, so it
|
|
7
|
-
// never performs a hosted create itself. It returns the same needs_input shape
|
|
8
|
-
// as the headless `workit action` route and points at the reserved,
|
|
9
|
-
// TTY-confirmed shared path.
|
|
10
|
-
import { prBuildBody } from "../pr-create";
|
|
11
|
-
|
|
12
|
-
const mode = process.argv[2] ?? "create";
|
|
13
|
-
if (mode === "--build-body") {
|
|
14
|
-
console.log(JSON.stringify({ body: prBuildBody(process.env, process.cwd()) }));
|
|
15
|
-
process.exit(0);
|
|
16
|
-
}
|
|
17
|
-
console.log(
|
|
18
|
-
JSON.stringify({
|
|
19
|
-
ok: false,
|
|
20
|
-
schemaVersion: 1,
|
|
21
|
-
code: "needs_input",
|
|
22
|
-
error: "hosted PR/MR creation requires the reserved shared action path with TTY confirmation",
|
|
23
|
-
details: {
|
|
24
|
-
operation: "hosting.pull_request",
|
|
25
|
-
guidance:
|
|
26
|
-
"Run `workit action hosting.pull_request --payload <file> --confirm` from the target checkout: it records the one-time action reservation behind the terminal confirmation and verifies the provider PR head against the approved source SHA before reporting success.",
|
|
27
|
-
},
|
|
28
|
-
}),
|
|
29
|
-
);
|
|
30
|
-
process.exit(1);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// CLI port of scripts/present/ascii-wireframe.sh — JSON spec on stdin.
|
|
2
|
-
import { renderAsciiWireframe } from "../present";
|
|
3
|
-
|
|
4
|
-
const input = await Bun.stdin.text();
|
|
5
|
-
try {
|
|
6
|
-
console.log(renderAsciiWireframe(input));
|
|
7
|
-
} catch (err) {
|
|
8
|
-
console.error(err instanceof Error ? err.message : "ascii-wireframe render failed");
|
|
9
|
-
process.exit(1);
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// CLI port of scripts/present/flow-diagram.sh — JSON spec on stdin.
|
|
2
|
-
import { renderFlowDiagram } from "../present";
|
|
3
|
-
|
|
4
|
-
const input = await Bun.stdin.text();
|
|
5
|
-
try {
|
|
6
|
-
console.log(renderFlowDiagram(input));
|
|
7
|
-
} catch (err) {
|
|
8
|
-
console.error(err instanceof Error ? err.message : "flow-diagram render failed");
|
|
9
|
-
process.exit(1);
|
|
10
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// CLI port of scripts/vcs/config.sh — mode: load | summary | resolve.
|
|
2
|
-
import { vcsConfig } from "../vcs-config";
|
|
3
|
-
|
|
4
|
-
const cmd = process.argv[2] ?? "load";
|
|
5
|
-
if (cmd !== "load" && cmd !== "summary" && cmd !== "resolve") {
|
|
6
|
-
console.error("ERROR: unknown command (load|summary|resolve)");
|
|
7
|
-
process.exit(1);
|
|
8
|
-
}
|
|
9
|
-
const out = vcsConfig(cmd, process.cwd());
|
|
10
|
-
if (!out.ok) {
|
|
11
|
-
console.log(JSON.stringify(out));
|
|
12
|
-
process.exit(1);
|
|
13
|
-
}
|
|
14
|
-
console.log(JSON.stringify(out));
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// CLI port of scripts/youtrack/api.sh — write guard before any config read.
|
|
2
|
-
import { youTrackApi } from "../youtrack";
|
|
3
|
-
|
|
4
|
-
const args = process.argv.slice(2);
|
|
5
|
-
const cmd = args[0];
|
|
6
|
-
if (cmd === "log-time" || cmd === "post-comment") {
|
|
7
|
-
if ((process.env.WORKFLOW_YT_WRITE ?? "") !== "1") {
|
|
8
|
-
console.error(
|
|
9
|
-
"ERROR: YouTrack write operations require WORKFLOW_YT_WRITE=1 (refusing to mutate production)",
|
|
10
|
-
);
|
|
11
|
-
process.exit(1);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
const out = await youTrackApi(args, process.env.WORKFLOW_YT_WRITE ?? "");
|
|
15
|
-
if ("error" in out) {
|
|
16
|
-
console.log(JSON.stringify({ ok: false, error: out.error }));
|
|
17
|
-
process.exit(1);
|
|
18
|
-
}
|
|
19
|
-
console.log(JSON.stringify(out.data));
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// CLI port of scripts/youtrack/config.sh — JSON out, argv/env in.
|
|
2
|
-
import { youTrackConfigLoad } from "../youtrack";
|
|
3
|
-
|
|
4
|
-
const args = process.argv.slice(2);
|
|
5
|
-
const cmd = args[0] ?? "load";
|
|
6
|
-
|
|
7
|
-
if (cmd !== "load") {
|
|
8
|
-
console.error("ERROR: unknown command");
|
|
9
|
-
process.exit(1);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const out = youTrackConfigLoad();
|
|
13
|
-
if ("error" in out) {
|
|
14
|
-
if (out.error === "ERROR: missing youtrack.json") {
|
|
15
|
-
console.error(out.error);
|
|
16
|
-
} else {
|
|
17
|
-
console.log(JSON.stringify({ ok: false, error: out.error }));
|
|
18
|
-
}
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
console.log(JSON.stringify(out.data));
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// CLI port of scripts/youtrack/greeting.sh.
|
|
2
|
-
import { youTrackGreeting } from "../youtrack";
|
|
3
|
-
|
|
4
|
-
const override = process.argv[2];
|
|
5
|
-
const result = youTrackGreeting(override);
|
|
6
|
-
if (result.exitCode !== 0) {
|
|
7
|
-
console.error(result.stderr || "greeting failed");
|
|
8
|
-
process.exit(1);
|
|
9
|
-
}
|
|
10
|
-
process.stdout.write(result.stdout);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// CLI port of scripts/youtrack/parse-duration.sh.
|
|
2
|
-
import { youTrackParseDuration } from "../youtrack";
|
|
3
|
-
|
|
4
|
-
const text = process.argv.slice(2).join(" ");
|
|
5
|
-
if (!text) {
|
|
6
|
-
console.error("ERROR: duration text required");
|
|
7
|
-
process.exit(1);
|
|
8
|
-
}
|
|
9
|
-
const out = youTrackParseDuration(text);
|
|
10
|
-
if ("error" in out) {
|
|
11
|
-
console.error("ERROR: " + out.error);
|
|
12
|
-
process.exit(1);
|
|
13
|
-
}
|
|
14
|
-
console.log(JSON.stringify(out.data));
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// CLI port of scripts/youtrack/verify-token.sh.
|
|
2
|
-
import { youTrackVerifyToken } from "../youtrack";
|
|
3
|
-
|
|
4
|
-
const out = await youTrackVerifyToken();
|
|
5
|
-
if ("error" in out) {
|
|
6
|
-
const payload: Record<string, any> = { ok: false, error: out.error };
|
|
7
|
-
if (out.http_status !== undefined) payload.http_status = out.http_status;
|
|
8
|
-
if (out.path !== undefined) payload.path = out.path;
|
|
9
|
-
console.log(JSON.stringify(payload, null, 2));
|
|
10
|
-
process.exit(1);
|
|
11
|
-
}
|
|
12
|
-
console.log(JSON.stringify(out.data, null, 2));
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// CLI port of scripts/youtrack/work-date-ms.sh.
|
|
2
|
-
import { youTrackWorkDateMs } from "../youtrack";
|
|
3
|
-
|
|
4
|
-
const raw = process.argv[2] ?? "auto";
|
|
5
|
-
const out = youTrackWorkDateMs(raw);
|
|
6
|
-
if ("error" in out) {
|
|
7
|
-
console.error("ERROR: " + out.error);
|
|
8
|
-
process.exit(1);
|
|
9
|
-
}
|
|
10
|
-
console.log(JSON.stringify(out.data));
|
package/src/core/present.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
// Ports of scripts/present/ascii-wireframe.sh + flow-diagram.sh — pure TS renderers.
|
|
2
|
-
|
|
3
|
-
function boxLine(text: string, width: number): string {
|
|
4
|
-
const inner = width - 4;
|
|
5
|
-
let t = text;
|
|
6
|
-
if (t.length > inner) t = t.slice(0, inner - 1) + "…";
|
|
7
|
-
return "│ " + t.padEnd(inner) + " │";
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function renderAsciiWireframe(spec: unknown): string {
|
|
11
|
-
const parsed = typeof spec === "string" ? JSON.parse(spec) : spec;
|
|
12
|
-
const title = String((parsed as any).title ?? "UI");
|
|
13
|
-
const width = Number((parsed as any).width ?? 72);
|
|
14
|
-
const rows = Array.isArray((parsed as any).rows) ? (parsed as any).rows : [];
|
|
15
|
-
|
|
16
|
-
const top = "┌" + "─".repeat(Math.max(0, width - 2)) + "┐";
|
|
17
|
-
const bot = "└" + "─".repeat(Math.max(0, width - 2)) + "┘";
|
|
18
|
-
const lines = [top, boxLine(title, width)];
|
|
19
|
-
lines.push("├" + "─".repeat(Math.max(0, width - 2)) + "┤");
|
|
20
|
-
|
|
21
|
-
for (const row of rows) {
|
|
22
|
-
const kind = row?.type ?? "text";
|
|
23
|
-
if (kind === "separator") {
|
|
24
|
-
lines.push("├" + "─".repeat(Math.max(0, width - 2)) + "┤");
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
if (kind === "header") {
|
|
28
|
-
lines.push(boxLine(String(row?.label ?? ""), width));
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
if (kind === "button") {
|
|
32
|
-
const label = "[ " + String(row?.label ?? "Button") + " ]";
|
|
33
|
-
lines.push(
|
|
34
|
-
boxLine(
|
|
35
|
-
label.padStart(Math.max(0, (width - 4 + label.length) / 2)).padEnd(width - 4),
|
|
36
|
-
width,
|
|
37
|
-
),
|
|
38
|
-
);
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
if (kind === "field") {
|
|
42
|
-
const label = String(row?.label ?? "Field");
|
|
43
|
-
const value = String(row?.value ?? "_______________");
|
|
44
|
-
lines.push(boxLine(`${label}: ${value}`, width));
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
if (kind === "columns") {
|
|
48
|
-
const cols = Array.isArray(row?.columns) ? row.columns : [];
|
|
49
|
-
const colW = Math.floor((width - 4 - cols.length + 1) / Math.max(cols.length, 1));
|
|
50
|
-
const parts = cols.map((c: any) =>
|
|
51
|
-
String(c?.label ?? "")
|
|
52
|
-
.slice(0, Math.max(0, colW - 1))
|
|
53
|
-
.padEnd(Math.max(0, colW)),
|
|
54
|
-
);
|
|
55
|
-
lines.push(boxLine(parts.join(" | ").trim(), width));
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
lines.push(boxLine(String(row?.label ?? String(row)), width));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
lines.push(bot);
|
|
62
|
-
return lines.join("\n");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function renderFlowDiagram(spec: unknown): string {
|
|
66
|
-
const parsed = typeof spec === "string" ? JSON.parse(spec) : spec;
|
|
67
|
-
const direction = String((parsed as any).direction ?? "TD");
|
|
68
|
-
const nodes = Array.isArray((parsed as any).nodes) ? (parsed as any).nodes : [];
|
|
69
|
-
const edges = Array.isArray((parsed as any).edges) ? (parsed as any).edges : [];
|
|
70
|
-
const title = (parsed as any).title;
|
|
71
|
-
|
|
72
|
-
const lines = ["flowchart " + direction];
|
|
73
|
-
if (title) lines.push(" %% " + String(title));
|
|
74
|
-
|
|
75
|
-
for (const n of nodes) {
|
|
76
|
-
const nid = String(n?.id ?? "");
|
|
77
|
-
const shape = String(n?.shape ?? "box");
|
|
78
|
-
const label = String(n?.label ?? nid).replaceAll('"', "'");
|
|
79
|
-
if (shape === "diamond") lines.push(` ${nid}{"${label}"}`);
|
|
80
|
-
else if (shape === "start") lines.push(` ${nid}(["${label}"])`);
|
|
81
|
-
else lines.push(` ${nid}["${label}"]`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
for (const e of edges) {
|
|
85
|
-
const src = String(e?.from ?? "");
|
|
86
|
-
const dst = String(e?.to ?? "");
|
|
87
|
-
const lbl = e?.label;
|
|
88
|
-
if (lbl) lines.push(` ${src} -->|${lbl}| ${dst}`);
|
|
89
|
-
else lines.push(` ${src} --> ${dst}`);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return lines.join("\n");
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function asciiWireframe(spec: unknown): Record<string, any> {
|
|
96
|
-
try {
|
|
97
|
-
return { data: { ascii: renderAsciiWireframe(spec), format: "ascii-wireframe" } };
|
|
98
|
-
} catch (err) {
|
|
99
|
-
return { error: err instanceof Error ? err.message : "ascii-wireframe render failed" };
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function flowDiagram(spec: unknown): Record<string, any> {
|
|
104
|
-
try {
|
|
105
|
-
return { data: { mermaid: renderFlowDiagram(spec), format: "mermaid" } };
|
|
106
|
-
} catch (err) {
|
|
107
|
-
return { error: err instanceof Error ? err.message : "flow-diagram render failed" };
|
|
108
|
-
}
|
|
109
|
-
}
|
package/src/core/repo-tool.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { resolveWorkspaceRoot } from "./scripts";
|
|
2
|
-
|
|
3
|
-
/** Attach the resolved repository root to each repository tool response. */
|
|
4
|
-
export function withWorkspace(
|
|
5
|
-
workspaceRoot: string,
|
|
6
|
-
data: Record<string, any> = {},
|
|
7
|
-
): Record<string, any> {
|
|
8
|
-
return {
|
|
9
|
-
workspace_root: resolveWorkspaceRoot(workspaceRoot),
|
|
10
|
-
...data,
|
|
11
|
-
};
|
|
12
|
-
}
|
package/src/core/repo-tools.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { fail, ok, run } from "../core";
|
|
2
|
-
|
|
3
|
-
export type RunResult = ReturnType<typeof run>;
|
|
4
|
-
|
|
5
|
-
export type RepoRuntime = {
|
|
6
|
-
git(root: string, args: string[]): RunResult;
|
|
7
|
-
verifyProject(root: string, dryRun: boolean): RunResult;
|
|
8
|
-
prContext(root: string, range: string | undefined): RunResult;
|
|
9
|
-
changelogContext(root: string, range: string | undefined): RunResult;
|
|
10
|
-
docsContext(root: string, range: string | undefined): RunResult;
|
|
11
|
-
releaseContext(root: string, range: string): RunResult;
|
|
12
|
-
initApply(root: string, action: string, env: Record<string, string>): RunResult;
|
|
13
|
-
initStatus(root: string): RunResult;
|
|
14
|
-
toolkitStatus(root: string): RunResult | Promise<RunResult>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const normalizeLegacyResult = (value: Record<string, unknown>) => {
|
|
18
|
-
if (value.error) return fail(String(value.error));
|
|
19
|
-
if (value.ok === false) return fail("legacy operation reported failure");
|
|
20
|
-
const { ok: _legacyOk, ...data } = value;
|
|
21
|
-
return ok(data);
|
|
22
|
-
};
|