nolo-cli 0.1.32 → 0.1.33

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 (230) hide show
  1. package/README.md +0 -6
  2. package/agent-runtime/agentRecordConfig.ts +2 -0
  3. package/agent-runtime/hostAdapter.ts +1 -0
  4. package/agent-runtime/index.ts +0 -21
  5. package/agent-runtime/localToolPolicy.ts +6 -13
  6. package/agent-runtime/localWorkspaceTools.ts +30 -333
  7. package/agent-runtime/platformChatProvider.ts +1 -4
  8. package/agent-runtime/runtimeToolPolicy.ts +47 -32
  9. package/agentAliases.ts +14 -83
  10. package/agentCommandSupport.ts +3 -6
  11. package/agentInternalCommandEntries.ts +2 -13
  12. package/agentListCommands.ts +19 -28
  13. package/agentMachineCommands.ts +40 -336
  14. package/agentPullCommand.ts +36 -56
  15. package/agentRecordCommands.ts +3 -5
  16. package/agentRecordHelpers.ts +22 -189
  17. package/agentRunCommand.ts +438 -107
  18. package/agentRuntimeLocal.ts +0 -10
  19. package/ai/agent/cliExecutor.ts +19 -323
  20. package/authCommands.ts +2 -36
  21. package/cli/agentAliases.ts +14 -83
  22. package/cli/agentCommandSupport.ts +3 -6
  23. package/cli/agentInternalCommandEntries.ts +2 -13
  24. package/cli/agentListCommands.ts +19 -28
  25. package/cli/agentMachineCommands.ts +40 -336
  26. package/cli/agentPullCommand.ts +36 -56
  27. package/cli/agentRecordCommands.ts +3 -5
  28. package/cli/agentRecordHelpers.ts +22 -189
  29. package/cli/agentRunCommand.ts +438 -107
  30. package/cli/agentRuntimeLocal.ts +0 -10
  31. package/cli/authCommands.ts +2 -36
  32. package/cli/cliEnvHelpers.ts +21 -162
  33. package/cli/client/agentRun.ts +853 -57
  34. package/cli/client/localRuntimeAdapter.ts +22 -159
  35. package/cli/client/streamingOutput.ts +3 -1
  36. package/cli/client/taskRunPrompt.ts +24 -7
  37. package/cli/commandRegistry.ts +2 -3
  38. package/cli/connectorRunArtifact.ts +10 -34
  39. package/cli/connectorWebSocketTarget.ts +6 -10
  40. package/cli/internalCommandEntries.ts +0 -8
  41. package/cli/localRuntimeDb.ts +2 -39
  42. package/cli/machineCommands.ts +189 -190
  43. package/cli/machineDaemonCommands.ts +165 -9
  44. package/cli/machineHeartbeatCommands.ts +2 -1
  45. package/cli/machineStatusCommands.ts +13 -5
  46. package/cli/machineWatchCommands.ts +1 -1
  47. package/cli/machineWsRunDispatch.ts +14 -48
  48. package/cli/machineWsSession.ts +0 -2
  49. package/cli/offlineMarxistsAgentCommand.ts +314 -0
  50. package/cli/runtimeDoctorCommands.ts +69 -18
  51. package/cli/scriptCommandEntries.ts +45 -5
  52. package/cli/tableCommands.ts +133 -33
  53. package/cli/taskRunCommand.ts +211 -16
  54. package/cli/tui/session.ts +372 -43
  55. package/cli/workflowInternalCommandEntries.ts +0 -20
  56. package/cliEnvHelpers.ts +21 -162
  57. package/client/agentConfigResolver.test.ts +2 -0
  58. package/client/agentRun.test.ts +12 -208
  59. package/client/agentRun.ts +853 -57
  60. package/client/localRuntimeAdapter.test.ts +9 -168
  61. package/client/localRuntimeAdapter.ts +22 -159
  62. package/client/localToolPolicy.test.ts +4 -28
  63. package/client/streamingOutput.ts +3 -1
  64. package/client/taskRunPrompt.ts +24 -7
  65. package/commandRegistry.ts +2 -3
  66. package/connectorRunArtifact.ts +10 -34
  67. package/connectorWebSocketTarget.ts +6 -10
  68. package/database/server/db.ts +34 -15
  69. package/internalCommandEntries.ts +0 -8
  70. package/localRuntimeDb.ts +2 -39
  71. package/machineCommands.ts +189 -190
  72. package/machineDaemonCommands.ts +165 -9
  73. package/machineHeartbeatCommands.ts +2 -1
  74. package/machineStatusCommands.ts +13 -5
  75. package/machineWatchCommands.ts +1 -1
  76. package/machineWsRunDispatch.ts +14 -48
  77. package/machineWsSession.ts +0 -2
  78. package/offlineMarxistsAgentCommand.ts +314 -0
  79. package/package.json +49 -193
  80. package/runtimeDoctorCommands.ts +69 -18
  81. package/scriptCommandEntries.ts +45 -5
  82. package/tableCommands.ts +133 -33
  83. package/taskRunCommand.ts +211 -16
  84. package/tui/session.ts +372 -43
  85. package/workflowInternalCommandEntries.ts +0 -20
  86. package/agent-runtime/dialogStatus.ts +0 -139
  87. package/agent-runtime/hostRuntimeConfig.ts +0 -86
  88. package/agentCreateCustomCommands.ts +0 -278
  89. package/agentDialogsCommands.ts +0 -227
  90. package/agentDoctorCommands.ts +0 -203
  91. package/agentRunLocalWorkspace.ts +0 -182
  92. package/agentRunParsing.ts +0 -298
  93. package/agentSuperviseCommands.ts +0 -8
  94. package/agentUnpublishCommands.ts +0 -113
  95. package/ai/agent/agentRunDialogLineage.ts +0 -56
  96. package/ai/policy/types.ts +0 -64
  97. package/ai/skills/skillSummaryMarker.ts +0 -26
  98. package/app/types.ts +0 -358
  99. package/build.ts +0 -16
  100. package/buildPublish.ts +0 -138
  101. package/buildPublishArtifactAssembly.ts +0 -724
  102. package/buildPublishImportAnalysis.ts +0 -242
  103. package/chat/messages/fetchMessages.ts +0 -84
  104. package/chat/messages/types.ts +0 -185
  105. package/cli/agentCreateCustomCommands.ts +0 -278
  106. package/cli/agentDialogsCommands.ts +0 -227
  107. package/cli/agentDoctorCommands.ts +0 -203
  108. package/cli/agentRunLocalWorkspace.ts +0 -182
  109. package/cli/agentRunParsing.ts +0 -298
  110. package/cli/agentSuperviseCommands.ts +0 -8
  111. package/cli/agentUnpublishCommands.ts +0 -113
  112. package/cli/buildPublish.ts +0 -138
  113. package/cli/buildPublishArtifactAssembly.ts +0 -724
  114. package/cli/buildPublishImportAnalysis.ts +0 -242
  115. package/cli/cliIoTypes.ts +0 -3
  116. package/cli/cliRuntimeDoctorReport.ts +0 -193
  117. package/cli/client/agentRunInput.ts +0 -10
  118. package/cli/client/agentRunLocalExecution.ts +0 -124
  119. package/cli/client/agentRunLocalExecutor.ts +0 -179
  120. package/cli/client/agentRunRuntimeSelection.ts +0 -145
  121. package/cli/client/agentRunServerTransport.ts +0 -397
  122. package/cli/client/agentRunTaskRunRecorder.ts +0 -176
  123. package/cli/customCodingAgentFlow.ts +0 -208
  124. package/cli/customCodingAgentRecord.ts +0 -179
  125. package/cli/dialogDataAccess.ts +0 -186
  126. package/cli/dialogInternalCommandEntries.ts +0 -11
  127. package/cli/dialogReadCommands.ts +0 -180
  128. package/cli/dialogReadHelpers.ts +0 -226
  129. package/cli/dialogStatusCommands.ts +0 -123
  130. package/cli/docInternalCommandEntries.ts +0 -20
  131. package/cli/hybridReadHelpers.ts +0 -109
  132. package/cli/machineCommandPrompts.ts +0 -79
  133. package/cli/machineCommandResolution.ts +0 -43
  134. package/cli/noloReadBridgePrompt.ts +0 -16
  135. package/cli/pageCreateCommands.ts +0 -219
  136. package/cli/pageDeleteCommands.ts +0 -167
  137. package/cli/pageReadCommands.ts +0 -151
  138. package/cli/pageUpdateCommands.ts +0 -249
  139. package/cli/pageWriteHelpers.ts +0 -209
  140. package/cli/publishPackage.ts +0 -36
  141. package/cli/runtimeInternalCommandEntries.ts +0 -15
  142. package/cli/runtimePassthroughCommands.ts +0 -22
  143. package/cli/scriptPassthroughHelpers.ts +0 -28
  144. package/cli/secretScanHelpers.ts +0 -31
  145. package/cli/spaceAttachCommands.ts +0 -134
  146. package/cli/spaceCategoryCommands.ts +0 -263
  147. package/cli/spaceCommands.ts +0 -295
  148. package/cli/spaceDeleteCommands.ts +0 -312
  149. package/cli/spaceInternalCommandEntries.ts +0 -21
  150. package/cli/spaceMutationHelpers.ts +0 -135
  151. package/cli/spaceReadCommands.ts +0 -323
  152. package/cli/tableDataOutput.ts +0 -41
  153. package/cli/tableDataSafety.ts +0 -26
  154. package/cli/tableMetaCommands.ts +0 -307
  155. package/cli/tableMutationCommands.ts +0 -266
  156. package/cli/tableQueryParsing.ts +0 -90
  157. package/cli/tableQueryRequest.ts +0 -53
  158. package/cli/taskRunActions.ts +0 -122
  159. package/cli/taskRunParsing.ts +0 -86
  160. package/cli/taskRunPromptShared.ts +0 -55
  161. package/cli/tui/tuiCatalog.ts +0 -22
  162. package/cli/tui/tuiCommandInterpreter.ts +0 -253
  163. package/cli/tui/tuiPresentation.ts +0 -146
  164. package/cliIoTypes.ts +0 -3
  165. package/cliRuntimeDoctorReport.ts +0 -193
  166. package/client/agentRunInput.ts +0 -10
  167. package/client/agentRunLocalExecution.test.ts +0 -123
  168. package/client/agentRunLocalExecution.ts +0 -124
  169. package/client/agentRunLocalExecutor.ts +0 -179
  170. package/client/agentRunRuntimeSelection.test.ts +0 -159
  171. package/client/agentRunRuntimeSelection.ts +0 -145
  172. package/client/agentRunServerTransport.ts +0 -397
  173. package/client/agentRunTaskRunRecorder.ts +0 -176
  174. package/connector-experimental/daemonLauncher.ts +0 -223
  175. package/create/space/spaceKeys.ts +0 -65
  176. package/create/types.ts +0 -21
  177. package/customCodingAgentFlow.ts +0 -208
  178. package/customCodingAgentRecord.ts +0 -179
  179. package/database/keys.ts +0 -765
  180. package/database/server/authorityStoreTypes.ts +0 -31
  181. package/database/server/legacyServerDb.ts +0 -58
  182. package/database/server/levelAuthorityStore.ts +0 -75
  183. package/database/server/memoryAuthorityStore.ts +0 -133
  184. package/database/server/serverStoreFactory.ts +0 -124
  185. package/database/tombstones.ts +0 -52
  186. package/database/utils/ulid.ts +0 -1
  187. package/dialogDataAccess.ts +0 -186
  188. package/dialogInternalCommandEntries.ts +0 -11
  189. package/dialogReadCommands.ts +0 -180
  190. package/dialogReadHelpers.ts +0 -226
  191. package/dialogStatusCommands.ts +0 -123
  192. package/docInternalCommandEntries.ts +0 -20
  193. package/hybridReadHelpers.ts +0 -109
  194. package/machineCommandPrompts.ts +0 -79
  195. package/machineCommandResolution.ts +0 -43
  196. package/noloReadBridgePrompt.ts +0 -16
  197. package/pageCreateCommands.ts +0 -219
  198. package/pageDeleteCommands.ts +0 -167
  199. package/pageReadCommands.ts +0 -151
  200. package/pageUpdateCommands.ts +0 -249
  201. package/pageWriteHelpers.ts +0 -209
  202. package/publishPackage.ts +0 -36
  203. package/runtimeInternalCommandEntries.ts +0 -15
  204. package/runtimePassthroughCommands.ts +0 -22
  205. package/scriptPassthroughHelpers.ts +0 -28
  206. package/secretScanHelpers.ts +0 -31
  207. package/share/helpers.ts +0 -302
  208. package/share/keys.ts +0 -243
  209. package/share/types.ts +0 -100
  210. package/spaceAttachCommands.ts +0 -134
  211. package/spaceCategoryCommands.ts +0 -263
  212. package/spaceCommands.ts +0 -295
  213. package/spaceDeleteCommands.ts +0 -312
  214. package/spaceInternalCommandEntries.ts +0 -21
  215. package/spaceMutationHelpers.ts +0 -135
  216. package/spaceReadCommands.ts +0 -323
  217. package/tableDataOutput.ts +0 -41
  218. package/tableDataSafety.ts +0 -26
  219. package/tableMetaCommands.ts +0 -307
  220. package/tableMutationCommands.ts +0 -266
  221. package/tableQueryParsing.ts +0 -90
  222. package/tableQueryRequest.ts +0 -53
  223. package/taskRunActions.ts +0 -122
  224. package/taskRunParsing.ts +0 -86
  225. package/taskRunPromptShared.ts +0 -55
  226. package/tui/tuiCatalog.ts +0 -22
  227. package/tui/tuiCommandInterpreter.test.ts +0 -169
  228. package/tui/tuiCommandInterpreter.ts +0 -253
  229. package/tui/tuiPresentation.test.ts +0 -154
  230. 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
- });