@genspark/cli 1.11.2 → 1.13.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.
Files changed (79) hide show
  1. package/README.md +217 -27
  2. package/dist/client.d.ts +67 -2
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +328 -3
  5. package/dist/client.js.map +1 -1
  6. package/dist/commands/chat-events.d.ts +1 -1
  7. package/dist/commands/chat-events.js +1 -1
  8. package/dist/commands/developer-preflight.d.ts +17 -0
  9. package/dist/commands/developer-preflight.d.ts.map +1 -0
  10. package/dist/commands/developer-preflight.js +131 -0
  11. package/dist/commands/developer-preflight.js.map +1 -0
  12. package/dist/commands/developer-project.d.ts +5 -0
  13. package/dist/commands/developer-project.d.ts.map +1 -0
  14. package/dist/commands/developer-project.js +140 -0
  15. package/dist/commands/developer-project.js.map +1 -0
  16. package/dist/commands/genspark-code-skills.d.ts +23 -0
  17. package/dist/commands/genspark-code-skills.d.ts.map +1 -0
  18. package/dist/commands/genspark-code-skills.js +49 -0
  19. package/dist/commands/genspark-code-skills.js.map +1 -0
  20. package/dist/commands/hosted-local.d.ts +10 -0
  21. package/dist/commands/hosted-local.d.ts.map +1 -0
  22. package/dist/commands/hosted-local.js +116 -0
  23. package/dist/commands/hosted-local.js.map +1 -0
  24. package/dist/commands/local-command-routing.d.ts +8 -0
  25. package/dist/commands/local-command-routing.d.ts.map +1 -0
  26. package/dist/commands/local-command-routing.js +33 -0
  27. package/dist/commands/local-command-routing.js.map +1 -0
  28. package/dist/commands/local-preview.d.ts +5 -0
  29. package/dist/commands/local-preview.d.ts.map +1 -0
  30. package/dist/commands/local-preview.js +35 -0
  31. package/dist/commands/local-preview.js.map +1 -0
  32. package/dist/commands/pi-config.d.ts +30 -0
  33. package/dist/commands/pi-config.d.ts.map +1 -0
  34. package/dist/commands/pi-config.js +72 -0
  35. package/dist/commands/pi-config.js.map +1 -0
  36. package/dist/config.d.ts +1 -1
  37. package/dist/config.d.ts.map +1 -1
  38. package/dist/config.js +12 -1
  39. package/dist/config.js.map +1 -1
  40. package/dist/confirm.d.ts +59 -3
  41. package/dist/confirm.d.ts.map +1 -1
  42. package/dist/confirm.js +91 -11
  43. package/dist/confirm.js.map +1 -1
  44. package/dist/developer-contract.d.ts +24 -0
  45. package/dist/developer-contract.d.ts.map +1 -0
  46. package/dist/developer-contract.js +64 -0
  47. package/dist/developer-contract.js.map +1 -0
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +286 -25
  50. package/dist/index.js.map +1 -1
  51. package/dist/local-source.d.ts +22 -0
  52. package/dist/local-source.d.ts.map +1 -0
  53. package/dist/local-source.js +204 -0
  54. package/dist/local-source.js.map +1 -0
  55. package/dist/project-binding.d.ts +31 -0
  56. package/dist/project-binding.d.ts.map +1 -0
  57. package/dist/project-binding.js +141 -0
  58. package/dist/project-binding.js.map +1 -0
  59. package/dist/types.d.ts +21 -0
  60. package/dist/types.d.ts.map +1 -1
  61. package/docs/confirmation.md +113 -6
  62. package/docs/skills.md +3 -2
  63. package/package.json +4 -2
  64. package/skills/gsk-aidrive/SKILL.md +25 -5
  65. package/skills/gsk-audio-generation/SKILL.md +1 -1
  66. package/skills/gsk-claw-share-link/SKILL.md +1 -1
  67. package/skills/gsk-genteam/SKILL.md +7 -8
  68. package/skills/gsk-gmail/SKILL.md +7 -7
  69. package/skills/gsk-google-calendar/SKILL.md +4 -5
  70. package/skills/gsk-google-chat/SKILL.md +2 -4
  71. package/skills/gsk-google-drive/SKILL.md +4 -2
  72. package/skills/gsk-microsoft-teams/SKILL.md +3 -7
  73. package/skills/gsk-onedrive/SKILL.md +4 -2
  74. package/skills/gsk-outlook-calendar/SKILL.md +4 -5
  75. package/skills/gsk-outlook-email/SKILL.md +7 -7
  76. package/skills/gsk-sb-brain/SKILL.md +61 -0
  77. package/skills/gsk-second-brain/SKILL.md +158 -0
  78. package/skills/gsk-shared/SKILL.md +20 -0
  79. package/skills/gsk-slack/SKILL.md +4 -4
