@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.
Files changed (110) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +55 -0
  3. package/src/AgentAvailability.ts +13 -0
  4. package/src/AgentAvailabilityStatus.ts +5 -0
  5. package/src/AggregateNodeDetailParams.ts +5 -0
  6. package/src/AskOptions.ts +12 -0
  7. package/src/ChatAttemptMeta.ts +7 -0
  8. package/src/ChatAttemptRow.ts +12 -0
  9. package/src/ChatOutputEvent.ts +6 -0
  10. package/src/DiffBundleLike.ts +6 -0
  11. package/src/DiscoveredWorkflow.ts +9 -0
  12. package/src/EnrichedNodeDetail.ts +60 -0
  13. package/src/EventCategory.ts +18 -0
  14. package/src/FindDbWaitOptions.ts +4 -0
  15. package/src/FormatEventLineOptions.ts +4 -0
  16. package/src/HijackCandidate.ts +11 -0
  17. package/src/HijackLaunchSpec.ts +6 -0
  18. package/src/InitWorkflowPackOptions.ts +4 -0
  19. package/src/InitWorkflowPackResult.ts +6 -0
  20. package/src/NativeHijackEngine.ts +8 -0
  21. package/src/NodeDetailAttempt.ts +22 -0
  22. package/src/NodeDetailTokenUsage.ts +11 -0
  23. package/src/NodeDetailToolCall.ts +12 -0
  24. package/src/ParsedNodeOutputEvent.ts +9 -0
  25. package/src/RenderNodeDetailOptions.ts +4 -0
  26. package/src/RunAutoResumeSkipReason.ts +4 -0
  27. package/src/RunDiffCommandInput.ts +13 -0
  28. package/src/RunDiffCommandResult.ts +3 -0
  29. package/src/RunOutputCommandInput.ts +12 -0
  30. package/src/RunOutputCommandResult.ts +3 -0
  31. package/src/RunRewindCommandInput.ts +14 -0
  32. package/src/RunRewindCommandResult.ts +3 -0
  33. package/src/RunTreeCommandInput.ts +14 -0
  34. package/src/RunTreeCommandResult.ts +3 -0
  35. package/src/SmithersEventType.ts +3 -0
  36. package/src/SupervisorOptions.ts +33 -0
  37. package/src/SupervisorPollSummary.ts +6 -0
  38. package/src/TreeRenderOptions.ts +5 -0
  39. package/src/WatchLoopOptions.ts +9 -0
  40. package/src/WatchLoopResult.ts +8 -0
  41. package/src/WatchRenderContext.ts +4 -0
  42. package/src/WhyBlocker.ts +17 -0
  43. package/src/WhyBlockerKind.ts +9 -0
  44. package/src/WhyDiagnosis.ts +10 -0
  45. package/src/WorkflowCta.ts +4 -0
  46. package/src/WorkflowSourceType.ts +1 -0
  47. package/src/agent-detection.js +257 -0
  48. package/src/ask.js +491 -0
  49. package/src/chat.js +226 -0
  50. package/src/diff.js +221 -0
  51. package/src/event-categories.js +141 -0
  52. package/src/find-db.js +93 -0
  53. package/src/format.js +272 -0
  54. package/src/hijack-session.js +207 -0
  55. package/src/hijack.js +226 -0
  56. package/src/index.d.ts +1 -0
  57. package/src/index.js +4868 -0
  58. package/src/mcp/SemanticMcpServerOptions.ts +4 -0
  59. package/src/mcp/SemanticToolCallResult.ts +14 -0
  60. package/src/mcp/SemanticToolContext.ts +6 -0
  61. package/src/mcp/SemanticToolDefinition.ts +13 -0
  62. package/src/mcp/SemanticToolError.ts +6 -0
  63. package/src/mcp/semantic-server.js +41 -0
  64. package/src/mcp/semantic-tools.js +1242 -0
  65. package/src/node-detail.js +682 -0
  66. package/src/output.js +111 -0
  67. package/src/resume-detached.js +37 -0
  68. package/src/rewind.js +88 -0
  69. package/src/scheduler.js +112 -0
  70. package/src/smithersRuntime.js +63 -0
  71. package/src/supervisor.js +418 -0
  72. package/src/tree.js +307 -0
  73. package/src/tui/app.jsx +139 -0
  74. package/src/tui/app.tsx +5 -0
  75. package/src/tui/components/AskModal.jsx +109 -0
  76. package/src/tui/components/AskModal.tsx +3 -0
  77. package/src/tui/components/AttentionPane.jsx +112 -0
  78. package/src/tui/components/AttentionPane.tsx +6 -0
  79. package/src/tui/components/ChatPane.jsx +57 -0
  80. package/src/tui/components/ChatPane.tsx +7 -0
  81. package/src/tui/components/CronList.jsx +87 -0
  82. package/src/tui/components/CronList.tsx +5 -0
  83. package/src/tui/components/DetailsPane.jsx +96 -0
  84. package/src/tui/components/DetailsPane.tsx +7 -0
  85. package/src/tui/components/FramesPane.jsx +147 -0
  86. package/src/tui/components/FramesPane.tsx +8 -0
  87. package/src/tui/components/LogsPane.jsx +46 -0
  88. package/src/tui/components/LogsPane.tsx +6 -0
  89. package/src/tui/components/MetricsPane.jsx +108 -0
  90. package/src/tui/components/MetricsPane.tsx +5 -0
  91. package/src/tui/components/NodeDetailView.jsx +284 -0
  92. package/src/tui/components/NodeDetailView.tsx +7 -0
  93. package/src/tui/components/NodeInspector.jsx +51 -0
  94. package/src/tui/components/NodeInspector.tsx +7 -0
  95. package/src/tui/components/RunDetailView.jsx +190 -0
  96. package/src/tui/components/RunDetailView.tsx +7 -0
  97. package/src/tui/components/RunsList.jsx +184 -0
  98. package/src/tui/components/RunsList.tsx +7 -0
  99. package/src/tui/components/SqliteBrowser.jsx +131 -0
  100. package/src/tui/components/SqliteBrowser.tsx +5 -0
  101. package/src/tui/components/WorkflowLauncher.jsx +63 -0
  102. package/src/tui/components/WorkflowLauncher.tsx +3 -0
  103. package/src/util/CliErrorMapping.ts +7 -0
  104. package/src/util/CliExitCode.ts +10 -0
  105. package/src/util/errorMessage.js +212 -0
  106. package/src/util/exitCodes.js +18 -0
  107. package/src/watch.js +128 -0
  108. package/src/why-diagnosis.js +1000 -0
  109. package/src/workflow-pack.js +2151 -0
  110. package/src/workflows.js +122 -0
@@ -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
+ }