@smithers-orchestrator/cli 0.16.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/package.json +55 -0
- package/src/AgentAvailability.ts +13 -0
- package/src/AgentAvailabilityStatus.ts +5 -0
- package/src/AggregateNodeDetailParams.ts +5 -0
- package/src/AskOptions.ts +12 -0
- package/src/ChatAttemptMeta.ts +7 -0
- package/src/ChatAttemptRow.ts +12 -0
- package/src/ChatOutputEvent.ts +6 -0
- package/src/DiffBundleLike.ts +6 -0
- package/src/DiscoveredWorkflow.ts +9 -0
- package/src/EnrichedNodeDetail.ts +60 -0
- package/src/EventCategory.ts +18 -0
- package/src/FindDbWaitOptions.ts +4 -0
- package/src/FormatEventLineOptions.ts +4 -0
- package/src/HijackCandidate.ts +11 -0
- package/src/HijackLaunchSpec.ts +6 -0
- package/src/InitWorkflowPackOptions.ts +4 -0
- package/src/InitWorkflowPackResult.ts +6 -0
- package/src/NativeHijackEngine.ts +8 -0
- package/src/NodeDetailAttempt.ts +22 -0
- package/src/NodeDetailTokenUsage.ts +11 -0
- package/src/NodeDetailToolCall.ts +12 -0
- package/src/ParsedNodeOutputEvent.ts +9 -0
- package/src/RenderNodeDetailOptions.ts +4 -0
- package/src/RunAutoResumeSkipReason.ts +4 -0
- package/src/RunDiffCommandInput.ts +13 -0
- package/src/RunDiffCommandResult.ts +3 -0
- package/src/RunOutputCommandInput.ts +12 -0
- package/src/RunOutputCommandResult.ts +3 -0
- package/src/RunRewindCommandInput.ts +14 -0
- package/src/RunRewindCommandResult.ts +3 -0
- package/src/RunTreeCommandInput.ts +14 -0
- package/src/RunTreeCommandResult.ts +3 -0
- package/src/SmithersEventType.ts +3 -0
- package/src/SupervisorOptions.ts +33 -0
- package/src/SupervisorPollSummary.ts +6 -0
- package/src/TreeRenderOptions.ts +5 -0
- package/src/WatchLoopOptions.ts +9 -0
- package/src/WatchLoopResult.ts +8 -0
- package/src/WatchRenderContext.ts +4 -0
- package/src/WhyBlocker.ts +17 -0
- package/src/WhyBlockerKind.ts +9 -0
- package/src/WhyDiagnosis.ts +10 -0
- package/src/WorkflowCta.ts +4 -0
- package/src/WorkflowSourceType.ts +1 -0
- package/src/agent-detection.js +257 -0
- package/src/ask.js +491 -0
- package/src/chat.js +226 -0
- package/src/diff.js +221 -0
- package/src/event-categories.js +141 -0
- package/src/find-db.js +93 -0
- package/src/format.js +272 -0
- package/src/hijack-session.js +207 -0
- package/src/hijack.js +226 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +4868 -0
- package/src/mcp/SemanticMcpServerOptions.ts +4 -0
- package/src/mcp/SemanticToolCallResult.ts +14 -0
- package/src/mcp/SemanticToolContext.ts +6 -0
- package/src/mcp/SemanticToolDefinition.ts +13 -0
- package/src/mcp/SemanticToolError.ts +6 -0
- package/src/mcp/semantic-server.js +41 -0
- package/src/mcp/semantic-tools.js +1242 -0
- package/src/node-detail.js +682 -0
- package/src/output.js +111 -0
- package/src/resume-detached.js +37 -0
- package/src/rewind.js +88 -0
- package/src/scheduler.js +112 -0
- package/src/smithersRuntime.js +63 -0
- package/src/supervisor.js +418 -0
- package/src/tree.js +307 -0
- package/src/tui/app.jsx +139 -0
- package/src/tui/app.tsx +5 -0
- package/src/tui/components/AskModal.jsx +109 -0
- package/src/tui/components/AskModal.tsx +3 -0
- package/src/tui/components/AttentionPane.jsx +112 -0
- package/src/tui/components/AttentionPane.tsx +6 -0
- package/src/tui/components/ChatPane.jsx +57 -0
- package/src/tui/components/ChatPane.tsx +7 -0
- package/src/tui/components/CronList.jsx +87 -0
- package/src/tui/components/CronList.tsx +5 -0
- package/src/tui/components/DetailsPane.jsx +96 -0
- package/src/tui/components/DetailsPane.tsx +7 -0
- package/src/tui/components/FramesPane.jsx +147 -0
- package/src/tui/components/FramesPane.tsx +8 -0
- package/src/tui/components/LogsPane.jsx +46 -0
- package/src/tui/components/LogsPane.tsx +6 -0
- package/src/tui/components/MetricsPane.jsx +108 -0
- package/src/tui/components/MetricsPane.tsx +5 -0
- package/src/tui/components/NodeDetailView.jsx +284 -0
- package/src/tui/components/NodeDetailView.tsx +7 -0
- package/src/tui/components/NodeInspector.jsx +51 -0
- package/src/tui/components/NodeInspector.tsx +7 -0
- package/src/tui/components/RunDetailView.jsx +190 -0
- package/src/tui/components/RunDetailView.tsx +7 -0
- package/src/tui/components/RunsList.jsx +184 -0
- package/src/tui/components/RunsList.tsx +7 -0
- package/src/tui/components/SqliteBrowser.jsx +131 -0
- package/src/tui/components/SqliteBrowser.tsx +5 -0
- package/src/tui/components/WorkflowLauncher.jsx +63 -0
- package/src/tui/components/WorkflowLauncher.tsx +3 -0
- package/src/util/CliErrorMapping.ts +7 -0
- package/src/util/CliExitCode.ts +10 -0
- package/src/util/errorMessage.js +212 -0
- package/src/util/exitCodes.js +18 -0
- package/src/watch.js +128 -0
- package/src/why-diagnosis.js +1000 -0
- package/src/workflow-pack.js +2151 -0
- package/src/workflows.js +122 -0
package/src/workflows.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// @smithers-type-exports-begin
|
|
2
|
+
/** @typedef {import("./WorkflowSourceType.ts").WorkflowSourceType} WorkflowSourceType */
|
|
3
|
+
// @smithers-type-exports-end
|
|
4
|
+
|
|
5
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync, } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { SmithersError } from "@smithers-orchestrator/errors";
|
|
8
|
+
|
|
9
|
+
/** @typedef {import("./DiscoveredWorkflow.ts").DiscoveredWorkflow} DiscoveredWorkflow */
|
|
10
|
+
|
|
11
|
+
const WORKFLOW_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} root
|
|
14
|
+
*/
|
|
15
|
+
function workflowsDir(root) {
|
|
16
|
+
return join(root, ".smithers", "workflows");
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} source
|
|
20
|
+
* @param {string} id
|
|
21
|
+
*/
|
|
22
|
+
function parseMetadata(source, id) {
|
|
23
|
+
const sourceMatch = source.match(/^\/\/\s*smithers-source:\s*(.+)$/m);
|
|
24
|
+
const displayMatch = source.match(/^\/\/\s*smithers-display-name:\s*(.+)$/m);
|
|
25
|
+
return {
|
|
26
|
+
sourceType: sourceMatch?.[1]?.trim() || "user",
|
|
27
|
+
displayName: displayMatch?.[1]?.trim() || id,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @param {string} file
|
|
32
|
+
* @param {string} root
|
|
33
|
+
* @returns {DiscoveredWorkflow}
|
|
34
|
+
*/
|
|
35
|
+
function workflowFromFile(file, root) {
|
|
36
|
+
const id = file.replace(/\.tsx$/, "");
|
|
37
|
+
const entryFile = join(workflowsDir(root), file);
|
|
38
|
+
const metadata = parseMetadata(readFileSync(entryFile, "utf8"), id);
|
|
39
|
+
return {
|
|
40
|
+
id,
|
|
41
|
+
displayName: metadata.displayName,
|
|
42
|
+
sourceType: metadata.sourceType,
|
|
43
|
+
entryFile,
|
|
44
|
+
path: entryFile,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @param {string} name
|
|
49
|
+
* @returns {string}
|
|
50
|
+
*/
|
|
51
|
+
function displayNameFromWorkflowName(name) {
|
|
52
|
+
return name
|
|
53
|
+
.split("-")
|
|
54
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
55
|
+
.join(" ");
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @param {string} root
|
|
59
|
+
* @returns {DiscoveredWorkflow[]}
|
|
60
|
+
*/
|
|
61
|
+
export function discoverWorkflows(root) {
|
|
62
|
+
const dir = workflowsDir(root);
|
|
63
|
+
if (!existsSync(dir))
|
|
64
|
+
return [];
|
|
65
|
+
return readdirSync(dir)
|
|
66
|
+
.filter((file) => file.endsWith(".tsx"))
|
|
67
|
+
.filter((file) => statSync(join(dir, file)).isFile())
|
|
68
|
+
.sort()
|
|
69
|
+
.map((file) => workflowFromFile(file, root));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @param {string} name
|
|
73
|
+
*/
|
|
74
|
+
export function validateWorkflowName(name) {
|
|
75
|
+
if (!WORKFLOW_NAME_PATTERN.test(name)) {
|
|
76
|
+
throw new SmithersError("INVALID_WORKFLOW_NAME", `Invalid workflow name: ${name}. Use lowercase kebab-case.`, { name });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @param {string} id
|
|
81
|
+
* @param {string} root
|
|
82
|
+
* @returns {DiscoveredWorkflow}
|
|
83
|
+
*/
|
|
84
|
+
export function resolveWorkflow(id, root) {
|
|
85
|
+
const workflow = discoverWorkflows(root).find((candidate) => candidate.id === id);
|
|
86
|
+
if (!workflow) {
|
|
87
|
+
throw new SmithersError("RUN_NOT_FOUND", `Workflow not found: ${id}`, {
|
|
88
|
+
id,
|
|
89
|
+
root,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return workflow;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @param {string} name
|
|
96
|
+
* @param {string} root
|
|
97
|
+
* @returns {DiscoveredWorkflow}
|
|
98
|
+
*/
|
|
99
|
+
export function createWorkflowFile(name, root) {
|
|
100
|
+
validateWorkflowName(name);
|
|
101
|
+
const dir = workflowsDir(root);
|
|
102
|
+
mkdirSync(dir, { recursive: true });
|
|
103
|
+
const entryFile = join(dir, `${name}.tsx`);
|
|
104
|
+
if (existsSync(entryFile)) {
|
|
105
|
+
throw new SmithersError("INVALID_INPUT", `Workflow already exists: ${name}`, {
|
|
106
|
+
name,
|
|
107
|
+
entryFile,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
writeFileSync(entryFile, [
|
|
111
|
+
"// smithers-source: generated",
|
|
112
|
+
`// smithers-display-name: ${displayNameFromWorkflowName(name)}`,
|
|
113
|
+
"/** @jsxImportSource smithers-orchestrator */",
|
|
114
|
+
'import { createSmithers, Workflow } from "smithers-orchestrator";',
|
|
115
|
+
"",
|
|
116
|
+
"const { smithers } = createSmithers({});",
|
|
117
|
+
"",
|
|
118
|
+
`export default smithers(() => <Workflow name="${name}" />);`,
|
|
119
|
+
"",
|
|
120
|
+
].join("\n"));
|
|
121
|
+
return workflowFromFile(`${name}.tsx`, root);
|
|
122
|
+
}
|