package/dist/index.js CHANGED
@@ -18,7 +18,12 @@
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, CommanderError, InvalidArgumentError, Option, } from 'commander';
22
+ import { resolveProjectSelection } from './project-binding.js';
23
+ import { registerDeveloperCommands } from './commands/developer-project.js';
24
+ import { localCommandRoute } from './commands/local-command-routing.js';
25
+ import { localServiceUrl, parseLocalPort } from './commands/local-preview.js';
26
+ import { registerHostedLocalCommand } from './commands/hosted-local.js';
22
27
  import * as fs from 'fs';
23
28
  import * as http from 'http';
24
29
  import * as https from 'https';
@@ -32,7 +37,7 @@ import { ApiClient, isAuthError, unauthenticatedRequest, } from './client.js';
32
37
  import { classifyFileArg, awaitLocalFileReady, decideAfterWait, localFileNotReadyError, passthroughWarning, urlsParamItems, } from './localFiles.js';
33
38
  import { setDebugEnabled, setOutputFormat, debug, info, warn, error as logError, output, progress, } from './logger.js';
34
39
  import { runInteractiveApprovalFlow, shouldPromptForApproval, } from './pendingApproval.js';
35
- import { isPendingConfirmationEnvelope, runPreCallConfirmation, STALE_SCHEMA_CACHE_MESSAGE, } from './confirm.js';
40
+ import { isPendingConfirmationEnvelope, LEGACY_SKIP_PARAMS, runPreCallConfirmation, STALE_SCHEMA_CACHE_MESSAGE, } from './confirm.js';
36
41
  import { repairJsonArrayArgs } from './arrayArgs.js';
37
42
  import { clearToolsCache, getCachedFeatures, loadConfigFile, getConfigPath, loadToolsCache, normalizeBaseUrl, saveToolsCache, setConfigPathOverride, updateConfigFile, } from './config.js';
38
43
  import { checkForUpdates } from './updater.js';
@@ -43,6 +48,7 @@ import { registerDesignCommand } from './commands/design.js';
43
48
  import { collectUploadFiles, pickExistingUploadOperand, buildAidriveUploadQuery, } from './commands/aidrive-upload.js';
44
49
  import { resolveAidriveDownloadOperands, normalizeDrivePath, extractReadableUrl, shouldResolveFileWrapperUrl, } from './commands/aidrive-download.js';
45
50
  import { parseLastSeenIndex, eventStdoutLine } from './commands/chat-events.js';
51
+ import { defaultPiAgentDir, mergePiModelsConfig, mergePiSettingsConfig, readJsonIfExists, resolvePiAgentDir, writeJsonFile, } from './commands/pi-config.js';
46
52
  import { mediaItemsKeyFor, mediaSummaryLines } from './mediaSummary.js';
47
53
  import { registerMeshCommand, getMeshInvocation, runMesh, } from './commands/mesh.js';
48
54
  import { executeCloneUrl, normalizeCloneUrlForGit, } from './commands/sb-git-clone.js';
