nolo-cli 0.1.32 → 0.1.34

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 (234) hide show
  1. package/README.md +4 -10
  2. package/agent-runtime/agentRecordConfig.ts +10 -0
  3. package/agent-runtime/hostAdapter.ts +10 -1
  4. package/agent-runtime/index.ts +9 -20
  5. package/agent-runtime/localLoop.ts +49 -2
  6. package/agent-runtime/localToolPolicy.ts +76 -34
  7. package/agent-runtime/localWorkspaceTools.ts +30 -333
  8. package/agent-runtime/openAiCompatibleProvider.ts +7 -3
  9. package/agent-runtime/openAiCompatibleProviderConfig.ts +15 -26
  10. package/agent-runtime/platformChatProvider.ts +47 -73
  11. package/agent-runtime/providerResolution.ts +244 -0
  12. package/agent-runtime/runtimeToolPolicy.ts +77 -29
  13. package/agent-runtime/shellCommandPolicy.ts +120 -0
  14. package/agentAliases.ts +14 -83
  15. package/agentCommandSupport.ts +3 -6
  16. package/agentInternalCommandEntries.ts +4 -13
  17. package/agentListCommands.ts +18 -27
  18. package/agentMachineCommands.ts +40 -336
  19. package/agentPullCommand.ts +30 -55
  20. package/agentRecordCommands.ts +84 -1
  21. package/agentRecordHelpers.ts +102 -186
  22. package/agentRunCommand.ts +438 -107
  23. package/agentRuntimeLocal.ts +2 -9
  24. package/ai/agent/cliExecutor.ts +19 -323
  25. package/ai/tools/toolNameAliases.ts +70 -0
  26. package/authCommands.ts +2 -36
  27. package/cli/agentAliases.ts +14 -83
  28. package/cli/agentCommandSupport.ts +3 -6
  29. package/cli/agentInternalCommandEntries.ts +4 -13
  30. package/cli/agentListCommands.ts +18 -27
  31. package/cli/agentMachineCommands.ts +40 -336
  32. package/cli/agentPullCommand.ts +30 -55
  33. package/cli/agentRecordCommands.ts +84 -1
  34. package/cli/agentRecordHelpers.ts +102 -186
  35. package/cli/agentRunCommand.ts +438 -107
  36. package/cli/agentRuntimeLocal.ts +2 -9
  37. package/cli/authCommands.ts +2 -36
  38. package/cli/cliCommandDispatch.ts +2 -2
  39. package/cli/cliEnvHelpers.ts +34 -107
  40. package/cli/client/agentRun.ts +854 -57
  41. package/cli/client/localRuntimeAdapter.ts +59 -159
  42. package/cli/client/streamingOutput.ts +3 -1
  43. package/cli/client/taskRunPrompt.ts +24 -7
  44. package/cli/commandRegistry.ts +4 -5
  45. package/cli/connectorRunArtifact.ts +10 -34
  46. package/cli/connectorWebSocketTarget.ts +6 -10
  47. package/cli/internalCommandEntries.ts +0 -8
  48. package/cli/localRuntimeDb.ts +2 -39
  49. package/cli/machineCommands.ts +189 -190
  50. package/cli/machineDaemonCommands.ts +165 -9
  51. package/cli/machineHeartbeatCommands.ts +2 -1
  52. package/cli/machineStatusCommands.ts +13 -5
  53. package/cli/machineWatchCommands.ts +1 -1
  54. package/cli/machineWsRunDispatch.ts +30 -44
  55. package/cli/machineWsSession.ts +0 -2
  56. package/cli/offlineMarxistsAgentCommand.ts +314 -0
  57. package/cli/runtimeDoctorCommands.ts +72 -15
  58. package/cli/scriptCommandEntries.ts +45 -5
  59. package/cli/tableCommands.ts +133 -33
  60. package/cli/taskRunCommand.ts +211 -16
  61. package/cli/tui/session.ts +372 -43
  62. package/cli/workflowInternalCommandEntries.ts +0 -20
  63. package/cliCommandDispatch.ts +2 -2
  64. package/cliEnvHelpers.ts +34 -107
  65. package/client/agentConfigResolver.test.ts +2 -0
  66. package/client/agentRun.test.ts +12 -208
  67. package/client/agentRun.ts +854 -57
  68. package/client/localProviderResolver.test.ts +26 -2
  69. package/client/localRuntimeAdapter.test.ts +296 -171
  70. package/client/localRuntimeAdapter.ts +59 -159
  71. package/client/localToolPolicy.test.ts +4 -28
  72. package/client/streamingOutput.ts +3 -1
  73. package/client/taskRunPrompt.ts +24 -7
  74. package/commandRegistry.ts +4 -5
  75. package/connectorRunArtifact.ts +10 -34
  76. package/connectorWebSocketTarget.ts +6 -10
  77. package/database/server/serverStoreFactory.ts +2 -8
  78. package/internalCommandEntries.ts +0 -8
  79. package/localRuntimeDb.ts +2 -39
  80. package/machineCommands.ts +189 -190
  81. package/machineDaemonCommands.ts +165 -9
  82. package/machineHeartbeatCommands.ts +2 -1
  83. package/machineStatusCommands.ts +13 -5
  84. package/machineWatchCommands.ts +1 -1
  85. package/machineWsRunDispatch.ts +30 -44
  86. package/machineWsSession.ts +0 -2
  87. package/offlineMarxistsAgentCommand.ts +314 -0
  88. package/package.json +52 -188
  89. package/runtimeDoctorCommands.ts +72 -15
  90. package/scriptCommandEntries.ts +45 -5
  91. package/tableCommands.ts +133 -33
  92. package/taskRunCommand.ts +211 -16
  93. package/tui/session.ts +372 -43
  94. package/workflowInternalCommandEntries.ts +0 -20
  95. package/agent-runtime/dialogStatus.ts +0 -139
  96. package/agent-runtime/hostRuntimeConfig.ts +0 -86
  97. package/agentCreateCustomCommands.ts +0 -278
  98. package/agentDialogsCommands.ts +0 -227
  99. package/agentDoctorCommands.ts +0 -203
  100. package/agentRunLocalWorkspace.ts +0 -182
  101. package/agentRunParsing.ts +0 -298
  102. package/agentSuperviseCommands.ts +0 -8
  103. package/agentUnpublishCommands.ts +0 -113
  104. package/ai/agent/agentRunDialogLineage.ts +0 -56
  105. package/ai/policy/types.ts +0 -64
  106. package/ai/skills/skillSummaryMarker.ts +0 -26
  107. package/app/types.ts +0 -358
  108. package/build.ts +0 -16
  109. package/buildPublish.ts +0 -138
  110. package/buildPublishArtifactAssembly.ts +0 -724
  111. package/buildPublishImportAnalysis.ts +0 -242
  112. package/chat/messages/fetchMessages.ts +0 -84
  113. package/chat/messages/types.ts +0 -185
  114. package/cli/agentCreateCustomCommands.ts +0 -278
  115. package/cli/agentDialogsCommands.ts +0 -227
  116. package/cli/agentDoctorCommands.ts +0 -203
  117. package/cli/agentRunLocalWorkspace.ts +0 -182
  118. package/cli/agentRunParsing.ts +0 -298
  119. package/cli/agentSuperviseCommands.ts +0 -8
  120. package/cli/agentUnpublishCommands.ts +0 -113
  121. package/cli/buildPublish.ts +0 -138
  122. package/cli/buildPublishArtifactAssembly.ts +0 -724
  123. package/cli/buildPublishImportAnalysis.ts +0 -242
  124. package/cli/cliIoTypes.ts +0 -3
  125. package/cli/cliRuntimeDoctorReport.ts +0 -193
  126. package/cli/client/agentRunInput.ts +0 -10
  127. package/cli/client/agentRunLocalExecution.ts +0 -124
  128. package/cli/client/agentRunLocalExecutor.ts +0 -179
  129. package/cli/client/agentRunRuntimeSelection.ts +0 -145
  130. package/cli/client/agentRunServerTransport.ts +0 -397
  131. package/cli/client/agentRunTaskRunRecorder.ts +0 -176
  132. package/cli/customCodingAgentFlow.ts +0 -208
  133. package/cli/customCodingAgentRecord.ts +0 -179
  134. package/cli/dialogDataAccess.ts +0 -186
  135. package/cli/dialogInternalCommandEntries.ts +0 -11
  136. package/cli/dialogReadCommands.ts +0 -180
  137. package/cli/dialogReadHelpers.ts +0 -226
  138. package/cli/dialogStatusCommands.ts +0 -123
  139. package/cli/docInternalCommandEntries.ts +0 -20
  140. package/cli/hybridReadHelpers.ts +0 -109
  141. package/cli/machineCommandPrompts.ts +0 -79
  142. package/cli/machineCommandResolution.ts +0 -43
  143. package/cli/noloReadBridgePrompt.ts +0 -16
  144. package/cli/pageCreateCommands.ts +0 -219
  145. package/cli/pageDeleteCommands.ts +0 -167
  146. package/cli/pageReadCommands.ts +0 -151
  147. package/cli/pageUpdateCommands.ts +0 -249
  148. package/cli/pageWriteHelpers.ts +0 -209
  149. package/cli/publishPackage.ts +0 -36
  150. package/cli/runtimeInternalCommandEntries.ts +0 -15
  151. package/cli/runtimePassthroughCommands.ts +0 -22
  152. package/cli/scriptPassthroughHelpers.ts +0 -28
  153. package/cli/secretScanHelpers.ts +0 -31
  154. package/cli/spaceAttachCommands.ts +0 -134
  155. package/cli/spaceCategoryCommands.ts +0 -263
  156. package/cli/spaceCommands.ts +0 -295
  157. package/cli/spaceDeleteCommands.ts +0 -312
  158. package/cli/spaceInternalCommandEntries.ts +0 -21
  159. package/cli/spaceMutationHelpers.ts +0 -135
  160. package/cli/spaceReadCommands.ts +0 -323
  161. package/cli/tableDataOutput.ts +0 -41
  162. package/cli/tableDataSafety.ts +0 -26
  163. package/cli/tableMetaCommands.ts +0 -307
  164. package/cli/tableMutationCommands.ts +0 -266
  165. package/cli/tableQueryParsing.ts +0 -90
  166. package/cli/tableQueryRequest.ts +0 -53
  167. package/cli/taskRunActions.ts +0 -122
  168. package/cli/taskRunParsing.ts +0 -86
  169. package/cli/taskRunPromptShared.ts +0 -55
  170. package/cli/tui/tuiCatalog.ts +0 -22
  171. package/cli/tui/tuiCommandInterpreter.ts +0 -253
  172. package/cli/tui/tuiPresentation.ts +0 -146
  173. package/cliIoTypes.ts +0 -3
  174. package/cliRuntimeDoctorReport.ts +0 -193
  175. package/client/agentRunInput.ts +0 -10
  176. package/client/agentRunLocalExecution.test.ts +0 -123
  177. package/client/agentRunLocalExecution.ts +0 -124
  178. package/client/agentRunLocalExecutor.ts +0 -179
  179. package/client/agentRunRuntimeSelection.test.ts +0 -159
  180. package/client/agentRunRuntimeSelection.ts +0 -145
  181. package/client/agentRunServerTransport.ts +0 -397
  182. package/client/agentRunTaskRunRecorder.ts +0 -176
  183. package/connector-experimental/daemonLauncher.ts +0 -223
  184. package/create/space/spaceKeys.ts +0 -65
  185. package/create/types.ts +0 -21
  186. package/customCodingAgentFlow.ts +0 -208
  187. package/customCodingAgentRecord.ts +0 -179
  188. package/database/keys.ts +0 -765
  189. package/database/tombstones.ts +0 -52
  190. package/database/utils/ulid.ts +0 -1
  191. package/dialogDataAccess.ts +0 -186
  192. package/dialogInternalCommandEntries.ts +0 -11
  193. package/dialogReadCommands.ts +0 -180
  194. package/dialogReadHelpers.ts +0 -226
  195. package/dialogStatusCommands.ts +0 -123
  196. package/docInternalCommandEntries.ts +0 -20
  197. package/hybridReadHelpers.ts +0 -109
  198. package/machineCommandPrompts.ts +0 -79
  199. package/machineCommandResolution.ts +0 -43
  200. package/noloReadBridgePrompt.ts +0 -16
  201. package/pageCreateCommands.ts +0 -219
  202. package/pageDeleteCommands.ts +0 -167
  203. package/pageReadCommands.ts +0 -151
  204. package/pageUpdateCommands.ts +0 -249
  205. package/pageWriteHelpers.ts +0 -209
  206. package/publishPackage.ts +0 -36
  207. package/runtimeInternalCommandEntries.ts +0 -15
  208. package/runtimePassthroughCommands.ts +0 -22
  209. package/scriptPassthroughHelpers.ts +0 -28
  210. package/secretScanHelpers.ts +0 -31
  211. package/share/helpers.ts +0 -302
  212. package/share/keys.ts +0 -243
  213. package/share/types.ts +0 -100
  214. package/spaceAttachCommands.ts +0 -134
  215. package/spaceCategoryCommands.ts +0 -263
  216. package/spaceCommands.ts +0 -295
  217. package/spaceDeleteCommands.ts +0 -312
  218. package/spaceInternalCommandEntries.ts +0 -21
  219. package/spaceMutationHelpers.ts +0 -135
  220. package/spaceReadCommands.ts +0 -323
  221. package/tableDataOutput.ts +0 -41
  222. package/tableDataSafety.ts +0 -26
  223. package/tableMetaCommands.ts +0 -307
  224. package/tableMutationCommands.ts +0 -266
  225. package/tableQueryParsing.ts +0 -90
  226. package/tableQueryRequest.ts +0 -53
  227. package/taskRunActions.ts +0 -122
  228. package/taskRunParsing.ts +0 -86
  229. package/taskRunPromptShared.ts +0 -55
  230. package/tui/tuiCatalog.ts +0 -22
  231. package/tui/tuiCommandInterpreter.test.ts +0 -169
  232. package/tui/tuiCommandInterpreter.ts +0 -253
  233. package/tui/tuiPresentation.test.ts +0 -154
  234. package/tui/tuiPresentation.ts +0 -146
