@genspark/cli 1.11.0 → 1.12.0
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 +112 -29
- package/dist/arrayArgs.d.ts +66 -0
- package/dist/arrayArgs.d.ts.map +1 -0
- package/dist/arrayArgs.js +144 -0
- package/dist/arrayArgs.js.map +1 -0
- package/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -0
- package/dist/client.js.map +1 -1
- package/dist/commands/chat-events.d.ts +1 -1
- package/dist/commands/chat-events.js +1 -1
- package/dist/commands/pi-config.d.ts +30 -0
- package/dist/commands/pi-config.d.ts.map +1 -0
- package/dist/commands/pi-config.js +72 -0
- package/dist/commands/pi-config.js.map +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +12 -1
- package/dist/config.js.map +1 -1
- package/dist/confirm.d.ts +59 -3
- package/dist/confirm.d.ts.map +1 -1
- package/dist/confirm.js +91 -11
- package/dist/confirm.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +221 -14
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +13 -9
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +15 -8
- package/dist/runtime.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/confirmation.md +113 -6
- package/docs/skills.md +4 -3
- package/package.json +1 -1
- package/skills/gsk-aidrive/SKILL.md +19 -3
- package/skills/gsk-audio-transcribe/SKILL.md +1 -1
- package/skills/gsk-genteam/SKILL.md +10 -10
- package/skills/gsk-github/SKILL.md +0 -4
- package/skills/gsk-gmail/SKILL.md +10 -8
- package/skills/gsk-google-calendar/SKILL.md +4 -6
- package/skills/gsk-google-chat/SKILL.md +3 -5
- package/skills/gsk-google-docs/SKILL.md +0 -4
- package/skills/gsk-google-drive/SKILL.md +5 -3
- package/skills/gsk-google-sheets/SKILL.md +1 -5
- package/skills/gsk-google-slides/SKILL.md +0 -4
- package/skills/gsk-microsoft-teams/SKILL.md +14 -16
- package/skills/gsk-notion/SKILL.md +0 -4
- package/skills/gsk-onedrive/SKILL.md +5 -3
- package/skills/gsk-outlook-calendar/SKILL.md +3 -5
- package/skills/gsk-outlook-email/SKILL.md +12 -10
- package/skills/gsk-sb-brain/SKILL.md +130 -0
- package/skills/gsk-shared/SKILL.md +8 -4
- package/skills/gsk-sharepoint/SKILL.md +10 -13
- package/skills/gsk-slack/SKILL.md +5 -5
- package/skills/gsk-video-generation/SKILL.md +3 -3
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* Tool name: "web_search" -> Command: `gsk web_search`, Alias: `gsk search`
|
|
19
19
|
* Tool name: "crawler" -> Command: `gsk crawler`, Alias: `gsk crawl`
|
|
20
20
|
*/
|
|
21
|
-
import { Command, InvalidArgumentError } from 'commander';
|
|
21
|
+
import { Command, InvalidArgumentError, Option } from 'commander';
|
|
22
22
|
import * as fs from 'fs';
|
|
23
23
|
import * as http from 'http';
|
|
24
24
|
import * as https from 'https';
|
|
@@ -32,7 +32,8 @@ import { ApiClient, isAuthError, unauthenticatedRequest, } from './client.js';
|
|
|
32
32
|
import { classifyFileArg, awaitLocalFileReady, decideAfterWait, localFileNotReadyError, passthroughWarning, urlsParamItems, } from './localFiles.js';
|
|
33
33
|
import { setDebugEnabled, setOutputFormat, debug, info, warn, error as logError, output, progress, } from './logger.js';
|
|
34
34
|
import { runInteractiveApprovalFlow, shouldPromptForApproval, } from './pendingApproval.js';
|
|
35
|
-
import { isPendingConfirmationEnvelope, runPreCallConfirmation, STALE_SCHEMA_CACHE_MESSAGE, } from './confirm.js';
|
|
35
|
+
import { isPendingConfirmationEnvelope, LEGACY_SKIP_PARAMS, runPreCallConfirmation, STALE_SCHEMA_CACHE_MESSAGE, } from './confirm.js';
|
|
36
|
+
import { repairJsonArrayArgs } from './arrayArgs.js';
|
|
36
37
|
import { clearToolsCache, getCachedFeatures, loadConfigFile, getConfigPath, loadToolsCache, normalizeBaseUrl, saveToolsCache, setConfigPathOverride, updateConfigFile, } from './config.js';
|
|
37
38
|
import { checkForUpdates } from './updater.js';
|
|
38
39
|
import { addRegisteredCommands, collectToolCommandTokens, staleCacheMissingToken, } from './staleCache.js';
|
|
@@ -42,6 +43,7 @@ import { registerDesignCommand } from './commands/design.js';
|
|
|
42
43
|
import { collectUploadFiles, pickExistingUploadOperand, buildAidriveUploadQuery, } from './commands/aidrive-upload.js';
|
|
43
44
|
import { resolveAidriveDownloadOperands, normalizeDrivePath, extractReadableUrl, shouldResolveFileWrapperUrl, } from './commands/aidrive-download.js';
|
|
44
45
|
import { parseLastSeenIndex, eventStdoutLine } from './commands/chat-events.js';
|
|
46
|
+
import { defaultPiAgentDir, mergePiModelsConfig, mergePiSettingsConfig, readJsonIfExists, resolvePiAgentDir, writeJsonFile, } from './commands/pi-config.js';
|
|
45
47
|
import { mediaItemsKeyFor, mediaSummaryLines } from './mediaSummary.js';
|
|
46
48
|
import { registerMeshCommand, getMeshInvocation, runMesh, } from './commands/mesh.js';
|
|
47
49
|
import { executeCloneUrl, normalizeCloneUrlForGit, } from './commands/sb-git-clone.js';
|
|
@@ -104,7 +106,8 @@ program
|
|
|
104
106
|
// Commander negation flag: parses into opts.input (default true).
|
|
105
107
|
.option('--no-input', 'Never prompt interactively (e.g. hosted approval y/n); print pending envelopes as-is')
|
|
106
108
|
.option('-y, --yes', 'Assume "yes" at confirmation prompts for confirmation-required ' +
|
|
107
|
-
'actions
|
|
109
|
+
'actions; replaces the deprecated --skip_confirmation ' +
|
|
110
|
+
'(interactive-only actions, e.g. slack send, still prompt)')
|
|
108
111
|
.option('--refresh', 'Force refresh of cached tool schemas from server')
|
|
109
112
|
.option('--config <path>', 'Path to a custom config file (defaults to ~/.genspark-tool-cli/config.json, or set GSK_CONFIG env var). The tools cache lives in the same directory as the config file.');
|
|
110
113
|
/**
|
|
@@ -650,6 +653,76 @@ function addSchemaOption(cmd, name, param, o) {
|
|
|
650
653
|
}
|
|
651
654
|
}
|
|
652
655
|
}
|
|
656
|
+
/**
|
|
657
|
+
* Whether a tool (flat / union view) or one of its actions is annotated
|
|
658
|
+
* `requires_confirmation`. These are the only places the pre-contract
|
|
659
|
+
* schema exposed `skip_confirmation` / `auto_skip_confirmation`, so they are
|
|
660
|
+
* the only places where the CLI keeps accepting the legacy params once a
|
|
661
|
+
* new-contract server hides them (hidden flags + --args-file keys), and
|
|
662
|
+
* the only commands whose --help teaches the [y/N] / --yes contract. With
|
|
663
|
+
* a resolvable action on a service tool the answer is that action's own
|
|
664
|
+
* annotation; with none (union view, action-less --args-file) any
|
|
665
|
+
* annotated action counts. Every confirmation-gated tool or action accepts
|
|
666
|
+
* the deprecated flags/keys — including ones whose pre-contract schema
|
|
667
|
+
* never exposed them (hubspot_*, calendar delete): the effect equals --yes
|
|
668
|
+
* and the server already honored the param over HTTP. Non-gated tools
|
|
669
|
+
* still refuse them as unknown parameters.
|
|
670
|
+
*/
|
|
671
|
+
function confirmationAnnotated(tool, action) {
|
|
672
|
+
if (tool.cli.requires_confirmation === true)
|
|
673
|
+
return true;
|
|
674
|
+
const actions = tool.actions;
|
|
675
|
+
if (!actions || typeof actions !== 'object')
|
|
676
|
+
return false;
|
|
677
|
+
if (action !== undefined) {
|
|
678
|
+
return actions[action]?.requires_confirmation === true;
|
|
679
|
+
}
|
|
680
|
+
return Object.values(actions).some(info => info?.requires_confirmation === true);
|
|
681
|
+
}
|
|
682
|
+
function isLegacySkipParam(name) {
|
|
683
|
+
return LEGACY_SKIP_PARAMS.includes(name);
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Register the legacy skip parameters as hidden boolean flags on a
|
|
687
|
+
* confirmation-annotated command. A new-contract server omits them from
|
|
688
|
+
* `props` (see confirm.ts LEGACY_SKIP_PARAMS); an unattended script that
|
|
689
|
+
* still passes `--skip_confirmation true` must keep parsing and reach the
|
|
690
|
+
* server verbatim, where it is honored as before. Skipped for any name the
|
|
691
|
+
* schema still carries (old server, feature off, stale cache): the visible
|
|
692
|
+
* schema flag already exists, and Commander throws on a duplicate option.
|
|
693
|
+
*/
|
|
694
|
+
function addHiddenLegacySkipOptions(cmd, props) {
|
|
695
|
+
for (const name of LEGACY_SKIP_PARAMS) {
|
|
696
|
+
if (name in props)
|
|
697
|
+
continue;
|
|
698
|
+
cmd.addOption(new Option(`--${name} [value]`, 'Deprecated: use --yes')
|
|
699
|
+
.argParser(parseBooleanFlagValue)
|
|
700
|
+
.hideHelp());
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* One-paragraph contract note appended to `--help` of every confirmation-
|
|
705
|
+
* annotated command / per-action subcommand. The global `--yes` /
|
|
706
|
+
* `--no-input` live on the program and would otherwise never show up in a
|
|
707
|
+
* subcommand's help (Commander hides inherited options there); a flat gated
|
|
708
|
+
* tool's description carries no note at all. Non-gated actions get nothing,
|
|
709
|
+
* and so does a client without the feature bit (old server / GK off): the
|
|
710
|
+
* CLI does not prompt there, so the note would describe a flow that does
|
|
711
|
+
* not run.
|
|
712
|
+
*/
|
|
713
|
+
function addConfirmationHelpText(cmd, interactiveOnly) {
|
|
714
|
+
if (getCachedFeatures()?.interactive_confirm !== true)
|
|
715
|
+
return;
|
|
716
|
+
let text = '\nConfirmation: this action asks [y/N] before the single server ' +
|
|
717
|
+
'call; --yes (-y) runs it unattended; --no-input makes it exit 2 ' +
|
|
718
|
+
'without calling the server.';
|
|
719
|
+
if (interactiveOnly) {
|
|
720
|
+
text +=
|
|
721
|
+
' --yes is ignored here (Marketplace policy); a real [y/N] answer ' +
|
|
722
|
+
'is required.';
|
|
723
|
+
}
|
|
724
|
+
cmd.addHelpText('after', text);
|
|
725
|
+
}
|
|
653
726
|
/**
|
|
654
727
|
* Register a dynamic tool command from a server-provided schema.
|
|
655
728
|
*
|
|
@@ -791,6 +864,16 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
791
864
|
injectedDefault,
|
|
792
865
|
});
|
|
793
866
|
}
|
|
867
|
+
// Union view of a confirmation-annotated tool (flat tools like
|
|
868
|
+
// x_post_tweet, and the hidden legacy top-level forms of service tools):
|
|
869
|
+
// keep accepting the legacy skip flags a new-contract server no longer
|
|
870
|
+
// advertises, and teach the [y/N] / --yes contract in --help. Per-action
|
|
871
|
+
// subcommands do the same per action below.
|
|
872
|
+
if (!actionViews && confirmationAnnotated(tool)) {
|
|
873
|
+
addHiddenLegacySkipOptions(cmd, props);
|
|
874
|
+
const annotated = [tool.cli, ...Object.values(tool.actions ?? {})].filter(source => source?.requires_confirmation === true);
|
|
875
|
+
addConfirmationHelpText(cmd, annotated.every(source => source.interactive_only === true));
|
|
876
|
+
}
|
|
794
877
|
// For tools that expose an `attachments` array (email send/draft/reply/
|
|
795
878
|
// forward across gmail + outlook), also surface human-friendly aliases
|
|
796
879
|
// `--attach` and `--attachment` that funnel into the same array. The
|
|
@@ -1056,6 +1139,10 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1056
1139
|
// deliberate rich payload, flags are the convenience layer (#46011).
|
|
1057
1140
|
// It sits before the numeric coercion below so file-provided
|
|
1058
1141
|
// numeric strings get the same schema-driven coercion flags do.
|
|
1142
|
+
// Array values that arrive from --args-file as real JSON arrays are
|
|
1143
|
+
// forwarded verbatim by the array-literal repair below (JSON has no
|
|
1144
|
+
// shell ambiguity); collected here because the merge erases origin.
|
|
1145
|
+
const fileProvidedArrays = new Set();
|
|
1059
1146
|
if (argsFilePath) {
|
|
1060
1147
|
let fileArgs;
|
|
1061
1148
|
try {
|
|
@@ -1078,7 +1165,19 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1078
1165
|
// user) may merely be stale, so bust it and let the rerun fetch a
|
|
1079
1166
|
// fresh schema — an in-process refetch is deliberately not
|
|
1080
1167
|
// attempted here; the retry is authoritative (the #51775 shape).
|
|
1081
|
-
|
|
1168
|
+
// The legacy skip params are the one exception, and only on a
|
|
1169
|
+
// confirmation-annotated tool/action: a new-contract server
|
|
1170
|
+
// hides them from the schema, but pre-contract cron payloads
|
|
1171
|
+
// (`{"op": "list", "skip_confirmation": true}` on genteam
|
|
1172
|
+
// members, `skip_confirmation` on a scheduled send) must keep
|
|
1173
|
+
// reaching the server, which still honors them.
|
|
1174
|
+
const fileAction = typeof fileArgs.action === 'string'
|
|
1175
|
+
? fileArgs.action
|
|
1176
|
+
: typeof args.action === 'string'
|
|
1177
|
+
? args.action
|
|
1178
|
+
: undefined;
|
|
1179
|
+
const legacySkipAllowed = confirmationAnnotated(tool, fileAction);
|
|
1180
|
+
const unknownKeys = Object.keys(fileArgs).filter(key => !(key in props) && !(legacySkipAllowed && isLegacySkipParam(key)));
|
|
1082
1181
|
if (unknownKeys.length > 0) {
|
|
1083
1182
|
clearToolsCache();
|
|
1084
1183
|
const listed = unknownKeys.map(key => `"${key}"`).join(', ');
|
|
@@ -1093,7 +1192,24 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1093
1192
|
'passed as flags.');
|
|
1094
1193
|
process.exit(1);
|
|
1095
1194
|
}
|
|
1195
|
+
// The deprecated skip keys must be JSON booleans: the CLI flag
|
|
1196
|
+
// parser only ever produces booleans for them, and confirm.ts
|
|
1197
|
+
// decides the prompt on Boolean(value) — a string "false" would
|
|
1198
|
+
// be truthy and skip the prompt. Not an unknown key, so no cache
|
|
1199
|
+
// bust; the request is simply not built.
|
|
1200
|
+
for (const key of LEGACY_SKIP_PARAMS) {
|
|
1201
|
+
if (key in fileArgs && typeof fileArgs[key] !== 'boolean') {
|
|
1202
|
+
logError(`--args-file: ${key} must be a JSON boolean (got ` +
|
|
1203
|
+
`${JSON.stringify(fileArgs[key])}); prefer --yes. ` +
|
|
1204
|
+
'The request was NOT sent.');
|
|
1205
|
+
process.exit(1);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1096
1208
|
Object.assign(args, fileArgs);
|
|
1209
|
+
for (const [key, value] of Object.entries(fileArgs)) {
|
|
1210
|
+
if (Array.isArray(value))
|
|
1211
|
+
fileProvidedArrays.add(key);
|
|
1212
|
+
}
|
|
1097
1213
|
// Required params were registered optional because the file may
|
|
1098
1214
|
// carry them (Commander validates before the file is readable) —
|
|
1099
1215
|
// re-validate the merged set now. CLI-populated params are
|
|
@@ -1128,6 +1244,23 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1128
1244
|
}
|
|
1129
1245
|
}
|
|
1130
1246
|
}
|
|
1247
|
+
// Array flags are variadics that never JSON-parse, so a whole-array
|
|
1248
|
+
// literal (`--sheet_names '["A","B"]'`) arrives as ONE element and
|
|
1249
|
+
// the server acts on the text verbatim — Google Sheets created a
|
|
1250
|
+
// sheet literally named `["A","B"]` (#60410). Repair it here, after
|
|
1251
|
+
// the --args-file merge, so both input paths see one contract; an
|
|
1252
|
+
// element type that contradicts items.type is refused before any
|
|
1253
|
+
// server call, and a real array from the file is the literal escape
|
|
1254
|
+
// hatch (contract in arrayArgs.ts).
|
|
1255
|
+
{
|
|
1256
|
+
const arrayError = repairJsonArrayArgs(args, props, {
|
|
1257
|
+
literalArrayKeys: fileProvidedArrays,
|
|
1258
|
+
});
|
|
1259
|
+
if (arrayError) {
|
|
1260
|
+
logError(arrayError);
|
|
1261
|
+
process.exit(1);
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1131
1264
|
// Pre-call confirmation (confirm.ts): when the cached /tools
|
|
1132
1265
|
// payload advertised interactive_confirm AND the schema marks this
|
|
1133
1266
|
// tool/action confirmation-required, resolve [y/N] / --yes /
|
|
@@ -1288,7 +1421,9 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1288
1421
|
}
|
|
1289
1422
|
// Attachments arrive spelled `aidrive:///a/b.pdf`; take that as-is
|
|
1290
1423
|
// rather than making the caller strip the scheme.
|
|
1291
|
-
const drivePath = sourceOperand
|
|
1424
|
+
const drivePath = sourceOperand
|
|
1425
|
+
? normalizeDrivePath(sourceOperand)
|
|
1426
|
+
: undefined;
|
|
1292
1427
|
// --id / --owner / --url resolve server-side inside get_readable_url;
|
|
1293
1428
|
// with them the path operand is optional.
|
|
1294
1429
|
const downloadLocator = {
|
|
@@ -1418,7 +1553,8 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1418
1553
|
// default the server may have moved this file aside, and
|
|
1419
1554
|
// echoing the requested destination would tell the caller it
|
|
1420
1555
|
// wrote a file that does not exist.
|
|
1421
|
-
const landed = result.data
|
|
1556
|
+
const landed = result.data
|
|
1557
|
+
?.path;
|
|
1422
1558
|
uploaded.push(landed || destination);
|
|
1423
1559
|
}
|
|
1424
1560
|
output({
|
|
@@ -1757,6 +1893,11 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1757
1893
|
description: actionScopedDescription(props[paramName].description || paramName, view.name, allActionNames),
|
|
1758
1894
|
});
|
|
1759
1895
|
}
|
|
1896
|
+
const actionInfo = tool.actions?.[view.name];
|
|
1897
|
+
if (actionInfo?.requires_confirmation === true) {
|
|
1898
|
+
addHiddenLegacySkipOptions(sub, props);
|
|
1899
|
+
addConfirmationHelpText(sub, actionInfo.interactive_only === true);
|
|
1900
|
+
}
|
|
1760
1901
|
if (hasAttachmentsParam && view.parameters.includes('attachments')) {
|
|
1761
1902
|
sub.option('--attach <values...>', 'Attach local files or URLs (alias for --attachments; repeatable)');
|
|
1762
1903
|
sub.option('--attachment <values...>', 'Attach local files or URLs (alias for --attachments; repeatable)');
|
|
@@ -2078,14 +2219,55 @@ pathModule.resolve('opencode.json'))
|
|
|
2078
2219
|
}
|
|
2079
2220
|
});
|
|
2080
2221
|
// ============================================
|
|
2222
|
+
// Init Pi - generate ~/.pi/agent config for Pi (pi.dev)
|
|
2223
|
+
// ============================================
|
|
2224
|
+
program
|
|
2225
|
+
.command('init-pi')
|
|
2226
|
+
.description('Generate Pi (pi.dev) config files (models.json + settings.json under ' +
|
|
2227
|
+
'~/.pi/agent) that route through the Genspark LLM proxy.')
|
|
2228
|
+
.option('--model <model>', 'Default model to use (e.g., claude-opus-4-8)')
|
|
2229
|
+
.option('-o, --out <dir>', 'Output directory for models.json + settings.json', defaultPiAgentDir())
|
|
2230
|
+
.action(async (opts) => {
|
|
2231
|
+
try {
|
|
2232
|
+
const client = createClient();
|
|
2233
|
+
const bundle = (await client.getPiConfig(opts.model));
|
|
2234
|
+
const dir = resolvePiAgentDir(opts.out);
|
|
2235
|
+
const modelsPath = pathModule.join(dir, 'models.json');
|
|
2236
|
+
const settingsPath = pathModule.join(dir, 'settings.json');
|
|
2237
|
+
// Merge, not overwrite: models.json also holds the user's own providers
|
|
2238
|
+
// and settings.json every other Pi setting. Re-running upserts ours.
|
|
2239
|
+
const models = mergePiModelsConfig(readJsonIfExists(modelsPath), bundle);
|
|
2240
|
+
const settings = mergePiSettingsConfig(readJsonIfExists(settingsPath), bundle);
|
|
2241
|
+
// models.json embeds the gsk- token as a literal provider apiKey.
|
|
2242
|
+
writeJsonFile(modelsPath, models, 0o600);
|
|
2243
|
+
writeJsonFile(settingsPath, settings);
|
|
2244
|
+
const providerNames = Object.keys(models.providers ?? {}).join(', ');
|
|
2245
|
+
info(`Wrote Pi config to ${dir} (providers: ${providerNames})`);
|
|
2246
|
+
output({
|
|
2247
|
+
status: 'ok',
|
|
2248
|
+
message: `Config written to ${dir}`,
|
|
2249
|
+
data: {
|
|
2250
|
+
models_path: modelsPath,
|
|
2251
|
+
settings_path: settingsPath,
|
|
2252
|
+
default_provider: settings.defaultProvider,
|
|
2253
|
+
default_model: settings.defaultModel,
|
|
2254
|
+
},
|
|
2255
|
+
});
|
|
2256
|
+
}
|
|
2257
|
+
catch (err) {
|
|
2258
|
+
logError(err.message);
|
|
2259
|
+
process.exit(1);
|
|
2260
|
+
}
|
|
2261
|
+
});
|
|
2262
|
+
// ============================================
|
|
2081
2263
|
// Init Skills - sync skill docs into current project
|
|
2082
2264
|
// ============================================
|
|
2083
2265
|
program
|
|
2084
2266
|
.command('init-skills')
|
|
2085
2267
|
.description('Copy GSK skill documents into the current project for AI agent discovery. ' +
|
|
2086
|
-
'Optionally generates agent-specific config (.claude/, CONTEXT.md).')
|
|
2268
|
+
'Optionally generates agent-specific config (.claude/, AGENTS.md, CONTEXT.md).')
|
|
2087
2269
|
.option('-o, --out <dir>', 'Output directory for skills (default: .gsk/skills in cwd)', pathModule.resolve('.gsk', 'skills'))
|
|
2088
|
-
.option('--agent <type>', 'Generate agent config: claude, gemini, or all')
|
|
2270
|
+
.option('--agent <type>', 'Generate agent config: claude, gemini, pi, or all')
|
|
2089
2271
|
.action(async (opts) => {
|
|
2090
2272
|
try {
|
|
2091
2273
|
const { fileURLToPath } = await import('url');
|
|
@@ -2135,7 +2317,7 @@ program
|
|
|
2135
2317
|
.split(pathModule.sep)
|
|
2136
2318
|
.join('/') || '.';
|
|
2137
2319
|
// Validate --agent value
|
|
2138
|
-
const validAgents = ['claude', 'gemini', 'all'];
|
|
2320
|
+
const validAgents = ['claude', 'gemini', 'pi', 'all'];
|
|
2139
2321
|
if (agentType && !validAgents.includes(agentType)) {
|
|
2140
2322
|
logError(`Unknown agent type: "${agentType}". Valid values: ${validAgents.join(', ')}`);
|
|
2141
2323
|
process.exit(1);
|
|
@@ -2146,6 +2328,9 @@ program
|
|
|
2146
2328
|
if (agentType === 'gemini' || agentType === 'all') {
|
|
2147
2329
|
_generateGeminiConfig(projectRoot);
|
|
2148
2330
|
}
|
|
2331
|
+
if (agentType === 'pi' || agentType === 'all') {
|
|
2332
|
+
_generatePiConfig(projectRoot, relSkillsDir);
|
|
2333
|
+
}
|
|
2149
2334
|
// Always generate CONTEXT.md as the universal agent entry point
|
|
2150
2335
|
const created = _generateContextMd(projectRoot, relSkillsDir, skillDirs);
|
|
2151
2336
|
if (created) {
|
|
@@ -2236,6 +2421,33 @@ function _generateGeminiConfig(projectRoot) {
|
|
|
2236
2421
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
|
|
2237
2422
|
info('Generated gemini-extension.json');
|
|
2238
2423
|
}
|
|
2424
|
+
/** Generate AGENTS.md referencing CONTEXT.md (Pi auto-loads AGENTS.md) */
|
|
2425
|
+
function _generatePiConfig(projectRoot, relSkillsDir) {
|
|
2426
|
+
const agentsMdPath = pathModule.join(projectRoot, 'AGENTS.md');
|
|
2427
|
+
// Don't overwrite if already exists
|
|
2428
|
+
if (fs.existsSync(agentsMdPath)) {
|
|
2429
|
+
const existing = fs.readFileSync(agentsMdPath, 'utf-8');
|
|
2430
|
+
if (existing.includes('CONTEXT.md')) {
|
|
2431
|
+
info('AGENTS.md already references CONTEXT.md, skipping');
|
|
2432
|
+
return;
|
|
2433
|
+
}
|
|
2434
|
+
// Append GSK section to existing AGENTS.md
|
|
2435
|
+
const section = `\n\n## GSK CLI\n\nThis project uses the Genspark CLI. Follow [CONTEXT.md](CONTEXT.md) for available tools and usage rules.\n`;
|
|
2436
|
+
fs.appendFileSync(agentsMdPath, section);
|
|
2437
|
+
info('Appended GSK section to existing AGENTS.md');
|
|
2438
|
+
return;
|
|
2439
|
+
}
|
|
2440
|
+
const content = `# AGENTS.md
|
|
2441
|
+
|
|
2442
|
+
## GSK CLI
|
|
2443
|
+
|
|
2444
|
+
This project uses the [Genspark CLI](https://www.genspark.ai) (\`gsk\`). Follow [CONTEXT.md](CONTEXT.md) for all available tools, flags, and usage rules.
|
|
2445
|
+
|
|
2446
|
+
Quick start: read [gsk-shared](${relSkillsDir}/gsk-shared/SKILL.md) for authentication and global flags.
|
|
2447
|
+
`;
|
|
2448
|
+
fs.writeFileSync(agentsMdPath, content);
|
|
2449
|
+
info('Generated AGENTS.md for Pi');
|
|
2450
|
+
}
|
|
2239
2451
|
/** Generate CONTEXT.md as universal agent entry point. Returns true if created. */
|
|
2240
2452
|
function _generateContextMd(projectRoot, relSkillsDir, skillDirs) {
|
|
2241
2453
|
const contextPath = pathModule.join(projectRoot, 'CONTEXT.md');
|
|
@@ -2487,11 +2699,6 @@ addPhoneCallOptions(phoneCallCmd
|
|
|
2487
2699
|
// Seed the dynamic-group map so server-registered phone-call tools become
|
|
2488
2700
|
// subcommands of this static parent instead of a duplicate top-level group.
|
|
2489
2701
|
_groupCommands.set('phone-call', phoneCallCmd);
|
|
2490
|
-
// Conversation tree: gsk chat <start|status|ask|stop|delete|rename>. The
|
|
2491
|
-
// verbs are all server-registered (cli_path, gated on
|
|
2492
|
-
// gk_tool_cli_conversation) and attach as dynamic subcommands via the
|
|
2493
|
-
// seeded _groupCommands entry; this static parent only gives the group a
|
|
2494
|
-
// real description instead of the generated "Commands for chat".
|
|
2495
2702
|
// The task command tree. Verbs are server-registered (create / status /
|
|
2496
2703
|
// info / ask / answer / messages / wait / stop / delete / rename attach as
|
|
2497
2704
|
// dynamic subcommands via the seeded group); this static parent gives the
|