@@ -64,14 +70,9 @@ function _resolveCustomConfigPath() {
64
70
  // `getGlobalOptions`): CLI flag > env var > (file / default). Check
65
71
  // argv first so an explicit `--config` always wins, even when the user
66
72
  // has a stale `GSK_CONFIG` export lying around in their shell.
67
- const argv = process.argv;
68
- for (let i = 0; i < argv.length; i++) {
69
- const a = argv[i];
70
- if (a === '--config' && i + 1 < argv.length)
71
- return argv[i + 1];
72
- if (a.startsWith('--config='))
73
- return a.slice('--config='.length);
74
- }
73
+ const explicit = localCommandRoute(process.argv.slice(2)).config;
74
+ if (explicit)
75
+ return explicit;
75
76
  const envVal = process.env.GSK_CONFIG;
76
77
  if (envVal)
77
78
  return envVal;
@@ -105,7 +106,8 @@ program
105
106
  // Commander negation flag: parses into opts.input (default true).
106
107
  .option('--no-input', 'Never prompt interactively (e.g. hosted approval y/n); print pending envelopes as-is')
107
108
  .option('-y, --yes', 'Assume "yes" at confirmation prompts for confirmation-required ' +
108
- 'actions (interactive-only actions, e.g. slack send, still prompt)')
109
+ 'actions; replaces the deprecated --skip_confirmation ' +
110
+ '(interactive-only actions, e.g. slack send, still prompt)')
109
111
  .option('--refresh', 'Force refresh of cached tool schemas from server')
