@kivacore/cli 0.13.1 → 0.13.2
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 +12 -7
- package/main.js +115 -15
- package/main.js.map +4 -4
- package/package.json +1 -1
- package/resources/pi-agent/prompts/agent-system.md +15 -1
package/README.md
CHANGED
|
@@ -38,16 +38,20 @@ one-line notice on stderr. Set `KIVA_SKIP_UPDATE_CHECK=1` to skip the check.
|
|
|
38
38
|
|
|
39
39
|
## Start with a prompt
|
|
40
40
|
|
|
41
|
-
Type what you want straight after `kiva` and
|
|
42
|
-
|
|
41
|
+
Type what you want straight after `kiva` and an agent opens with it as the
|
|
42
|
+
first message, already sent:
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
|
-
kiva "summarize what changed in this repo this week"
|
|
45
|
+
kiva "summarize what changed in this repo this week" # Work Agent
|
|
46
|
+
kiva "create a purchasing management app for my company" # Coding Agent
|
|
46
47
|
```
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
Kiva picks the agent from the prompt: the Coding Agent when it asks to build or
|
|
50
|
+
change software, the Work Agent for everything else, and whenever you are
|
|
51
|
+
logged out or the choice cannot be made within a few seconds. To choose
|
|
52
|
+
yourself, name the agent: `kiva work "<prompt>"` or `kiva code "<prompt>"`.
|
|
53
|
+
The same options apply (`kiva --thinking high "..."`). The prompt must be
|
|
54
|
+
quoted: a single word is still read as a command.
|
|
51
55
|
|
|
52
56
|
## AI provider for `kiva work` and `kiva code`
|
|
53
57
|
|
|
@@ -335,7 +339,8 @@ kiva dsql query "<sql>" --json
|
|
|
335
339
|
kiva dsql generate "open tasks assigned to me" --json
|
|
336
340
|
kiva dsql ask "how many tasks are open?" --json
|
|
337
341
|
kiva dsql schema app base --json
|
|
338
|
-
kiva dsql schema data-source base task --json
|
|
342
|
+
kiva dsql schema data-source base task --json # lists each enum field's option ids and labels; --no-expand-enums omits them
|
|
343
|
+
kiva dsql schema app base --expand-enums --json
|
|
339
344
|
kiva dsql list-custom-query --appSlug base --json
|
|
340
345
|
kiva dsql create-custom-query --appSlug base --name "Open Tasks" --dsqlQuery "<sql>" --fields '<json>' --json
|
|
341
346
|
kiva dsql run-custom-query --queryId "<id>" --json
|
package/main.js
CHANGED
|
@@ -97698,7 +97698,7 @@ function resolveDisplayName(name3, aliases) {
|
|
|
97698
97698
|
// package.json
|
|
97699
97699
|
var package_default = {
|
|
97700
97700
|
name: "@kivacore/cli",
|
|
97701
|
-
version: "0.13.
|
|
97701
|
+
version: "0.13.2",
|
|
97702
97702
|
private: false,
|
|
97703
97703
|
description: "KIVA API CLI",
|
|
97704
97704
|
bin: {
|
|
@@ -100200,8 +100200,36 @@ var StudioResolver = class {
|
|
|
100200
100200
|
if (dataSourceId) {
|
|
100201
100201
|
return dataSourceId;
|
|
100202
100202
|
}
|
|
100203
|
-
|
|
100204
|
-
|
|
100203
|
+
try {
|
|
100204
|
+
const dataSources = await this.getDataSourcesForApp(options.appId);
|
|
100205
|
+
return resolveBySlug("Data source", dataSources, dataSourceSlug);
|
|
100206
|
+
} catch (error62) {
|
|
100207
|
+
const systemAppSlug = lookupSystemAppSlugById(options.appId);
|
|
100208
|
+
if (!systemAppSlug || !(error62 instanceof ApiResponseError) || error62.httpStatusCode !== 404) {
|
|
100209
|
+
throw error62;
|
|
100210
|
+
}
|
|
100211
|
+
return await this.#resolveSystemDataSourceId({ appSlug: systemAppSlug, dataSourceSlug });
|
|
100212
|
+
}
|
|
100213
|
+
}
|
|
100214
|
+
async #resolveSystemDataSourceId(params) {
|
|
100215
|
+
const notFound = new UserInputError(`Data source slug '${params.dataSourceSlug}' was not found in app '${params.appSlug}'.`);
|
|
100216
|
+
try {
|
|
100217
|
+
const response = await this.apiClient.request({
|
|
100218
|
+
method: "GET",
|
|
100219
|
+
path: `/dsql/schema/apps/${encodeURIComponent(params.appSlug)}/data-sources/${encodeURIComponent(params.dataSourceSlug)}`
|
|
100220
|
+
});
|
|
100221
|
+
const payload = isRecord3(response.data) && isRecord3(response.data.data) ? response.data.data : response.data;
|
|
100222
|
+
const id = isRecord3(payload) ? extractString(payload, "id") : void 0;
|
|
100223
|
+
if (!id) {
|
|
100224
|
+
throw notFound;
|
|
100225
|
+
}
|
|
100226
|
+
return id;
|
|
100227
|
+
} catch (error62) {
|
|
100228
|
+
if (error62 instanceof ApiResponseError && error62.httpStatusCode === 404) {
|
|
100229
|
+
throw notFound;
|
|
100230
|
+
}
|
|
100231
|
+
throw error62;
|
|
100232
|
+
}
|
|
100205
100233
|
}
|
|
100206
100234
|
async resolveAppSlug(options) {
|
|
100207
100235
|
const appId = normalizeOptional(options.appId);
|
|
@@ -106135,6 +106163,10 @@ async function generateDsqlQuery(params) {
|
|
|
106135
106163
|
});
|
|
106136
106164
|
return extractGeneratedDsql(result);
|
|
106137
106165
|
}
|
|
106166
|
+
var EXPAND_ENUMS_DESCRIPTION = "List each enum field's option ids and labels under its column.";
|
|
106167
|
+
function expandEnumsQuery(expandEnums) {
|
|
106168
|
+
return expandEnums ? { expandEnums: "true" } : {};
|
|
106169
|
+
}
|
|
106138
106170
|
function createDsqlCli(dependencies) {
|
|
106139
106171
|
const dsqlCli = Cli_exports.create("dsql", {
|
|
106140
106172
|
description: "Logical SQL query and schema discovery commands",
|
|
@@ -106176,12 +106208,16 @@ function createDsqlCli(dependencies) {
|
|
|
106176
106208
|
args: external_exports.object({
|
|
106177
106209
|
appSlug: external_exports.string().min(1)
|
|
106178
106210
|
}),
|
|
106211
|
+
options: external_exports.object({
|
|
106212
|
+
expandEnums: external_exports.boolean().default(false).describe(EXPAND_ENUMS_DESCRIPTION)
|
|
106213
|
+
}),
|
|
106179
106214
|
run: async (context) => {
|
|
106180
106215
|
const apiBaseUrl = await dependencies.environmentConfigService.getActiveApiBaseUrl();
|
|
106181
106216
|
const apiClient = dependencies.createApiClient(apiBaseUrl);
|
|
106182
106217
|
const response = await apiClient.request({
|
|
106183
106218
|
method: "GET",
|
|
106184
|
-
path: `/dsql/schema/apps/${context.args.appSlug}
|
|
106219
|
+
path: `/dsql/schema/apps/${context.args.appSlug}`,
|
|
106220
|
+
query: expandEnumsQuery(context.options.expandEnums)
|
|
106185
106221
|
});
|
|
106186
106222
|
return await injectContext({
|
|
106187
106223
|
apiBaseUrl,
|
|
@@ -106196,12 +106232,18 @@ function createDsqlCli(dependencies) {
|
|
|
106196
106232
|
appSlug: external_exports.string().min(1),
|
|
106197
106233
|
dataSourceSlug: external_exports.string().min(1)
|
|
106198
106234
|
}),
|
|
106235
|
+
options: external_exports.object({
|
|
106236
|
+
// On by default: a single table is small, and its enum labels are what a
|
|
106237
|
+
// filter such as "open tasks" has to be written against.
|
|
106238
|
+
expandEnums: external_exports.boolean().default(true).describe(`${EXPAND_ENUMS_DESCRIPTION} On by default; pass --no-expand-enums to omit`)
|
|
106239
|
+
}),
|
|
106199
106240
|
run: async (context) => {
|
|
106200
106241
|
const apiBaseUrl = await dependencies.environmentConfigService.getActiveApiBaseUrl();
|
|
106201
106242
|
const apiClient = dependencies.createApiClient(apiBaseUrl);
|
|
106202
106243
|
const response = await apiClient.request({
|
|
106203
106244
|
method: "GET",
|
|
106204
|
-
path: `/dsql/schema/apps/${context.args.appSlug}/data-sources/${context.args.dataSourceSlug}
|
|
106245
|
+
path: `/dsql/schema/apps/${context.args.appSlug}/data-sources/${context.args.dataSourceSlug}`,
|
|
106246
|
+
query: expandEnumsQuery(context.options.expandEnums)
|
|
106205
106247
|
});
|
|
106206
106248
|
return await injectContext({
|
|
106207
106249
|
apiBaseUrl,
|
|
@@ -106213,7 +106255,8 @@ function createDsqlCli(dependencies) {
|
|
|
106213
106255
|
schemaCli.command("data-sources", {
|
|
106214
106256
|
description: "Get the DSQL schema for data sources matching the given ids",
|
|
106215
106257
|
options: external_exports.object({
|
|
106216
|
-
ids: external_exports.string().optional().describe("Comma-separated data source ids")
|
|
106258
|
+
ids: external_exports.string().optional().describe("Comma-separated data source ids"),
|
|
106259
|
+
expandEnums: external_exports.boolean().default(false).describe(EXPAND_ENUMS_DESCRIPTION)
|
|
106217
106260
|
}),
|
|
106218
106261
|
run: async (context) => {
|
|
106219
106262
|
const apiBaseUrl = await dependencies.environmentConfigService.getActiveApiBaseUrl();
|
|
@@ -106226,7 +106269,8 @@ function createDsqlCli(dependencies) {
|
|
|
106226
106269
|
method: "GET",
|
|
106227
106270
|
path: "/dsql/schema/data-sources",
|
|
106228
106271
|
query: {
|
|
106229
|
-
ids: ids.join(",")
|
|
106272
|
+
ids: ids.join(","),
|
|
106273
|
+
...expandEnumsQuery(context.options.expandEnums)
|
|
106230
106274
|
}
|
|
106231
106275
|
});
|
|
106232
106276
|
return await injectContext({
|
|
@@ -120676,15 +120720,16 @@ var AuthStore = class _AuthStore {
|
|
|
120676
120720
|
};
|
|
120677
120721
|
|
|
120678
120722
|
// src/services/barePrompt.ts
|
|
120723
|
+
var BARE_PROMPT_AGENT_COMMANDS = ["work", "code"];
|
|
120679
120724
|
var BARE_PROMPT_COMMAND = "work";
|
|
120680
120725
|
var SENTENCE_RE = /\S\s+\S/u;
|
|
120681
|
-
function
|
|
120726
|
+
function findBarePrompt(argv) {
|
|
120682
120727
|
for (const [index3, token] of argv.entries()) {
|
|
120683
120728
|
if (token.startsWith("-")) {
|
|
120684
120729
|
continue;
|
|
120685
120730
|
}
|
|
120686
120731
|
if (SENTENCE_RE.test(token)) {
|
|
120687
|
-
return
|
|
120732
|
+
return token;
|
|
120688
120733
|
}
|
|
120689
120734
|
const previous2 = argv[index3 - 1];
|
|
120690
120735
|
if (previous2?.startsWith("-") && !previous2.includes("=")) {
|
|
@@ -120692,7 +120737,46 @@ function rewriteBarePromptArgv(argv) {
|
|
|
120692
120737
|
}
|
|
120693
120738
|
break;
|
|
120694
120739
|
}
|
|
120695
|
-
return
|
|
120740
|
+
return void 0;
|
|
120741
|
+
}
|
|
120742
|
+
function rewriteBarePromptArgv(argv, command2 = BARE_PROMPT_COMMAND) {
|
|
120743
|
+
return findBarePrompt(argv) === void 0 ? [...argv] : [command2, ...argv];
|
|
120744
|
+
}
|
|
120745
|
+
|
|
120746
|
+
// src/services/barePromptAgent.ts
|
|
120747
|
+
var BARE_PROMPT_DECISION_PATH = "/ai/decideCliAgent";
|
|
120748
|
+
var DECISION_TIMEOUT_MS = 3e3;
|
|
120749
|
+
function isAgentCommand(value2) {
|
|
120750
|
+
return BARE_PROMPT_AGENT_COMMANDS.includes(value2);
|
|
120751
|
+
}
|
|
120752
|
+
async function decideBarePromptAgent(params) {
|
|
120753
|
+
if (isHostedSandbox(params.env)) {
|
|
120754
|
+
return BARE_PROMPT_COMMAND;
|
|
120755
|
+
}
|
|
120756
|
+
let timer;
|
|
120757
|
+
try {
|
|
120758
|
+
const apiBaseUrl = normalizeApiBaseUrl(await params.environmentConfigService.getActiveApiBaseUrl());
|
|
120759
|
+
if (!await params.authStore.getActiveProfile(apiBaseUrl)) {
|
|
120760
|
+
return BARE_PROMPT_COMMAND;
|
|
120761
|
+
}
|
|
120762
|
+
const apiClient = params.createApiClient?.(apiBaseUrl) ?? new ApiClient({ apiBaseUrl, authSessionService: new AuthSessionService({ apiBaseUrl, authStore: params.authStore }) });
|
|
120763
|
+
const decision = requestApiData({
|
|
120764
|
+
apiClient,
|
|
120765
|
+
request: { method: "POST", path: BARE_PROMPT_DECISION_PATH, body: { prompt: params.prompt } }
|
|
120766
|
+
}).then((payload) => {
|
|
120767
|
+
const agent = payload?.agent ?? payload?.data?.agent;
|
|
120768
|
+
return isAgentCommand(agent) ? agent : BARE_PROMPT_COMMAND;
|
|
120769
|
+
});
|
|
120770
|
+
decision.catch(() => void 0);
|
|
120771
|
+
const deadline = new Promise((resolve9) => {
|
|
120772
|
+
timer = setTimeout(() => resolve9(BARE_PROMPT_COMMAND), params.timeoutMs ?? DECISION_TIMEOUT_MS);
|
|
120773
|
+
});
|
|
120774
|
+
return await Promise.race([decision, deadline]);
|
|
120775
|
+
} catch {
|
|
120776
|
+
return BARE_PROMPT_COMMAND;
|
|
120777
|
+
} finally {
|
|
120778
|
+
clearTimeout(timer);
|
|
120779
|
+
}
|
|
120696
120780
|
}
|
|
120697
120781
|
|
|
120698
120782
|
// src/services/environmentConfig.ts
|
|
@@ -122473,7 +122557,7 @@ var ROOT_HELP_COMMANDS = [
|
|
|
122473
122557
|
{ command: "auth set-tokens --accessToken <token>", description: "Save custom access and refresh tokens" },
|
|
122474
122558
|
{ command: "auth accounts list", description: "List saved user accounts" },
|
|
122475
122559
|
{ command: "auth tenants use <uuid|tenantNo>", description: "Switch active tenant for selected user" },
|
|
122476
|
-
{ command: '"<prompt>"', description:
|
|
122560
|
+
{ command: '"<prompt>"', description: "Start an agent with a prompt: the Coding Agent for software requests, the Work Agent otherwise" },
|
|
122477
122561
|
{ command: "work [prompt]", description: "Launch the Kiva Work Agent" },
|
|
122478
122562
|
{ command: "code [prompt]", description: "Launch the Kiva Coding Agent" },
|
|
122479
122563
|
{ command: "server", description: "Start HTTP server bridging pi agent to AI SDK useChat" },
|
|
@@ -122772,15 +122856,31 @@ function createKivaCli(params) {
|
|
|
122772
122856
|
}
|
|
122773
122857
|
migrateLegacyBrandDirectories();
|
|
122774
122858
|
var extractedArgs = extractGlobalFlagFromArgv(process.argv.slice(2));
|
|
122775
|
-
var runtimeArgs = { ...extractedArgs, argv: rewriteBarePromptArgv(extractedArgs.argv) };
|
|
122776
122859
|
var cli = createKivaCli({
|
|
122777
|
-
forceGlobalSettings:
|
|
122860
|
+
forceGlobalSettings: extractedArgs.forceGlobal
|
|
122778
122861
|
});
|
|
122862
|
+
async function resolveRuntimeArgv() {
|
|
122863
|
+
const prompt = findBarePrompt(extractedArgs.argv);
|
|
122864
|
+
if (prompt === void 0) {
|
|
122865
|
+
return [...extractedArgs.argv];
|
|
122866
|
+
}
|
|
122867
|
+
const settingsPaths = resolveKivaSettingsPaths({ forceGlobal: extractedArgs.forceGlobal });
|
|
122868
|
+
const agent = await decideBarePromptAgent({
|
|
122869
|
+
prompt,
|
|
122870
|
+
authStore: new AuthStore(settingsPaths.authFilePath),
|
|
122871
|
+
environmentConfigService: new EnvironmentConfigService(settingsPaths.configFilePath)
|
|
122872
|
+
});
|
|
122873
|
+
if (agent === "code") {
|
|
122874
|
+
process.stderr.write('Starting the Kiva Coding Agent for this request. To choose yourself: kiva work "<prompt>"\n');
|
|
122875
|
+
}
|
|
122876
|
+
return rewriteBarePromptArgv(extractedArgs.argv, agent);
|
|
122877
|
+
}
|
|
122779
122878
|
void runWithIncurSkillsOutOfDateWarningSuppressed({
|
|
122780
122879
|
run: async () => {
|
|
122880
|
+
const argv = await resolveRuntimeArgv();
|
|
122781
122881
|
const gate = await enforceLatestCliVersion({
|
|
122782
122882
|
currentVersion: package_default.version,
|
|
122783
|
-
argv
|
|
122883
|
+
argv,
|
|
122784
122884
|
interactive: isInteractiveSession(),
|
|
122785
122885
|
promptFn: async (question) => await promptYesNo({ question })
|
|
122786
122886
|
});
|
|
@@ -122788,7 +122888,7 @@ void runWithIncurSkillsOutOfDateWarningSuppressed({
|
|
|
122788
122888
|
process.exitCode = gate.exitCode;
|
|
122789
122889
|
return;
|
|
122790
122890
|
}
|
|
122791
|
-
await cli.serve(
|
|
122891
|
+
await cli.serve(argv);
|
|
122792
122892
|
}
|
|
122793
122893
|
});
|
|
122794
122894
|
var main_default = cli;
|