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.
- package/README.md +0 -6
- package/agent-runtime/agentRecordConfig.ts +2 -0
- package/agent-runtime/hostAdapter.ts +1 -0
- package/agent-runtime/index.ts +0 -21
- package/agent-runtime/localToolPolicy.ts +6 -13
- package/agent-runtime/localWorkspaceTools.ts +30 -333
- package/agent-runtime/platformChatProvider.ts +1 -4
- package/agent-runtime/runtimeToolPolicy.ts +47 -32
- package/agentAliases.ts +14 -83
- package/agentCommandSupport.ts +3 -6
- package/agentInternalCommandEntries.ts +2 -13
- package/agentListCommands.ts +19 -28
- package/agentMachineCommands.ts +40 -336
- package/agentPullCommand.ts +36 -56
- package/agentRecordCommands.ts +3 -5
- package/agentRecordHelpers.ts +22 -189
- package/agentRunCommand.ts +438 -107
- package/agentRuntimeLocal.ts +0 -10
- package/ai/agent/cliExecutor.ts +19 -323
- package/authCommands.ts +2 -36
- package/cli/agentAliases.ts +14 -83
- package/cli/agentCommandSupport.ts +3 -6
- package/cli/agentInternalCommandEntries.ts +2 -13
- package/cli/agentListCommands.ts +19 -28
- package/cli/agentMachineCommands.ts +40 -336
- package/cli/agentPullCommand.ts +36 -56
- package/cli/agentRecordCommands.ts +3 -5
- package/cli/agentRecordHelpers.ts +22 -189
- package/cli/agentRunCommand.ts +438 -107
- package/cli/agentRuntimeLocal.ts +0 -10
- package/cli/authCommands.ts +2 -36
- package/cli/cliEnvHelpers.ts +21 -162
- package/cli/client/agentRun.ts +853 -57
- package/cli/client/localRuntimeAdapter.ts +22 -159
- package/cli/client/streamingOutput.ts +3 -1
- package/cli/client/taskRunPrompt.ts +24 -7
- package/cli/commandRegistry.ts +2 -3
- package/cli/connectorRunArtifact.ts +10 -34
- package/cli/connectorWebSocketTarget.ts +6 -10
- package/cli/internalCommandEntries.ts +0 -8
- package/cli/localRuntimeDb.ts +2 -39
- package/cli/machineCommands.ts +189 -190
- package/cli/machineDaemonCommands.ts +165 -9
- package/cli/machineHeartbeatCommands.ts +2 -1
- package/cli/machineStatusCommands.ts +13 -5
- package/cli/machineWatchCommands.ts +1 -1
- package/cli/machineWsRunDispatch.ts +14 -48
- package/cli/machineWsSession.ts +0 -2
- package/cli/offlineMarxistsAgentCommand.ts +314 -0
- package/cli/runtimeDoctorCommands.ts +69 -18
- package/cli/scriptCommandEntries.ts +45 -5
- package/cli/tableCommands.ts +133 -33
- package/cli/taskRunCommand.ts +211 -16
- package/cli/tui/session.ts +372 -43
- package/cli/workflowInternalCommandEntries.ts +0 -20
- package/cliEnvHelpers.ts +21 -162
- package/client/agentConfigResolver.test.ts +2 -0
- package/client/agentRun.test.ts +12 -208
- package/client/agentRun.ts +853 -57
- package/client/localRuntimeAdapter.test.ts +9 -168
- package/client/localRuntimeAdapter.ts +22 -159
- package/client/localToolPolicy.test.ts +4 -28
- package/client/streamingOutput.ts +3 -1
- package/client/taskRunPrompt.ts +24 -7
- package/commandRegistry.ts +2 -3
- package/connectorRunArtifact.ts +10 -34
- package/connectorWebSocketTarget.ts +6 -10
- package/database/server/db.ts +34 -15
- package/internalCommandEntries.ts +0 -8
- package/localRuntimeDb.ts +2 -39
- package/machineCommands.ts +189 -190
- package/machineDaemonCommands.ts +165 -9
- package/machineHeartbeatCommands.ts +2 -1
- package/machineStatusCommands.ts +13 -5
- package/machineWatchCommands.ts +1 -1
- package/machineWsRunDispatch.ts +14 -48
- package/machineWsSession.ts +0 -2
- package/offlineMarxistsAgentCommand.ts +314 -0
- package/package.json +49 -193
- package/runtimeDoctorCommands.ts +69 -18
- package/scriptCommandEntries.ts +45 -5
- package/tableCommands.ts +133 -33
- package/taskRunCommand.ts +211 -16
- package/tui/session.ts +372 -43
- package/workflowInternalCommandEntries.ts +0 -20
- package/agent-runtime/dialogStatus.ts +0 -139
- package/agent-runtime/hostRuntimeConfig.ts +0 -86
- package/agentCreateCustomCommands.ts +0 -278
- package/agentDialogsCommands.ts +0 -227
- package/agentDoctorCommands.ts +0 -203
- package/agentRunLocalWorkspace.ts +0 -182
- package/agentRunParsing.ts +0 -298
- package/agentSuperviseCommands.ts +0 -8
- package/agentUnpublishCommands.ts +0 -113
- package/ai/agent/agentRunDialogLineage.ts +0 -56
- package/ai/policy/types.ts +0 -64
- package/ai/skills/skillSummaryMarker.ts +0 -26
- package/app/types.ts +0 -358
- package/build.ts +0 -16
- package/buildPublish.ts +0 -138
- package/buildPublishArtifactAssembly.ts +0 -724
- package/buildPublishImportAnalysis.ts +0 -242
- package/chat/messages/fetchMessages.ts +0 -84
- package/chat/messages/types.ts +0 -185
- package/cli/agentCreateCustomCommands.ts +0 -278
- package/cli/agentDialogsCommands.ts +0 -227
- package/cli/agentDoctorCommands.ts +0 -203
- package/cli/agentRunLocalWorkspace.ts +0 -182
- package/cli/agentRunParsing.ts +0 -298
- package/cli/agentSuperviseCommands.ts +0 -8
- package/cli/agentUnpublishCommands.ts +0 -113
- package/cli/buildPublish.ts +0 -138
- package/cli/buildPublishArtifactAssembly.ts +0 -724
- package/cli/buildPublishImportAnalysis.ts +0 -242
- package/cli/cliIoTypes.ts +0 -3
- package/cli/cliRuntimeDoctorReport.ts +0 -193
- package/cli/client/agentRunInput.ts +0 -10
- package/cli/client/agentRunLocalExecution.ts +0 -124
- package/cli/client/agentRunLocalExecutor.ts +0 -179
- package/cli/client/agentRunRuntimeSelection.ts +0 -145
- package/cli/client/agentRunServerTransport.ts +0 -397
- package/cli/client/agentRunTaskRunRecorder.ts +0 -176
- package/cli/customCodingAgentFlow.ts +0 -208
- package/cli/customCodingAgentRecord.ts +0 -179
- package/cli/dialogDataAccess.ts +0 -186
- package/cli/dialogInternalCommandEntries.ts +0 -11
- package/cli/dialogReadCommands.ts +0 -180
- package/cli/dialogReadHelpers.ts +0 -226
- package/cli/dialogStatusCommands.ts +0 -123
- package/cli/docInternalCommandEntries.ts +0 -20
- package/cli/hybridReadHelpers.ts +0 -109
- package/cli/machineCommandPrompts.ts +0 -79
- package/cli/machineCommandResolution.ts +0 -43
- package/cli/noloReadBridgePrompt.ts +0 -16
- package/cli/pageCreateCommands.ts +0 -219
- package/cli/pageDeleteCommands.ts +0 -167
- package/cli/pageReadCommands.ts +0 -151
- package/cli/pageUpdateCommands.ts +0 -249
- package/cli/pageWriteHelpers.ts +0 -209
- package/cli/publishPackage.ts +0 -36
- package/cli/runtimeInternalCommandEntries.ts +0 -15
- package/cli/runtimePassthroughCommands.ts +0 -22
- package/cli/scriptPassthroughHelpers.ts +0 -28
- package/cli/secretScanHelpers.ts +0 -31
- package/cli/spaceAttachCommands.ts +0 -134
- package/cli/spaceCategoryCommands.ts +0 -263
- package/cli/spaceCommands.ts +0 -295
- package/cli/spaceDeleteCommands.ts +0 -312
- package/cli/spaceInternalCommandEntries.ts +0 -21
- package/cli/spaceMutationHelpers.ts +0 -135
- package/cli/spaceReadCommands.ts +0 -323
- package/cli/tableDataOutput.ts +0 -41
- package/cli/tableDataSafety.ts +0 -26
- package/cli/tableMetaCommands.ts +0 -307
- package/cli/tableMutationCommands.ts +0 -266
- package/cli/tableQueryParsing.ts +0 -90
- package/cli/tableQueryRequest.ts +0 -53
- package/cli/taskRunActions.ts +0 -122
- package/cli/taskRunParsing.ts +0 -86
- package/cli/taskRunPromptShared.ts +0 -55
- package/cli/tui/tuiCatalog.ts +0 -22
- package/cli/tui/tuiCommandInterpreter.ts +0 -253
- package/cli/tui/tuiPresentation.ts +0 -146
- package/cliIoTypes.ts +0 -3
- package/cliRuntimeDoctorReport.ts +0 -193
- package/client/agentRunInput.ts +0 -10
- package/client/agentRunLocalExecution.test.ts +0 -123
- package/client/agentRunLocalExecution.ts +0 -124
- package/client/agentRunLocalExecutor.ts +0 -179
- package/client/agentRunRuntimeSelection.test.ts +0 -159
- package/client/agentRunRuntimeSelection.ts +0 -145
- package/client/agentRunServerTransport.ts +0 -397
- package/client/agentRunTaskRunRecorder.ts +0 -176
- package/connector-experimental/daemonLauncher.ts +0 -223
- package/create/space/spaceKeys.ts +0 -65
- package/create/types.ts +0 -21
- package/customCodingAgentFlow.ts +0 -208
- package/customCodingAgentRecord.ts +0 -179
- package/database/keys.ts +0 -765
- package/database/server/authorityStoreTypes.ts +0 -31
- package/database/server/legacyServerDb.ts +0 -58
- package/database/server/levelAuthorityStore.ts +0 -75
- package/database/server/memoryAuthorityStore.ts +0 -133
- package/database/server/serverStoreFactory.ts +0 -124
- package/database/tombstones.ts +0 -52
- package/database/utils/ulid.ts +0 -1
- package/dialogDataAccess.ts +0 -186
- package/dialogInternalCommandEntries.ts +0 -11
- package/dialogReadCommands.ts +0 -180
- package/dialogReadHelpers.ts +0 -226
- package/dialogStatusCommands.ts +0 -123
- package/docInternalCommandEntries.ts +0 -20
- package/hybridReadHelpers.ts +0 -109
- package/machineCommandPrompts.ts +0 -79
- package/machineCommandResolution.ts +0 -43
- package/noloReadBridgePrompt.ts +0 -16
- package/pageCreateCommands.ts +0 -219
- package/pageDeleteCommands.ts +0 -167
- package/pageReadCommands.ts +0 -151
- package/pageUpdateCommands.ts +0 -249
- package/pageWriteHelpers.ts +0 -209
- package/publishPackage.ts +0 -36
- package/runtimeInternalCommandEntries.ts +0 -15
- package/runtimePassthroughCommands.ts +0 -22
- package/scriptPassthroughHelpers.ts +0 -28
- package/secretScanHelpers.ts +0 -31
- package/share/helpers.ts +0 -302
- package/share/keys.ts +0 -243
- package/share/types.ts +0 -100
- package/spaceAttachCommands.ts +0 -134
- package/spaceCategoryCommands.ts +0 -263
- package/spaceCommands.ts +0 -295
- package/spaceDeleteCommands.ts +0 -312
- package/spaceInternalCommandEntries.ts +0 -21
- package/spaceMutationHelpers.ts +0 -135
- package/spaceReadCommands.ts +0 -323
- package/tableDataOutput.ts +0 -41
- package/tableDataSafety.ts +0 -26
- package/tableMetaCommands.ts +0 -307
- package/tableMutationCommands.ts +0 -266
- package/tableQueryParsing.ts +0 -90
- package/tableQueryRequest.ts +0 -53
- package/taskRunActions.ts +0 -122
- package/taskRunParsing.ts +0 -86
- package/taskRunPromptShared.ts +0 -55
- package/tui/tuiCatalog.ts +0 -22
- package/tui/tuiCommandInterpreter.test.ts +0 -169
- package/tui/tuiCommandInterpreter.ts +0 -253
- package/tui/tuiPresentation.test.ts +0 -154
- 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
|
-
});
|