110
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.');
111
113
  /**
@@ -132,8 +134,13 @@ function getGlobalOptions() {
132
134
  : fileConfig.timeout || DEFAULT_TIMEOUT;
133
135
  // Debug priority: CLI > config file > default
134
136
  const debugMode = opts.debug || fileConfig.debug || false;
135
- // Project ID priority: CLI > env > config file
136
- const projectId = opts.projectId || process.env.GSK_PROJECT_ID || fileConfig.project_id;
137
+ // Project ID priority: CLI > env > nearest checkout binding > global config.
138
+ const projectId = resolveProjectSelection({
139
+ baseUrl,
140
+ explicit: opts.projectId,
141
+ environment: process.env.GSK_PROJECT_ID,
142
+ legacy: fileConfig.project_id,
143
+ });
137
144
  return {
138
145
  apiKey,
139
146
  baseUrl,
@@ -551,6 +558,8 @@ async function resolveLocalFiles(args, client) {
551
558
  // Map of group name -> parent Command for hierarchical subcommands
552
559
  // (e.g., "email" -> Command for `gsk email [subcommand]`)
553
560
  const _groupCommands = new Map();
561
+ registerDeveloperCommands(program, getGlobalOptions);
562
+ _groupCommands.set('hosted', registerHostedLocalCommand(program, getGlobalOptions));
554
563
  // ============================================
555
564
  /**
556
565
  * Extract a file URL from nested result data using dot-separated path keys.
@@ -651,6 +660,76 @@ function addSchemaOption(cmd, name, param, o) {
651
660
  }
652
661
  }
653
662
  }
663
+ /**
664
+ * Whether a tool (flat / union view) or one of its actions is annotated
665
+ * `requires_confirmation`. These are the only places the pre-contract
666
+ * schema exposed `skip_confirmation` / `auto_skip_confirmation`, so they are
667
+ * the only places where the CLI keeps accepting the legacy params once a
668
+ * new-contract server hides them (hidden flags + --args-file keys), and
669
+ * the only commands whose --help teaches the [y/N] / --yes contract. With
670
+ * a resolvable action on a service tool the answer is that action's own
671
+ * annotation; with none (union view, action-less --args-file) any
672
+ * annotated action counts. Every confirmation-gated tool or action accepts
673
+ * the deprecated flags/keys — including ones whose pre-contract schema
674
+ * never exposed them (hubspot_*, calendar delete): the effect equals --yes
675
+ * and the server already honored the param over HTTP. Non-gated tools
676
+ * still refuse them as unknown parameters.
677
+ */
678
+ function confirmationAnnotated(tool, action) {
679
+ if (tool.cli.requires_confirmation === true)
680
+ return true;
681
+ const actions = tool.actions;
682
+ if (!actions || typeof actions !== 'object')
683
+ return false;
684
+ if (action !== undefined) {
685
+ return actions[action]?.requires_confirmation === true;
686
+ }
687
+ return Object.values(actions).some(info => info?.requires_confirmation === true);
688
+ }
689
+ function isLegacySkipParam(name) {
690
+ return LEGACY_SKIP_PARAMS.includes(name);
691
+ }
692
+ /**
693
+ * Register the legacy skip parameters as hidden boolean flags on a
694
+ * confirmation-annotated command. A new-contract server omits them from
695
+ * `props` (see confirm.ts LEGACY_SKIP_PARAMS); an unattended script that
696
+ * still passes `--skip_confirmation true` must keep parsing and reach the
697
+ * server verbatim, where it is honored as before. Skipped for any name the
698
+ * schema still carries (old server, feature off, stale cache): the visible
699
+ * schema flag already exists, and Commander throws on a duplicate option.
700
+ */
701
+ function addHiddenLegacySkipOptions(cmd, props) {
702
+ for (const name of LEGACY_SKIP_PARAMS) {
703
+ if (name in props)
704
+ continue;
705
+ cmd.addOption(new Option(`--${name} [value]`, 'Deprecated: use --yes')
706
+ .argParser(parseBooleanFlagValue)
707
+ .hideHelp());
708
+ }
709
+ }
710
+ /**
711
+ * One-paragraph contract note appended to `--help` of every confirmation-
712
+ * annotated command / per-action subcommand. The global `--yes` /
713
+ * `--no-input` live on the program and would otherwise never show up in a
714
+ * subcommand's help (Commander hides inherited options there); a flat gated
715
+ * tool's description carries no note at all. Non-gated actions get nothing,
716
+ * and so does a client without the feature bit (old server / GK off): the
717
+ * CLI does not prompt there, so the note would describe a flow that does
718
+ * not run.
719
+ */
720
+ function addConfirmationHelpText(cmd, interactiveOnly) {
721
+ if (getCachedFeatures()?.interactive_confirm !== true)
722
+ return;
723
+ let text = '\nConfirmation: this action asks [y/N] before the single server ' +
724
+ 'call; --yes (-y) runs it unattended; --no-input makes it exit 2 ' +
725
+ 'without calling the server.';
726
+ if (interactiveOnly) {
727
+ text +=
728
+ ' --yes is ignored here (Marketplace policy); a real [y/N] answer ' +
729
+ 'is required.';
730
+ }
731
+ cmd.addHelpText('after', text);
732
+ }
654
733
  /**
655
734
  * Register a dynamic tool command from a server-provided schema.
656
735
  *
@@ -792,6 +871,16 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
792
871
  injectedDefault,
793
872
  });
794
873
  }
874
+ // Union view of a confirmation-annotated tool (flat tools like
875
+ // x_post_tweet, and the hidden legacy top-level forms of service tools):
876
+ // keep accepting the legacy skip flags a new-contract server no longer
877
+ // advertises, and teach the [y/N] / --yes contract in --help. Per-action
878
+ // subcommands do the same per action below.
879
+ if (!actionViews && confirmationAnnotated(tool)) {
880
+ addHiddenLegacySkipOptions(cmd, props);
881
+ const annotated = [tool.cli, ...Object.values(tool.actions ?? {})].filter(source => source?.requires_confirmation === true);
882
+ addConfirmationHelpText(cmd, annotated.every(source => source.interactive_only === true));
883
+ }
795
884
  // For tools that expose an `attachments` array (email send/draft/reply/
796
885
  // forward across gmail + outlook), also surface human-friendly aliases
797
886
  // `--attach` and `--attachment` that funnel into the same array. The
@@ -1083,7 +1172,19 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1083
1172
  // user) may merely be stale, so bust it and let the rerun fetch a
1084
1173
  // fresh schema — an in-process refetch is deliberately not
1085
1174
  // attempted here; the retry is authoritative (the #51775 shape).
1086
- const unknownKeys = Object.keys(fileArgs).filter(key => !(key in props));
1175
+ // The legacy skip params are the one exception, and only on a
1176
+ // confirmation-annotated tool/action: a new-contract server
1177
+ // hides them from the schema, but pre-contract cron payloads
1178
+ // (`{"op": "list", "skip_confirmation": true}` on genteam
1179
+ // members, `skip_confirmation` on a scheduled send) must keep
1180
+ // reaching the server, which still honors them.
1181
+ const fileAction = typeof fileArgs.action === 'string'
1182
+ ? fileArgs.action
1183
+ : typeof args.action === 'string'
1184
+ ? args.action
1185
+ : undefined;
1186
+ const legacySkipAllowed = confirmationAnnotated(tool, fileAction);
1187
+ const unknownKeys = Object.keys(fileArgs).filter(key => !(key in props) && !(legacySkipAllowed && isLegacySkipParam(key)));
1087
1188
  if (unknownKeys.length > 0) {
1088
1189
  clearToolsCache();
1089
1190
  const listed = unknownKeys.map(key => `"${key}"`).join(', ');
@@ -1098,6 +1199,19 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1098
1199
  'passed as flags.');
1099
1200
  process.exit(1);
1100
1201
  }
1202
+ // The deprecated skip keys must be JSON booleans: the CLI flag
1203
+ // parser only ever produces booleans for them, and confirm.ts
1204
+ // decides the prompt on Boolean(value) — a string "false" would
1205
+ // be truthy and skip the prompt. Not an unknown key, so no cache
1206
+ // bust; the request is simply not built.
1207
+ for (const key of LEGACY_SKIP_PARAMS) {
1208
+ if (key in fileArgs && typeof fileArgs[key] !== 'boolean') {
1209
+ logError(`--args-file: ${key} must be a JSON boolean (got ` +
1210
+ `${JSON.stringify(fileArgs[key])}); prefer --yes. ` +
1211
+ 'The request was NOT sent.');
1212
+ process.exit(1);
1213
+ }
1214
+ }
1101
1215
  Object.assign(args, fileArgs);
1102
1216
  for (const [key, value] of Object.entries(fileArgs)) {
1103
1217
  if (Array.isArray(value))
@@ -1314,7 +1428,9 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1314
1428
  }
1315
1429
  // Attachments arrive spelled `aidrive:///a/b.pdf`; take that as-is
1316
1430
  // rather than making the caller strip the scheme.
1317
- const drivePath = sourceOperand ? normalizeDrivePath(sourceOperand) : undefined;
1431
+ const drivePath = sourceOperand
1432
+ ? normalizeDrivePath(sourceOperand)
1433
+ : undefined;
1318
1434
  // --id / --owner / --url resolve server-side inside get_readable_url;
1319
1435
  // with them the path operand is optional.
1320
1436
  const downloadLocator = {
@@ -1444,7 +1560,8 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1444
1560
  // default the server may have moved this file aside, and
1445
1561
  // echoing the requested destination would tell the caller it
1446
1562
  // wrote a file that does not exist.
1447
- const landed = result.data?.path;
1563
+ const landed = result.data
1564
+ ?.path;
1448
1565
  uploaded.push(landed || destination);
1449
1566
  }
1450
1567
  output({
@@ -1783,6 +1900,11 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
1783
1900
  description: actionScopedDescription(props[paramName].description || paramName, view.name, allActionNames),
1784
1901
  });
1785
1902
  }
1903
+ const actionInfo = tool.actions?.[view.name];
1904
+ if (actionInfo?.requires_confirmation === true) {
1905
+ addHiddenLegacySkipOptions(sub, props);
1906
+ addConfirmationHelpText(sub, actionInfo.interactive_only === true);
1907
+ }
1786
1908
  if (hasAttachmentsParam && view.parameters.includes('attachments')) {
1787
1909
  sub.option('--attach <values...>', 'Attach local files or URLs (alias for --attachments; repeatable)');
1788
1910
  sub.option('--attachment <values...>', 'Attach local files or URLs (alias for --attachments; repeatable)');
@@ -2104,14 +2226,55 @@ pathModule.resolve('opencode.json'))
2104
2226
  }
2105
2227
  });
2106
2228
  // ============================================
2229
+ // Init Pi - generate ~/.pi/agent config for Pi (pi.dev)
2230
+ // ============================================
2231
+ program
2232
+ .command('init-pi')
2233
+ .description('Generate Pi (pi.dev) config files (models.json + settings.json under ' +
2234
+ '~/.pi/agent) that route through the Genspark LLM proxy.')
2235
+ .option('--model <model>', 'Default model to use (e.g., claude-opus-4-8)')
2236
+ .option('-o, --out <dir>', 'Output directory for models.json + settings.json', defaultPiAgentDir())
2237
+ .action(async (opts) => {
2238
+ try {
2239
+ const client = createClient();
2240
+ const bundle = (await client.getPiConfig(opts.model));
2241
+ const dir = resolvePiAgentDir(opts.out);
2242
+ const modelsPath = pathModule.join(dir, 'models.json');
2243
+ const settingsPath = pathModule.join(dir, 'settings.json');
2244
+ // Merge, not overwrite: models.json also holds the user's own providers
2245
+ // and settings.json every other Pi setting. Re-running upserts ours.
2246
+ const models = mergePiModelsConfig(readJsonIfExists(modelsPath), bundle);
2247
+ const settings = mergePiSettingsConfig(readJsonIfExists(settingsPath), bundle);
2248
+ // models.json embeds the gsk- token as a literal provider apiKey.
2249
+ writeJsonFile(modelsPath, models, 0o600);
2250
+ writeJsonFile(settingsPath, settings);
2251
+ const providerNames = Object.keys(models.providers ?? {}).join(', ');
2252
+ info(`Wrote Pi config to ${dir} (providers: ${providerNames})`);
2253
+ output({
2254
+ status: 'ok',
2255
+ message: `Config written to ${dir}`,
2256
+ data: {
2257
+ models_path: modelsPath,
2258
+ settings_path: settingsPath,
2259
+ default_provider: settings.defaultProvider,
2260
+ default_model: settings.defaultModel,
2261
+ },
2262
+ });
2263
+ }
2264
+ catch (err) {
2265
+ logError(err.message);
2266
+ process.exit(1);
2267
+ }
2268
+ });
2269
+ // ============================================
2107
2270
  // Init Skills - sync skill docs into current project
2108
2271
  // ============================================
2109
2272
  program
2110
2273
  .command('init-skills')
2111
2274
  .description('Copy GSK skill documents into the current project for AI agent discovery. ' +
2112
- 'Optionally generates agent-specific config (.claude/, CONTEXT.md).')
2275
+ 'Optionally generates agent-specific config (.claude/, AGENTS.md, CONTEXT.md).')
2113
2276
  .option('-o, --out <dir>', 'Output directory for skills (default: .gsk/skills in cwd)', pathModule.resolve('.gsk', 'skills'))
2114
- .option('--agent <type>', 'Generate agent config: claude, gemini, or all')
2277
+ .option('--agent <type>', 'Generate agent config: claude, gemini, pi, or all')
2115
2278
  .action(async (opts) => {
2116
2279
  try {
2117
2280
  const { fileURLToPath } = await import('url');
@@ -2161,7 +2324,7 @@ program
2161
2324
  .split(pathModule.sep)
2162
2325
  .join('/') || '.';
2163
2326
  // Validate --agent value
2164
- const validAgents = ['claude', 'gemini', 'all'];
2327
+ const validAgents = ['claude', 'gemini', 'pi', 'all'];
2165
2328
  if (agentType && !validAgents.includes(agentType)) {
2166
2329
  logError(`Unknown agent type: "${agentType}". Valid values: ${validAgents.join(', ')}`);
2167
2330
  process.exit(1);
@@ -2172,6 +2335,9 @@ program
2172
2335
  if (agentType === 'gemini' || agentType === 'all') {
2173
2336
  _generateGeminiConfig(projectRoot);
2174
2337
  }
2338
+ if (agentType === 'pi' || agentType === 'all') {
2339
+ _generatePiConfig(projectRoot, relSkillsDir);
2340
+ }
2175
2341
  // Always generate CONTEXT.md as the universal agent entry point
2176
2342
  const created = _generateContextMd(projectRoot, relSkillsDir, skillDirs);
2177
2343
  if (created) {
@@ -2192,6 +2358,42 @@ program
2192
2358
  process.exit(1);
2193
2359
  }
2194
2360
  });
2361
+ // ============================================
2362
+ // Init Genspark Code Skills - fetch sandbox skill docs
2363
+ // ============================================
2364
+ program
2365
+ .command('init-genspark-code-skills')
2366
+ .description('Fetch the genspark-code (code sandbox) skill documents into the ' +
2367
+ 'current project for AI agent discovery. Covers the full developer ' +
2368
+ 'skill set a sandbox can install — web / Cloudflare / Flutter / ' +
2369
+ 'Shopify / HTML5-game development, hosted deployment, and GitHub.')
2370
+ .option('-o, --out <dir>', 'Output directory for skills (default: .genspark-code/skills in cwd)', pathModule.resolve('.genspark-code', 'skills'))
2371
+ .action(async (opts) => {
2372
+ try {
2373
+ const client = createClient();
2374
+ const { skills } = await client.getGensparkCodeSkills();
2375
+ const destDir = pathModule.resolve(opts.out);
2376
+ // Validate + write via the traversal-guarded writer shared with
2377
+ // `gsk skills pull` (the paths come from the server).
2378
+ const { writeCodeSkills } = await import('./commands/genspark-code-skills.js');
2379
+ const fileCount = writeCodeSkills(skills, destDir);
2380
+ info(`Wrote ${skills.length} skills (${fileCount} files) to ${destDir}`);
2381
+ output({
2382
+ status: 'ok',
2383
+ message: `Wrote ${skills.length} skills (${fileCount} files) to ${destDir}`,
2384
+ data: {
2385
+ skills_dir: destDir,
2386
+ skill_count: skills.length,
2387
+ file_count: fileCount,
2388
+ skills: skills.map(s => s.name),
2389
+ },
2390
+ });
2391
+ }
2392
+ catch (err) {
2393
+ logError(err.message);
2394
+ process.exit(1);
2395
+ }
2396
+ });
2195
2397
  /** Recursively copy a directory */
