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.
- package/README.md +4 -10
- package/agent-runtime/agentRecordConfig.ts +10 -0
- package/agent-runtime/hostAdapter.ts +10 -1
- package/agent-runtime/index.ts +9 -20
- package/agent-runtime/localLoop.ts +49 -2
- package/agent-runtime/localToolPolicy.ts +76 -34
- package/agent-runtime/localWorkspaceTools.ts +30 -333
- package/agent-runtime/openAiCompatibleProvider.ts +7 -3
- package/agent-runtime/openAiCompatibleProviderConfig.ts +15 -26
- package/agent-runtime/platformChatProvider.ts +47 -73
- package/agent-runtime/providerResolution.ts +244 -0
- package/agent-runtime/runtimeToolPolicy.ts +77 -29
- package/agent-runtime/shellCommandPolicy.ts +120 -0
- package/agentAliases.ts +14 -83
- package/agentCommandSupport.ts +3 -6
- package/agentInternalCommandEntries.ts +4 -13
- package/agentListCommands.ts +18 -27
- package/agentMachineCommands.ts +40 -336
- package/agentPullCommand.ts +30 -55
- package/agentRecordCommands.ts +84 -1
- package/agentRecordHelpers.ts +102 -186
- package/agentRunCommand.ts +438 -107
- package/agentRuntimeLocal.ts +2 -9
- package/ai/agent/cliExecutor.ts +19 -323
- package/ai/tools/toolNameAliases.ts +70 -0
- package/authCommands.ts +2 -36
- package/cli/agentAliases.ts +14 -83
- package/cli/agentCommandSupport.ts +3 -6
- package/cli/agentInternalCommandEntries.ts +4 -13
- package/cli/agentListCommands.ts +18 -27
- package/cli/agentMachineCommands.ts +40 -336
- package/cli/agentPullCommand.ts +30 -55
- package/cli/agentRecordCommands.ts +84 -1
- package/cli/agentRecordHelpers.ts +102 -186
- package/cli/agentRunCommand.ts +438 -107
- package/cli/agentRuntimeLocal.ts +2 -9
- package/cli/authCommands.ts +2 -36
- package/cli/cliCommandDispatch.ts +2 -2
- package/cli/cliEnvHelpers.ts +34 -107
- package/cli/client/agentRun.ts +854 -57
- package/cli/client/localRuntimeAdapter.ts +59 -159
- package/cli/client/streamingOutput.ts +3 -1
- package/cli/client/taskRunPrompt.ts +24 -7
- package/cli/commandRegistry.ts +4 -5
- 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 +30 -44
- package/cli/machineWsSession.ts +0 -2
- package/cli/offlineMarxistsAgentCommand.ts +314 -0
- package/cli/runtimeDoctorCommands.ts +72 -15
- 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/cliCommandDispatch.ts +2 -2
- package/cliEnvHelpers.ts +34 -107
- package/client/agentConfigResolver.test.ts +2 -0
- package/client/agentRun.test.ts +12 -208
- package/client/agentRun.ts +854 -57
- package/client/localProviderResolver.test.ts +26 -2
- package/client/localRuntimeAdapter.test.ts +296 -171
- package/client/localRuntimeAdapter.ts +59 -159
- package/client/localToolPolicy.test.ts +4 -28
- package/client/streamingOutput.ts +3 -1
- package/client/taskRunPrompt.ts +24 -7
- package/commandRegistry.ts +4 -5
- package/connectorRunArtifact.ts +10 -34
- package/connectorWebSocketTarget.ts +6 -10
- package/database/server/serverStoreFactory.ts +2 -8
- 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 +30 -44
- package/machineWsSession.ts +0 -2
- package/offlineMarxistsAgentCommand.ts +314 -0
- package/package.json +52 -188
- package/runtimeDoctorCommands.ts +72 -15
- 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/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/pageDeleteCommands.ts
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { parseSkillDocProtocol, resolvePageSkillMetadata } from "./ai/skills/skillDocProtocol";
|
|
2
|
-
import { getReadableCliDb, type AgentCommandDeps } from "./agentCommandSupport";
|
|
3
|
-
import { deleteDbRecord, readDbRecord, writeDbRecord } from "./agentRecordHelpers";
|
|
4
|
-
import {
|
|
5
|
-
parseUserIdFromAuthToken,
|
|
6
|
-
resolveAuthToken,
|
|
7
|
-
resolveServerCandidates,
|
|
8
|
-
resolveServerUrl,
|
|
9
|
-
} from "./cliEnvHelpers";
|
|
10
|
-
import { readRecordWithCandidates } from "./hybridReadHelpers";
|
|
11
|
-
import { buildDetachedDocSpaceRecord, readOption } from "./pageWriteHelpers";
|
|
12
|
-
|
|
13
|
-
function usage(command: "doc" | "skill-doc") {
|
|
14
|
-
return [
|
|
15
|
-
"Usage:",
|
|
16
|
-
` nolo ${command} delete --key <pageKey>`,
|
|
17
|
-
"",
|
|
18
|
-
].join("\n");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async function readRecord(args: {
|
|
22
|
-
authToken: string;
|
|
23
|
-
db: Awaited<ReturnType<typeof getReadableCliDb>>;
|
|
24
|
-
dbKey: string;
|
|
25
|
-
fetchImpl: typeof fetch;
|
|
26
|
-
fallbackFetchImpl?: typeof fetch;
|
|
27
|
-
serverCandidates: string[];
|
|
28
|
-
}) {
|
|
29
|
-
return readRecordWithCandidates<Record<string, any>>({
|
|
30
|
-
db: args.db,
|
|
31
|
-
dbKey: args.dbKey,
|
|
32
|
-
serverCandidates: args.serverCandidates,
|
|
33
|
-
readRemote: async (serverUrl, dbKey) =>
|
|
34
|
-
readDbRecord({
|
|
35
|
-
authToken: args.authToken,
|
|
36
|
-
dbKey,
|
|
37
|
-
fallbackFetchImpl: args.fallbackFetchImpl,
|
|
38
|
-
fetchImpl: args.fetchImpl,
|
|
39
|
-
serverUrl,
|
|
40
|
-
}),
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export async function runBasePageDeleteCommand(
|
|
45
|
-
args: string[],
|
|
46
|
-
deps: AgentCommandDeps,
|
|
47
|
-
mode: "doc" | "skill-doc"
|
|
48
|
-
) {
|
|
49
|
-
const env = deps.env ?? process.env;
|
|
50
|
-
const output = deps.output ?? process.stdout;
|
|
51
|
-
const dbKey = readOption(args, "--key");
|
|
52
|
-
if (!dbKey || dbKey === "-h" || dbKey === "--help") {
|
|
53
|
-
output.write(`${usage(mode)}\n`);
|
|
54
|
-
return dbKey ? 0 : 1;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const authToken = resolveAuthToken(args, env);
|
|
58
|
-
const userId = parseUserIdFromAuthToken(authToken);
|
|
59
|
-
if (!authToken || !userId) {
|
|
60
|
-
output.write(`[nolo] ${mode} delete requires an auth token with userId. Run \`nolo login\`.\n`);
|
|
61
|
-
return 1;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const db = deps.db ?? await getReadableCliDb(output);
|
|
65
|
-
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
66
|
-
const fallbackFetchImpl = deps.fallbackFetchImpl;
|
|
67
|
-
const defaultServerUrl = resolveServerUrl(args, env);
|
|
68
|
-
const serverCandidates = resolveServerCandidates(args, env, defaultServerUrl);
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
const existing = await readRecord({
|
|
72
|
-
authToken,
|
|
73
|
-
db,
|
|
74
|
-
dbKey,
|
|
75
|
-
fetchImpl,
|
|
76
|
-
fallbackFetchImpl,
|
|
77
|
-
serverCandidates,
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
if (mode === "doc" && existing?.meta?.kind === "skill") {
|
|
81
|
-
throw new Error(`target page is a skill doc; use \`nolo skill-doc delete --key ${dbKey}\``);
|
|
82
|
-
}
|
|
83
|
-
if (mode === "skill-doc") {
|
|
84
|
-
const parsed = parseSkillDocProtocol(
|
|
85
|
-
typeof existing?.content === "string" ? existing.content : "",
|
|
86
|
-
existing?.meta,
|
|
87
|
-
existing?.tools
|
|
88
|
-
);
|
|
89
|
-
const metadata = resolvePageSkillMetadata({
|
|
90
|
-
...existing,
|
|
91
|
-
content: parsed.content,
|
|
92
|
-
});
|
|
93
|
-
if (!metadata?.skillConfig) {
|
|
94
|
-
throw new Error(`target page is not a skill doc: ${dbKey}`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const spaceId =
|
|
99
|
-
typeof existing?.spaceId === "string" && existing.spaceId.trim()
|
|
100
|
-
? existing.spaceId
|
|
101
|
-
: null;
|
|
102
|
-
const spaceKey = spaceId ? `space-${spaceId}` : null;
|
|
103
|
-
let pendingSpaceRecord: Record<string, any> | null = null;
|
|
104
|
-
|
|
105
|
-
if (spaceId && spaceKey) {
|
|
106
|
-
const existingSpaceRecord = await readRecord({
|
|
107
|
-
authToken,
|
|
108
|
-
db,
|
|
109
|
-
dbKey: spaceKey,
|
|
110
|
-
fetchImpl,
|
|
111
|
-
fallbackFetchImpl,
|
|
112
|
-
serverCandidates,
|
|
113
|
-
});
|
|
114
|
-
const spaceRecord = buildDetachedDocSpaceRecord({
|
|
115
|
-
contentKey: dbKey,
|
|
116
|
-
existingSpaceRecord,
|
|
117
|
-
spaceId,
|
|
118
|
-
});
|
|
119
|
-
pendingSpaceRecord = spaceRecord;
|
|
120
|
-
await writeDbRecord({
|
|
121
|
-
authToken,
|
|
122
|
-
dbKey: spaceKey,
|
|
123
|
-
fallbackFetchImpl,
|
|
124
|
-
fetchImpl,
|
|
125
|
-
record: spaceRecord,
|
|
126
|
-
serverUrl: defaultServerUrl,
|
|
127
|
-
userId,
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const deleteStatus = await deleteDbRecord({
|
|
132
|
-
authToken,
|
|
133
|
-
dbKey,
|
|
134
|
-
fallbackFetchImpl,
|
|
135
|
-
fetchImpl,
|
|
136
|
-
serverUrl: defaultServerUrl,
|
|
137
|
-
userId,
|
|
138
|
-
});
|
|
139
|
-
if (spaceKey && pendingSpaceRecord) {
|
|
140
|
-
await db.put(spaceKey, pendingSpaceRecord);
|
|
141
|
-
}
|
|
142
|
-
await db.batch([{ type: "del", key: dbKey }]);
|
|
143
|
-
output.write(`${JSON.stringify({ ok: true, dbKey, status: deleteStatus, spaceKey }, null, 2)}\n`);
|
|
144
|
-
return 0;
|
|
145
|
-
} catch (error) {
|
|
146
|
-
output.write(
|
|
147
|
-
`[nolo] ${mode} delete failed: ${
|
|
148
|
-
error instanceof Error ? error.message : String(error)
|
|
149
|
-
}\n`
|
|
150
|
-
);
|
|
151
|
-
return 1;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export async function runDocDeleteCommand(
|
|
156
|
-
args: string[],
|
|
157
|
-
deps: AgentCommandDeps = {}
|
|
158
|
-
) {
|
|
159
|
-
return runBasePageDeleteCommand(args, deps, "doc");
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export async function runSkillDocDeleteCommand(
|
|
163
|
-
args: string[],
|
|
164
|
-
deps: AgentCommandDeps = {}
|
|
165
|
-
) {
|
|
166
|
-
return runBasePageDeleteCommand(args, deps, "skill-doc");
|
|
167
|
-
}
|
package/pageReadCommands.ts
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { parseSkillDocProtocol, resolvePageSkillMetadata } from "./ai/skills/skillDocProtocol";
|
|
2
|
-
import { getReadableCliDb, type AgentCommandDeps } from "./agentCommandSupport";
|
|
3
|
-
import { readDbRecord } from "./agentRecordHelpers";
|
|
4
|
-
import {
|
|
5
|
-
resolveAuthToken,
|
|
6
|
-
resolveServerCandidates,
|
|
7
|
-
resolveServerUrl,
|
|
8
|
-
} from "./cliEnvHelpers";
|
|
9
|
-
import { readRecordWithCandidates } from "./hybridReadHelpers";
|
|
10
|
-
|
|
11
|
-
type PageReadResult = {
|
|
12
|
-
baseUrl: string;
|
|
13
|
-
dbKey: string;
|
|
14
|
-
title: string | null;
|
|
15
|
-
spaceId: string | null;
|
|
16
|
-
type: string | null;
|
|
17
|
-
content: string | null;
|
|
18
|
-
meta: Record<string, any> | null;
|
|
19
|
-
record: Record<string, any>;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
function usage(command: "doc" | "skill-doc") {
|
|
23
|
-
return [
|
|
24
|
-
"Usage:",
|
|
25
|
-
` nolo ${command} read <pageKey>`,
|
|
26
|
-
"",
|
|
27
|
-
].join("\n");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async function readPageRecord(args: {
|
|
31
|
-
db: Awaited<ReturnType<typeof getReadableCliDb>>;
|
|
32
|
-
authToken: string;
|
|
33
|
-
dbKey: string;
|
|
34
|
-
fetchImpl: typeof fetch;
|
|
35
|
-
fallbackFetchImpl?: typeof fetch;
|
|
36
|
-
serverCandidates: string[];
|
|
37
|
-
}) {
|
|
38
|
-
return await readRecordWithCandidates<Record<string, any>>({
|
|
39
|
-
db: args.db,
|
|
40
|
-
dbKey: args.dbKey,
|
|
41
|
-
serverCandidates: args.serverCandidates,
|
|
42
|
-
readRemote: async (serverUrl, dbKey) =>
|
|
43
|
-
readDbRecord({
|
|
44
|
-
authToken: args.authToken,
|
|
45
|
-
dbKey,
|
|
46
|
-
fallbackFetchImpl: args.fallbackFetchImpl,
|
|
47
|
-
fetchImpl: args.fetchImpl,
|
|
48
|
-
serverUrl,
|
|
49
|
-
}),
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function buildPageReadResult(baseUrl: string, dbKey: string, record: Record<string, any>): PageReadResult {
|
|
54
|
-
return {
|
|
55
|
-
baseUrl,
|
|
56
|
-
dbKey,
|
|
57
|
-
title: record?.title ?? null,
|
|
58
|
-
spaceId: record?.spaceId ?? null,
|
|
59
|
-
type: record?.type ?? null,
|
|
60
|
-
content: typeof record?.content === "string" ? record.content : null,
|
|
61
|
-
meta: record?.meta && typeof record.meta === "object" ? record.meta : null,
|
|
62
|
-
record,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async function runBasePageReadCommand(
|
|
67
|
-
args: string[],
|
|
68
|
-
deps: AgentCommandDeps,
|
|
69
|
-
mode: "doc" | "skill-doc"
|
|
70
|
-
) {
|
|
71
|
-
const env = deps.env ?? process.env;
|
|
72
|
-
const output = deps.output ?? process.stdout;
|
|
73
|
-
const raw = args[0]?.trim();
|
|
74
|
-
if (!raw || raw === "-h" || raw === "--help") {
|
|
75
|
-
output.write(`${usage(mode)}\n`);
|
|
76
|
-
return raw ? 0 : 1;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const authToken = resolveAuthToken(args, env);
|
|
80
|
-
if (!authToken) {
|
|
81
|
-
output.write(`[nolo] ${mode} read requires an auth token. Run \`nolo login\` or set AUTH_TOKEN.\n`);
|
|
82
|
-
return 1;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const db = deps.db ?? await getReadableCliDb(output);
|
|
86
|
-
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
87
|
-
const fallbackFetchImpl = deps.fallbackFetchImpl;
|
|
88
|
-
const defaultServerUrl = resolveServerUrl(args, env);
|
|
89
|
-
const serverCandidates = resolveServerCandidates(args, env, defaultServerUrl);
|
|
90
|
-
|
|
91
|
-
try {
|
|
92
|
-
const record = await readPageRecord({
|
|
93
|
-
db,
|
|
94
|
-
authToken,
|
|
95
|
-
dbKey: raw,
|
|
96
|
-
fetchImpl,
|
|
97
|
-
fallbackFetchImpl,
|
|
98
|
-
serverCandidates,
|
|
99
|
-
});
|
|
100
|
-
const result = buildPageReadResult(defaultServerUrl, raw, record);
|
|
101
|
-
|
|
102
|
-
if (mode === "doc") {
|
|
103
|
-
output.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
104
|
-
return 0;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const parsed = parseSkillDocProtocol(
|
|
108
|
-
typeof record?.content === "string" ? record.content : "",
|
|
109
|
-
record?.meta,
|
|
110
|
-
record?.tools
|
|
111
|
-
);
|
|
112
|
-
const meta = resolvePageSkillMetadata(record);
|
|
113
|
-
const skillConfig = meta?.skillConfig ?? null;
|
|
114
|
-
|
|
115
|
-
output.write(
|
|
116
|
-
`${JSON.stringify(
|
|
117
|
-
{
|
|
118
|
-
...result,
|
|
119
|
-
isSkill: Boolean(meta?.kind === "skill" || skillConfig),
|
|
120
|
-
body: typeof parsed.content === "string" ? parsed.content : "",
|
|
121
|
-
meta: meta ?? result.meta,
|
|
122
|
-
skillConfig,
|
|
123
|
-
},
|
|
124
|
-
null,
|
|
125
|
-
2
|
|
126
|
-
)}\n`
|
|
127
|
-
);
|
|
128
|
-
return 0;
|
|
129
|
-
} catch (error) {
|
|
130
|
-
output.write(
|
|
131
|
-
`[nolo] ${mode} read failed: ${
|
|
132
|
-
error instanceof Error ? error.message : String(error)
|
|
133
|
-
}\n`
|
|
134
|
-
);
|
|
135
|
-
return 1;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export async function runDocReadCommand(
|
|
140
|
-
args: string[],
|
|
141
|
-
deps: AgentCommandDeps = {}
|
|
142
|
-
) {
|
|
143
|
-
return runBasePageReadCommand(args, deps, "doc");
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export async function runSkillDocReadCommand(
|
|
147
|
-
args: string[],
|
|
148
|
-
deps: AgentCommandDeps = {}
|
|
149
|
-
) {
|
|
150
|
-
return runBasePageReadCommand(args, deps, "skill-doc");
|
|
151
|
-
}
|
package/pageUpdateCommands.ts
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import { parseSkillDocProtocol, resolvePageSkillMetadata, type SkillDocConfig } from "./ai/skills/skillDocProtocol";
|
|
2
|
-
import { getReadableCliDb, type AgentCommandDeps } from "./agentCommandSupport";
|
|
3
|
-
import { readDbRecord } from "./agentRecordHelpers";
|
|
4
|
-
import {
|
|
5
|
-
parseUserIdFromAuthToken,
|
|
6
|
-
resolveAuthToken,
|
|
7
|
-
resolveServerCandidates,
|
|
8
|
-
resolveServerUrl,
|
|
9
|
-
} from "./cliEnvHelpers";
|
|
10
|
-
import { readRecordWithCandidates } from "./hybridReadHelpers";
|
|
11
|
-
import {
|
|
12
|
-
buildDocSpaceRecord,
|
|
13
|
-
buildPageRecord,
|
|
14
|
-
buildSkillPageRecord,
|
|
15
|
-
buildSkillSummaryFromRecord,
|
|
16
|
-
parseJsonOption,
|
|
17
|
-
readBodyOption,
|
|
18
|
-
readOption,
|
|
19
|
-
writeRemoteRecordsThenCache,
|
|
20
|
-
} from "./pageWriteHelpers";
|
|
21
|
-
|
|
22
|
-
function usage(command: "doc" | "skill-doc") {
|
|
23
|
-
return [
|
|
24
|
-
"Usage:",
|
|
25
|
-
` nolo ${command} update --key <pageKey> [options]`,
|
|
26
|
-
"",
|
|
27
|
-
].join("\n");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async function readRecord(args: {
|
|
31
|
-
authToken: string;
|
|
32
|
-
db: Awaited<ReturnType<typeof getReadableCliDb>>;
|
|
33
|
-
dbKey: string;
|
|
34
|
-
fetchImpl: typeof fetch;
|
|
35
|
-
fallbackFetchImpl?: typeof fetch;
|
|
36
|
-
serverCandidates: string[];
|
|
37
|
-
}) {
|
|
38
|
-
return readRecordWithCandidates<Record<string, any>>({
|
|
39
|
-
db: args.db,
|
|
40
|
-
dbKey: args.dbKey,
|
|
41
|
-
serverCandidates: args.serverCandidates,
|
|
42
|
-
readRemote: async (serverUrl, dbKey) =>
|
|
43
|
-
readDbRecord({
|
|
44
|
-
authToken: args.authToken,
|
|
45
|
-
dbKey,
|
|
46
|
-
fallbackFetchImpl: args.fallbackFetchImpl,
|
|
47
|
-
fetchImpl: args.fetchImpl,
|
|
48
|
-
serverUrl,
|
|
49
|
-
}),
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async function runBasePageUpdateCommand(
|
|
54
|
-
args: string[],
|
|
55
|
-
deps: AgentCommandDeps,
|
|
56
|
-
mode: "doc" | "skill-doc"
|
|
57
|
-
) {
|
|
58
|
-
const env = deps.env ?? process.env;
|
|
59
|
-
const output = deps.output ?? process.stdout;
|
|
60
|
-
const dbKey = readOption(args, "--key");
|
|
61
|
-
if (!dbKey || dbKey === "-h" || dbKey === "--help") {
|
|
62
|
-
output.write(`${usage(mode)}\n`);
|
|
63
|
-
return dbKey ? 0 : 1;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const authToken = resolveAuthToken(args, env);
|
|
67
|
-
const userId = parseUserIdFromAuthToken(authToken);
|
|
68
|
-
if (!authToken || !userId) {
|
|
69
|
-
output.write(`[nolo] ${mode} update requires an auth token with userId. Run \`nolo login\`.\n`);
|
|
70
|
-
return 1;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const db = deps.db ?? await getReadableCliDb(output);
|
|
74
|
-
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
75
|
-
const fallbackFetchImpl = deps.fallbackFetchImpl;
|
|
76
|
-
const defaultServerUrl = resolveServerUrl(args, env);
|
|
77
|
-
const serverCandidates = resolveServerCandidates(args, env, defaultServerUrl);
|
|
78
|
-
const writeTargets = [defaultServerUrl];
|
|
79
|
-
|
|
80
|
-
try {
|
|
81
|
-
const existing = await readRecord({
|
|
82
|
-
authToken,
|
|
83
|
-
db,
|
|
84
|
-
dbKey,
|
|
85
|
-
fetchImpl,
|
|
86
|
-
fallbackFetchImpl,
|
|
87
|
-
serverCandidates,
|
|
88
|
-
});
|
|
89
|
-
const spaceId = readOption(args, "--space") ?? (typeof existing?.spaceId === "string" ? existing.spaceId : null);
|
|
90
|
-
if (!spaceId) {
|
|
91
|
-
throw new Error(`unable to resolve space for ${dbKey}`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const spaceKey = `space-${spaceId}`;
|
|
95
|
-
const existingSpaceRecord = await readRecord({
|
|
96
|
-
authToken,
|
|
97
|
-
db,
|
|
98
|
-
dbKey: spaceKey,
|
|
99
|
-
fetchImpl,
|
|
100
|
-
fallbackFetchImpl,
|
|
101
|
-
serverCandidates,
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
if (mode === "doc") {
|
|
105
|
-
if (existing?.meta?.kind === "skill") {
|
|
106
|
-
throw new Error(`target page is a skill doc; use \`nolo skill-doc update --key ${dbKey}\``);
|
|
107
|
-
}
|
|
108
|
-
const title = readOption(args, "--title") ?? existing?.title;
|
|
109
|
-
if (!title) {
|
|
110
|
-
throw new Error(`missing title for ${dbKey}`);
|
|
111
|
-
}
|
|
112
|
-
const content = readBodyOption(args, typeof existing?.content === "string" ? existing.content : "");
|
|
113
|
-
const pageId =
|
|
114
|
-
typeof existing?.id === "string" && existing.id.trim()
|
|
115
|
-
? existing.id
|
|
116
|
-
: dbKey.split("-").slice(-1)[0];
|
|
117
|
-
const pageRecord = buildPageRecord({
|
|
118
|
-
content,
|
|
119
|
-
dbKey,
|
|
120
|
-
existing,
|
|
121
|
-
meta: existing?.meta ?? undefined,
|
|
122
|
-
pageId,
|
|
123
|
-
spaceId,
|
|
124
|
-
title,
|
|
125
|
-
});
|
|
126
|
-
const spaceRecord = buildDocSpaceRecord({
|
|
127
|
-
contentKey: dbKey,
|
|
128
|
-
existingSpaceRecord,
|
|
129
|
-
spaceId,
|
|
130
|
-
title,
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
await writeRemoteRecordsThenCache({
|
|
134
|
-
authToken,
|
|
135
|
-
db,
|
|
136
|
-
fetchImpl,
|
|
137
|
-
fallbackFetchImpl,
|
|
138
|
-
records: [
|
|
139
|
-
...writeTargets.map((serverUrl) => ({ dbKey, record: pageRecord, serverUrl })),
|
|
140
|
-
...writeTargets.map((serverUrl) => ({ dbKey: spaceKey, record: spaceRecord, serverUrl })),
|
|
141
|
-
],
|
|
142
|
-
userId,
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
output.write(`${JSON.stringify({ ok: true, dbKey, spaceKey, baseUrl: defaultServerUrl }, null, 2)}\n`);
|
|
146
|
-
return 0;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const parsed = parseSkillDocProtocol(
|
|
150
|
-
typeof existing?.content === "string" ? existing.content : "",
|
|
151
|
-
existing?.meta,
|
|
152
|
-
existing?.tools
|
|
153
|
-
);
|
|
154
|
-
const metadata = resolvePageSkillMetadata(existing);
|
|
155
|
-
const currentConfig = metadata?.skillConfig;
|
|
156
|
-
if (!currentConfig) {
|
|
157
|
-
throw new Error(`target page is not a skill doc: ${dbKey}`);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const title = readOption(args, "--title") ?? existing?.title ?? currentConfig.name;
|
|
161
|
-
const description = readOption(args, "--description") ?? currentConfig.description;
|
|
162
|
-
if (!title || !description) {
|
|
163
|
-
throw new Error(`skill doc requires title and description: ${dbKey}`);
|
|
164
|
-
}
|
|
165
|
-
const mergedSkillConfig: SkillDocConfig = {
|
|
166
|
-
...currentConfig,
|
|
167
|
-
name: title,
|
|
168
|
-
description,
|
|
169
|
-
...(readOption(args, "--tools") !== undefined
|
|
170
|
-
? { toolNames: parseJsonOption<string[]>(readOption(args, "--tools"), []) }
|
|
171
|
-
: {}),
|
|
172
|
-
...(readOption(args, "--required-skills") !== undefined
|
|
173
|
-
? { requiredSkills: parseJsonOption<string[]>(readOption(args, "--required-skills"), []) }
|
|
174
|
-
: {}),
|
|
175
|
-
...(readOption(args, "--recommended-skills") !== undefined
|
|
176
|
-
? { recommendedSkills: parseJsonOption<string[]>(readOption(args, "--recommended-skills"), []) }
|
|
177
|
-
: {}),
|
|
178
|
-
...(readOption(args, "--preferred-agents") !== undefined
|
|
179
|
-
? { preferredAgents: parseJsonOption<string[]>(readOption(args, "--preferred-agents"), []) }
|
|
180
|
-
: {}),
|
|
181
|
-
...(readOption(args, "--trigger-mode") !== undefined
|
|
182
|
-
? { triggerMode: readOption(args, "--trigger-mode") as SkillDocConfig["triggerMode"] }
|
|
183
|
-
: {}),
|
|
184
|
-
...(readOption(args, "--budget-tier") !== undefined
|
|
185
|
-
? { budgetTier: readOption(args, "--budget-tier") as SkillDocConfig["budgetTier"] }
|
|
186
|
-
: {}),
|
|
187
|
-
...(readOption(args, "--prompt-patch") !== undefined
|
|
188
|
-
? { promptPatch: readOption(args, "--prompt-patch") || undefined }
|
|
189
|
-
: {}),
|
|
190
|
-
};
|
|
191
|
-
const body = readBodyOption(args, parsed.content ?? "");
|
|
192
|
-
const skillId =
|
|
193
|
-
typeof existing?.id === "string" && existing.id.trim()
|
|
194
|
-
? existing.id
|
|
195
|
-
: dbKey.split("-").slice(-1)[0];
|
|
196
|
-
const pageRecord = buildSkillPageRecord({
|
|
197
|
-
body,
|
|
198
|
-
dbKey,
|
|
199
|
-
existing,
|
|
200
|
-
skillConfig: mergedSkillConfig,
|
|
201
|
-
skillId,
|
|
202
|
-
spaceId,
|
|
203
|
-
title,
|
|
204
|
-
});
|
|
205
|
-
const spaceRecord = buildDocSpaceRecord({
|
|
206
|
-
contentKey: dbKey,
|
|
207
|
-
existingSpaceRecord,
|
|
208
|
-
skillSummary: buildSkillSummaryFromRecord(pageRecord),
|
|
209
|
-
spaceId,
|
|
210
|
-
title,
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
await writeRemoteRecordsThenCache({
|
|
214
|
-
authToken,
|
|
215
|
-
db,
|
|
216
|
-
fetchImpl,
|
|
217
|
-
fallbackFetchImpl,
|
|
218
|
-
records: [
|
|
219
|
-
...writeTargets.map((serverUrl) => ({ dbKey, record: pageRecord, serverUrl })),
|
|
220
|
-
...writeTargets.map((serverUrl) => ({ dbKey: spaceKey, record: spaceRecord, serverUrl })),
|
|
221
|
-
],
|
|
222
|
-
userId,
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
output.write(`${JSON.stringify({ ok: true, dbKey, spaceKey, baseUrl: defaultServerUrl }, null, 2)}\n`);
|
|
226
|
-
return 0;
|
|
227
|
-
} catch (error) {
|
|
228
|
-
output.write(
|
|
229
|
-
`[nolo] ${mode} update failed: ${
|
|
230
|
-
error instanceof Error ? error.message : String(error)
|
|
231
|
-
}\n`
|
|
232
|
-
);
|
|
233
|
-
return 1;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export async function runDocUpdateCommand(
|
|
238
|
-
args: string[],
|
|
239
|
-
deps: AgentCommandDeps = {}
|
|
240
|
-
) {
|
|
241
|
-
return runBasePageUpdateCommand(args, deps, "doc");
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
export async function runSkillDocUpdateCommand(
|
|
245
|
-
args: string[],
|
|
246
|
-
deps: AgentCommandDeps = {}
|
|
247
|
-
) {
|
|
248
|
-
return runBasePageUpdateCommand(args, deps, "skill-doc");
|
|
249
|
-
}
|