package/tui/tuiCatalog.ts DELETED
@@ -1,22 +0,0 @@
1
- export const DEFAULT_TUI_AGENT_KEY = "agent-pub-01NOLOAPPBLD000000019KCKT0";
2
-
3
- export const KNOWN_AGENTS: Array<{
4
- name: string;
5
- key: string;
6
- description: string;
7
- }> = [
8
- {
9
- name: "nolo",
10
- key: "agent-pub-01NOLOAPPBLD000000019KCKT0",
11
- description: "one assistant that routes work across your agents and data",
12
- },
13
- {
14
- name: "app-builder",
15
- key: "agent-pub-01APPBUILDER00000001YAII3I",
16
- description: "builds web apps, tools, charts, and product prototypes",
17
- },
18
- ];
19
-
20
- export const KNOWN_AGENT_ALIASES: Record<string, { name: string; key: string }> =
21
- Object.fromEntries(KNOWN_AGENTS.map((agent) => [agent.name, agent]));
22
-
@@ -1,169 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
-
3
- import {
4
- handleTuiInput,
5
- resolveSwitchTarget,
6
- type TuiCommandInterpreterDeps,
7
- type TuiInterpreterState,
8
- } from "./tuiCommandInterpreter";
9
-
10
- function createState(
11
- overrides: Partial<TuiInterpreterState> = {}
12
- ): TuiInterpreterState {
13
- return {
14
- agentKey: "agent-pub-01NOLOAPPBLD000000019KCKT0",
15
- agentName: "nolo",
16
- dialogLabel: "new",
17
- profileName: "local",
18
- serverUrl: "https://nolo.chat",
19
- attachedDocs: [],
20
- runtimeMode: "auto",
21
- ...overrides,
22
- };
23
- }
24
-
25
- function createDeps(): TuiCommandInterpreterDeps {
26
- return {
27
- knownAgents: [
28
- { name: "nolo", key: "agent-pub-01NOLOAPPBLD000000019KCKT0" },
29
- { name: "app-builder", key: "agent-pub-01APPBUILDER00000001YAII3I" },
30
- ],
31
- renderHelp: () => "HELP",
32
- renderContextPanel: () => "CONTEXT",
33
- renderKnownAgents: () => "AGENTS",
34
- };
35
- }
36
-
37
- describe("tuiCommandInterpreter", () => {
38
- test("treats normal text as a chat action", () => {
39
- const result = handleTuiInput("修一下通知面板", createState(), createDeps());
40
-
41
- expect(result.action).toEqual({
42
- type: "chat",
43
- message: "修一下通知面板",
44
- agentKey: "agent-pub-01NOLOAPPBLD000000019KCKT0",
45
- runtimeMode: "auto",
46
- });
47
- expect(result.output).toBe("");
48
- });
49
-
50
- test("includes continueDialogId for chat when dialog exists", () => {
51
- const result = handleTuiInput(
52
- "继续聊",
53
- createState({ dialogId: "01KQHZ56KKMA7G2F755QXFA3QX" }),
54
- createDeps()
55
- );
56
-
57
- expect(result.action).toEqual({
58
- type: "chat",
59
- message: "继续聊",
60
- agentKey: "agent-pub-01NOLOAPPBLD000000019KCKT0",
61
- runtimeMode: "auto",
62
- continueDialogId: "01KQHZ56KKMA7G2F755QXFA3QX",
63
- });
64
- });
65
-
66
- test("switches runtime modes and rejects invalid values", () => {
67
- const deps = createDeps();
68
- const state = createState();
69
-
70
- const local = handleTuiInput("/runtime local", state, deps);
71
- expect(local.nextState.runtimeMode).toBe("local");
72
- expect(local.output).toBe("Runtime: local");
73
-
74
- const server = handleTuiInput("/runtime server", local.nextState, deps);
75
- expect(server.nextState.runtimeMode).toBe("server");
76
- expect(server.output).toBe("Runtime: server");
77
-
78
- const invalid = handleTuiInput("/runtime nope", server.nextState, deps);
79
- expect(invalid.nextState.runtimeMode).toBe("server");
80
- expect(invalid.output).toBe("Usage: /runtime <auto|local|server>");
81
- });
82
-
83
- test("/new clears dialog state and attached docs", () => {
84
- const result = handleTuiInput(
85
- "/new",
86
- createState({
87
- dialogId: "01OLD",
88
- dialogLabel: "01OLD",
89
- attachedDocs: ["notes"],
90
- }),
91
- createDeps()
92
- );
93
-
94
- expect(result.nextState.dialogId).toBeUndefined();
95
- expect(result.nextState.dialogLabel).toBe("new");
96
- expect(result.nextState.attachedDocs).toEqual([]);
97
- });
98
-
99
- test("/compact handles action, missing dialog, extra text, and trailing whitespace", () => {
100
- const deps = createDeps();
101
- const withDialog = createState({ dialogId: "01OLD", dialogLabel: "01OLD" });
102
-
103
- expect(handleTuiInput("/compact", withDialog, deps).action).toEqual({
104
- type: "compact",
105
- dialogId: "01OLD",
106
- });
107
-
108
- const none = handleTuiInput("/compact", createState(), deps);
109
- expect(none.action).toBeUndefined();
110
- expect(none.output).toContain("nothing to compact");
111
-
112
- const extra = handleTuiInput("/compact anything", withDialog, deps);
113
- expect(extra.action).toBeUndefined();
114
- expect(extra.output).toBe("Unknown command: /compact anything\n\nHELP");
115
-
116
- expect(handleTuiInput(" /compact ", withDialog, deps).action).toEqual({
117
- type: "compact",
118
- dialogId: "01OLD",
119
- });
120
- });
121
-
122
- test("/switch resolves alias, numeric index, and full agent key", () => {
123
- const deps = createDeps();
124
- const state = createState();
125
-
126
- const alias = handleTuiInput("/switch app-builder", state, deps);
127
- expect(alias.nextState.agentName).toBe("app-builder");
128
- expect(alias.nextState.agentKey).toBe("agent-pub-01APPBUILDER00000001YAII3I");
129
-
130
- const numeric = handleTuiInput("/switch 2", state, deps);
131
- expect(numeric.nextState.agentName).toBe("app-builder");
132
-
133
- const fullKey = handleTuiInput("/switch agent-pub-01CUSTOM", state, deps);
134
- expect(fullKey.nextState.agentName).toBe("agent-pub-01CUSTOM");
135
- expect(fullKey.nextState.agentKey).toBe("agent-pub-01CUSTOM");
136
- });
137
-
138
- test("resolveSwitchTarget returns null for unknown targets", () => {
139
- expect(resolveSwitchTarget("missing", createDeps())).toBeNull();
140
- });
141
-
142
- test("/doc attach adds one doc and deduplicates repeats", () => {
143
- const deps = createDeps();
144
- const first = handleTuiInput("/doc attach product-plan", createState(), deps);
145
- expect(first.nextState.attachedDocs).toEqual(["product-plan"]);
146
- expect(first.output).toBe("Attached doc: product-plan");
147
-
148
- const again = handleTuiInput("/doc attach product-plan", first.nextState, deps);
149
- expect(again.nextState.attachedDocs).toEqual(["product-plan"]);
150
- });
151
-
152
- test("unknown commands include injected help output", () => {
153
- const result = handleTuiInput("/wat", createState(), createDeps());
154
- expect(result.output).toBe("Unknown command: /wat\n\nHELP");
155
- });
156
-
157
- test("/exit and /update emit actions without mutating state", () => {
158
- const state = createState({ attachedDocs: ["notes"] });
159
- const deps = createDeps();
160
-
161
- const exit = handleTuiInput("/exit", state, deps);
162
- expect(exit.nextState).toEqual(state);
163
- expect(exit.action).toEqual({ type: "exit" });
164
-
165
- const update = handleTuiInput("/update", state, deps);
166
- expect(update.nextState).toEqual(state);
167
- expect(update.action).toEqual({ type: "self-update" });
168
- });
169
- });
@@ -1,253 +0,0 @@
1
- import type { AgentRuntimeRequestedMode } from "../agentRuntimeLocal";
2
-
3
- export type TuiInterpreterState = {
4
- agentKey: string;
5
- agentName: string;
6
- dialogId?: string;
7
- dialogLabel: string;
8
- profileName: string;
9
- serverUrl: string;
10
- cliVersion?: string;
11
- attachedDocs: string[];
12
- runtimeMode: AgentRuntimeRequestedMode;
13
- };
14
-
15
- export type TuiInterpreterAction =
16
- | {
17
- type: "chat";
18
- message: string;
19
- agentKey: string;
20
- runtimeMode: AgentRuntimeRequestedMode;
21
- continueDialogId?: string;
22
- }
23
- | {
24
- type: "compact";
25
- dialogId: string;
26
- }
27
- | {
28
- type: "self-update";
29
- }
30
- | {
31
- type: "exit";
32
- };
33
-
34
- export type TuiInterpreterResult = {
35
- nextState: TuiInterpreterState;
36
- output: string;
37
- action?: TuiInterpreterAction;
38
- };
39
-
40
- export type TuiKnownAgent = {
41
- name: string;
42
- key: string;
43
- };
44
-
45
- export type TuiCommandInterpreterDeps = {
46
- knownAgents: TuiKnownAgent[];
47
- renderHelp: () => string;
48
- renderContextPanel: (state: TuiInterpreterState) => string;
49
- renderKnownAgents: () => string;
50
- };
51
-
52
- export function resolveSwitchTarget(
53
- rawTarget: string,
54
- deps: Pick<TuiCommandInterpreterDeps, "knownAgents">
55
- ) {
56
- const target = rawTarget.trim();
57
- if (/^\d+$/.test(target)) {
58
- const agent = deps.knownAgents[Number(target) - 1];
59
- return agent ? { name: agent.name, key: agent.key } : null;
60
- }
61
-
62
- const knownAgentAliases: Record<string, TuiKnownAgent> = Object.fromEntries(
63
- deps.knownAgents.map((agent) => [agent.name.toLowerCase(), agent])
64
- );
65
- const alias = knownAgentAliases[target.toLowerCase()];
66
- if (alias) return alias;
67
-
68
- if (target.startsWith("agent-") || target.startsWith("agent-pub-")) {
69
- return { name: target, key: target };
70
- }
71
-
72
- return null;
73
- }
74
-
75
- export function handleTuiInput(
76
- input: string,
77
- state: TuiInterpreterState,
78
- deps: TuiCommandInterpreterDeps
79
- ): TuiInterpreterResult {
80
- const trimmed = input.trim();
81
- if (!trimmed) {
82
- return { nextState: state, output: "" };
83
- }
84
-
85
- if (!trimmed.startsWith("/")) {
86
- return {
87
- nextState: state,
88
- output: "",
89
- action: {
90
- type: "chat",
91
- message: trimmed,
92
- agentKey: state.agentKey,
93
- runtimeMode: state.runtimeMode,
94
- ...(state.dialogId ? { continueDialogId: state.dialogId } : {}),
95
- },
96
- };
97
- }
98
-
99
- const [command = "", ...rest] = trimmed.split(/\s+/);
100
- const argText = rest.join(" ").trim();
101
-
102
- switch (command) {
103
- case "/help":
104
- return { nextState: state, output: deps.renderHelp() };
105
- case "/context":
106
- case "/ctx":
107
- return { nextState: state, output: deps.renderContextPanel(state) };
108
- case "/runtime": {
109
- if (argText !== "auto" && argText !== "local" && argText !== "server") {
110
- return {
111
- nextState: state,
112
- output: "Usage: /runtime <auto|local|server>",
113
- };
114
- }
115
-
116
- return {
117
- nextState: { ...state, runtimeMode: argText },
118
- output: `Runtime: ${argText}`,
119
- };
120
- }
121
- case "/exit":
122
- case "/quit":
123
- return { nextState: state, output: "Bye.", action: { type: "exit" } };
124
- case "/new":
125
- return {
126
- nextState: {
127
- ...state,
128
- dialogId: undefined,
129
- dialogLabel: "new",
130
- attachedDocs: [],
131
- },
132
- output: "Started a fresh dialog.",
133
- };
134
- case "/compact":
135
- if (argText) {
136
- return {
137
- nextState: state,
138
- output: `Unknown command: ${trimmed}\n\n${deps.renderHelp()}`,
139
- };
140
- }
141
- if (!state.dialogId) {
142
- return {
143
- nextState: state,
144
- output: "Current dialog: new (nothing to compact yet)",
145
- };
146
- }
147
- return {
148
- nextState: state,
149
- output: "Compacting current dialog...",
150
- action: { type: "compact", dialogId: state.dialogId },
151
- };
152
- case "/agent":
153
- return {
154
- nextState: state,
155
- output: `Current agent: ${state.agentName} (${state.agentKey})`,
156
- };
157
- case "/agents":
158
- return {
159
- nextState: state,
160
- output: deps.renderKnownAgents(),
161
- };
162
- case "/switch": {
163
- if (!argText) {
164
- return {
165
- nextState: state,
166
- output: "Usage: /switch <agent-key|alias>",
167
- };
168
- }
169
- const resolvedTarget = resolveSwitchTarget(argText, deps);
170
- if (!resolvedTarget) {
171
- return {
172
- nextState: state,
173
- output:
174
- `I don't know agent shortcut "${argText}" yet.\n` +
175
- "Use /switch nolo, /switch app-builder, or a full agent key like agent-pub-...",
176
- };
177
- }
178
- return {
179
- nextState: {
180
- ...state,
181
- agentName: resolvedTarget.name,
182
- agentKey: resolvedTarget.key,
183
- },
184
- output: `Switched to ${resolvedTarget.name}.`,
185
- };
186
- }
187
- case "/dialog":
188
- return {
189
- nextState: state,
190
- output: state.dialogId
191
- ? `Current dialog: ${state.dialogId}`
192
- : "Current dialog: new",
193
- };
194
- case "/doc": {
195
- if (rest[0] === "attach") {
196
- const docName = rest.slice(1).join(" ").trim();
197
- if (!docName) {
198
- return { nextState: state, output: "Usage: /doc attach <doc>" };
199
- }
200
- const attachedDocs = state.attachedDocs.includes(docName)
201
- ? state.attachedDocs
202
- : [...state.attachedDocs, docName];
203
- return {
204
- nextState: { ...state, attachedDocs },
205
- output: `Attached doc: ${docName}`,
206
- };
207
- }
208
- return {
209
- nextState: state,
210
- output:
211
- state.attachedDocs.length > 0
212
- ? `Attached docs: ${state.attachedDocs.join(", ")}`
213
- : "No docs attached. Use /doc attach <doc>.",
214
- };
215
- }
216
- case "/customize":
217
- return {
218
- nextState: state,
219
- output:
220
- "Tell nolo what to change, for example: /customize make my default agent more concise.",
221
- };
222
- case "/login":
223
- return {
224
- nextState: state,
225
- output:
226
- "MVP login uses profile/env auth. Set AUTH_TOKEN, NOLO_SERVER, or NOLO_PROFILE before starting nolo.",
227
- };
228
- case "/profile":
229
- return {
230
- nextState: state,
231
- output: `Profile: ${state.profileName}`,
232
- };
233
- case "/update":
234
- return {
235
- nextState: state,
236
- output: "Starting self-update...",
237
- action: { type: "self-update" },
238
- };
239
- case "/version":
240
- return {
241
- nextState: state,
242
- output:
243
- `nolo ${state.cliVersion || "unknown version"}\n` +
244
- "Update this install with: nolo update\n" +
245
- "If repo-local output differs, publish/install the latest npm package first.",
246
- };
247
- default:
248
- return {
249
- nextState: state,
250
- output: `Unknown command: ${command}\n\n${deps.renderHelp()}`,
251
- };
252
- }
253
- }
@@ -1,154 +0,0 @@
1
- import { describe, expect, it } from "bun:test";
2
- import {
3
- createInitialTuiState,
4
- DEFAULT_TUI_SERVER_URL,
5
- renderContextPanel,
6
- renderKnownAgents,
7
- renderPrompt,
8
- renderStatusLine,
9
- renderTuiHelp,
10
- renderWelcome,
11
- resolveDialogLabel,
12
- shortenDialogId,
13
- type TuiState,
14
- } from "./tuiPresentation";
15
-
16
- describe("createInitialTuiState", () => {
17
- it("uses defaults when env is empty", () => {
18
- expect(createInitialTuiState({})).toEqual({
19
- agentKey: "agent-pub-01NOLOAPPBLD000000019KCKT0",
20
- agentName: "nolo",
21
- dialogId: undefined,
22
- dialogLabel: "new",
23
- profileName: "local",
24
- serverUrl: DEFAULT_TUI_SERVER_URL,
25
- cliVersion: undefined,
26
- attachedDocs: [],
27
- runtimeMode: "auto",
28
- });
29
- });
30
-
31
- it("uses env overrides and trims trailing server slashes", () => {
32
- expect(
33
- createInitialTuiState({
34
- NOLO_AGENT: " agent-custom ",
35
- NOLO_AGENT_NAME: " builder ",
36
- NOLO_DIALOG_ID: " dialog-1234567890abcd ",
37
- NOLO_DIALOG: " ignored ",
38
- NOLO_PROFILE: " team ",
39
- NOLO_SERVER: "https://nolo.chat///",
40
- NOLO_CLI_VERSION: " 1.2.3 ",
41
- NOLO_RUNTIME_MODE: "local",
42
- })
43
- ).toEqual({
44
- agentKey: "agent-custom",
45
- agentName: "builder",
46
- dialogId: "dialog-1234567890abcd",
47
- dialogLabel: "ignored",
48
- profileName: "team",
49
- serverUrl: "https://nolo.chat",
50
- cliVersion: "1.2.3",
51
- attachedDocs: [],
52
- runtimeMode: "local",
53
- });
54
- });
55
- });
56
-
57
- describe("dialog label helpers", () => {
58
- it("shortens long dialog ids", () => {
59
- expect(shortenDialogId("dialog-1234567890abcd")).toBe("dialog...abcd");
60
- });
61
-
62
- it("prefers shortened dialog id over label", () => {
63
- expect(
64
- resolveDialogLabel({
65
- dialogId: "dialog-1234567890abcd",
66
- dialogLabel: "custom",
67
- })
68
- ).toBe("dialog...abcd");
69
- });
70
-
71
- it("falls back to dialog label", () => {
72
- expect(
73
- resolveDialogLabel({
74
- dialogId: undefined,
75
- dialogLabel: "new",
76
- })
77
- ).toBe("new");
78
- });
79
- });
80
-
81
- describe("presentation helpers", () => {
82
- const state: TuiState = {
83
- agentKey: "agent-pub-01NOLOAPPBLD000000019KCKT0",
84
- agentName: "nolo",
85
- dialogId: "dialog-1234567890abcd",
86
- dialogLabel: "new",
87
- profileName: "local",
88
- serverUrl: "https://nolo.chat",
89
- cliVersion: "1.2.3",
90
- attachedDocs: ["spec.md", "notes.md"],
91
- runtimeMode: "server",
92
- };
93
-
94
- it("renders status line", () => {
95
- expect(renderStatusLine(state)).toBe(
96
- "agent nolo | dialog dialog...abcd | docs 2 | runtime server | profile local"
97
- );
98
- });
99
-
100
- it("renders welcome block", () => {
101
- expect(renderWelcome(state)).toBe(
102
- [
103
- "",
104
- "Nolo workspace nolo 1.2.3",
105
- "agent nolo | dialog dialog...abcd | docs 2 attached | profile local",
106
- "server https://nolo.chat",
107
- "",
108
- "Tell nolo what you want. Use /help for commands. Use /version if this install feels stale.",
109
- "",
110
- ].join("\n")
111
- );
112
- });
113
-
114
- it("renders prompt", () => {
115
- expect(renderPrompt(state)).toBe("you > ");
116
- });
117
-
118
- it("renders help", () => {
119
- expect(renderTuiHelp()).toContain("/runtime <mode>");
120
- expect(renderTuiHelp()).toContain("/agents");
121
- });
122
-
123
- it("renders context panel", () => {
124
- expect(renderContextPanel(state)).toBe(
125
- [
126
- "Workspace context",
127
- "-----------------",
128
- "agent nolo",
129
- "dialog dialog...abcd",
130
- "docs spec.md, notes.md",
131
- "profile local",
132
- "runtime server",
133
- "server https://nolo.chat",
134
- "",
135
- "Next:",
136
- " /agents see specialist shortcuts",
137
- " /doc attach <doc> add working context",
138
- " /new start a clean dialog",
139
- ].join("\n")
140
- );
141
- });
142
-
143
- it("renders known agents", () => {
144
- expect(renderKnownAgents()).toBe(
145
- [
146
- "Agents:",
147
- " 1 nolo one assistant that routes work across your agents and data",
148
- " 2 app-builder builds web apps, tools, charts, and product prototypes",
149
- "",
150
- "Tip: stay on nolo for the one-assistant feel; switch only when you want a specialist directly.",
151
- ].join("\n")
152
- );
153
- });
154
- });