2196
2398
  function _copyDirRecursive(src, dest) {
2197
2399
  fs.mkdirSync(dest, { recursive: true });
@@ -2262,6 +2464,33 @@ function _generateGeminiConfig(projectRoot) {
2262
2464
  fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
2263
2465
  info('Generated gemini-extension.json');
2264
2466
  }
2467
+ /** Generate AGENTS.md referencing CONTEXT.md (Pi auto-loads AGENTS.md) */
2468
+ function _generatePiConfig(projectRoot, relSkillsDir) {
2469
+ const agentsMdPath = pathModule.join(projectRoot, 'AGENTS.md');
2470
+ // Don't overwrite if already exists
2471
+ if (fs.existsSync(agentsMdPath)) {
2472
+ const existing = fs.readFileSync(agentsMdPath, 'utf-8');
2473
+ if (existing.includes('CONTEXT.md')) {
2474
+ info('AGENTS.md already references CONTEXT.md, skipping');
2475
+ return;
2476
+ }
2477
+ // Append GSK section to existing AGENTS.md
2478
+ 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`;
2479
+ fs.appendFileSync(agentsMdPath, section);
2480
+ info('Appended GSK section to existing AGENTS.md');
2481
+ return;
2482
+ }
2483
+ const content = `# AGENTS.md
2484
+
2485
+ ## GSK CLI
2486
+
2487
+ This project uses the [Genspark CLI](https://www.genspark.ai) (\`gsk\`). Follow [CONTEXT.md](CONTEXT.md) for all available tools, flags, and usage rules.
2488
+
2489
+ Quick start: read [gsk-shared](${relSkillsDir}/gsk-shared/SKILL.md) for authentication and global flags.
2490
+ `;
2491
+ fs.writeFileSync(agentsMdPath, content);
2492
+ info('Generated AGENTS.md for Pi');
2493
+ }
2265
2494
  /** Generate CONTEXT.md as universal agent entry point. Returns true if created. */
2266
2495
  function _generateContextMd(projectRoot, relSkillsDir, skillDirs) {
2267
2496
  const contextPath = pathModule.join(projectRoot, 'CONTEXT.md');
@@ -2513,11 +2742,6 @@ addPhoneCallOptions(phoneCallCmd
2513
2742
  // Seed the dynamic-group map so server-registered phone-call tools become
2514
2743
  // subcommands of this static parent instead of a duplicate top-level group.
2515
2744
  _groupCommands.set('phone-call', phoneCallCmd);
2516
- // Conversation tree: gsk chat <start|status|ask|stop|delete|rename>. The
2517
- // verbs are all server-registered (cli_path, gated on
2518
- // gk_tool_cli_conversation) and attach as dynamic subcommands via the
2519
- // seeded _groupCommands entry; this static parent only gives the group a
2520
- // real description instead of the generated "Commands for chat".
2521
2745
  // The task command tree. Verbs are server-registered (create / status /
2522
2746
  // info / ask / answer / messages / wait / stop / delete / rename attach as
2523
2747
  // dynamic subcommands via the seeded group); this static parent gives the
@@ -2651,6 +2875,43 @@ taskCmd
2651
2875
  // Dynamic Tool Registration & Startup
2652
2876
  // ============================================
2653
2877
  async function main() {
2878
+ const localRoute = localCommandRoute(process.argv.slice(2));
2879
+ if (localRoute.local &&
2880
+ ['service-url', 'get_service_url'].includes(localRoute.command || '')) {
2881
+ program.exitOverride();
2882
+ program
2883
+ .command('service-url')
2884
+ .alias('get_service_url')
2885
+ .option('--local')
2886
+ .allowExcessArguments(false)
2887
+ .requiredOption('--port <port>', 'Local loopback port', parseLocalPort)
2888
+ .action(async (flags) => {
2889
+ setOutputFormat(program.opts().output);
2890
+ const result = await localServiceUrl(flags.port);
2891
+ output(result);
2892
+ if (result.status === 'error')
2893
+ process.exitCode = 1;
2894
+ });
2895
+ try {
2896
+ await program.parseAsync();
2897
+ }
2898
+ catch (error) {
2899
+ if (error instanceof CommanderError && error.exitCode === 0)
2900
+ return;
2901
+ output({
2902
+ status: 'error',
2903
+ local_only: true,
2904
+ message: error instanceof Error ? error.message : String(error),
2905
+ });
2906
+ process.exitCode = 1;
2907
+ }
2908
+ return;
2909
+ }
2910
+ if (['project', 'preflight'].includes(localRoute.command || '') ||
2911
+ (localRoute.command === 'hosted' && localRoute.subcommand === 'deploy-local')) {
2912
+ await program.parseAsync();
2913
+ return;
2914
+ }
2654
2915
  // Pre-tree `gsk task <type>` compat (see shimLegacyTaskInvocation).
2655
2916
  process.argv = [
2656
2917
  ...process.argv.slice(0, 2),
@@ -2815,7 +3076,7 @@ async function main() {
2815
3076
  }
2816
3077
  }
2817
3078
  // Parse and run
2818
- program.parse();
3079
+ await program.parseAsync();
2819
3080
  }
2820
3081
  main().catch(err => {
2821
3082
  logError(err.message);