@genspark/cli 1.11.2 → 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 +89 -25
- 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 +195 -14
- package/dist/index.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 +3 -2
- package/package.json +1 -1
- package/skills/gsk-aidrive/SKILL.md +19 -3
- package/skills/gsk-genteam/SKILL.md +7 -8
- package/skills/gsk-gmail/SKILL.md +7 -7
- package/skills/gsk-google-calendar/SKILL.md +2 -4
- package/skills/gsk-google-chat/SKILL.md +2 -4
- package/skills/gsk-google-drive/SKILL.md +4 -2
- package/skills/gsk-microsoft-teams/SKILL.md +3 -7
- package/skills/gsk-onedrive/SKILL.md +4 -2
- package/skills/gsk-outlook-calendar/SKILL.md +2 -4
- package/skills/gsk-outlook-email/SKILL.md +7 -7
- package/skills/gsk-sb-brain/SKILL.md +130 -0
- package/skills/gsk-shared/SKILL.md +2 -0
- package/skills/gsk-slack/SKILL.md +4 -4
package/dist/confirm.d.ts
CHANGED
|
@@ -12,6 +12,24 @@
|
|
|
12
12
|
* the old pending/double-call contract only remains as the server-side
|
|
13
13
|
* fail-safe for a stale schema cache (see isPendingConfirmationEnvelope).
|
|
14
14
|
*
|
|
15
|
+
* Actions that dispatch on one argument (genteam members `op`, teams api
|
|
16
|
+
* `method`) additionally carry `confirmation_exempt` — the server's list of
|
|
17
|
+
* read-only values of that argument, plus, when the server substitutes a
|
|
18
|
+
* value for an OMITTED argument, that `default`. Only an exact match
|
|
19
|
+
* against the final merged args (an omitted argument counting as the
|
|
20
|
+
* declared default) skips the prompt (see isConfirmationExempt); everything
|
|
21
|
+
* else stays gated as before, and the server's own gate still backs every
|
|
22
|
+
* write.
|
|
23
|
+
*
|
|
24
|
+
* `--yes` is the only advertised unattended path: a new-contract server
|
|
25
|
+
* omits the legacy `skip_confirmation` / `auto_skip_confirmation`
|
|
26
|
+
* parameters from the schema it serves to this CLI. They are still
|
|
27
|
+
* accepted (hidden flags, --args-file keys — see LEGACY_SKIP_PARAMS) and
|
|
28
|
+
* passed through verbatim, because the server honors them for CLI callers
|
|
29
|
+
* regardless of the feature bit, so pre-contract cron scripts keep working
|
|
30
|
+
* on any server. When such a param is what skips the prompt, the CLI prints
|
|
31
|
+
* LEGACY_SKIP_DEPRECATION_HINT once per process (stderr).
|
|
32
|
+
*
|
|
15
33
|
* Like pendingApproval.ts, every decision is a pure, unit-testable
|
|
16
34
|
* function; the readline shell at the bottom is the only impure part. The
|
|
17
35
|
* prompt reads stdin (NOT /dev/tty) so `echo y | gsk ...` and agents
|
|
@@ -19,15 +37,43 @@
|
|
|
19
37
|
*/
|
|
20
38
|
import type { ApiResponse, ToolSchema } from './types.js';
|
|
21
39
|
export declare const STALE_SCHEMA_CACHE_MESSAGE = "schema cache stale, run 'gsk --refresh ls' and retry";
|
|
40
|
+
/**
|
|
41
|
+
* The pre-contract server-side skip parameters. A new-contract server hides
|
|
42
|
+
* them from the schema served to this CLI; the CLI keeps accepting them
|
|
43
|
+
* (hidden flags + --args-file keys on confirmation-annotated tools) and
|
|
44
|
+
* forwards them unchanged — the server honors them for CLI callers with or
|
|
45
|
+
* without the feature bit, so an unattended script written against the old
|
|
46
|
+
* contract works on every server version.
|
|
47
|
+
*/
|
|
48
|
+
export declare const LEGACY_SKIP_PARAMS: readonly ["skip_confirmation", "auto_skip_confirmation"];
|
|
49
|
+
export declare const LEGACY_SKIP_DEPRECATION_HINT: string;
|
|
50
|
+
/** Test hook: forget that the deprecation hint was already printed. */
|
|
51
|
+
export declare function resetLegacySkipDeprecationHint(): void;
|
|
22
52
|
export interface ConfirmationFlags {
|
|
23
53
|
requiresConfirmation: boolean;
|
|
24
54
|
interactiveOnly: boolean;
|
|
25
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Per-value exemption declared by the server (e.g. genteam members op=list):
|
|
58
|
+
* true only when the annotation is well-formed AND the FINAL merged arg is a
|
|
59
|
+
* string exactly equal to one of the server's canonical values. An arg that
|
|
60
|
+
* is ABSENT (`undefined`, never `null` or `''`) counts as the annotation's
|
|
61
|
+
* `default` when the server declares one — that is the value its run()
|
|
62
|
+
* substitutes, so `teams api --path <x>` with no --method is the GET it
|
|
63
|
+
* really is (#60102). Non-string, unknown or differently-cased values, a
|
|
64
|
+
* default the server did not declare (or declared outside `values`) and any
|
|
65
|
+
* malformed annotation stay gated — fail-closed; the server's own gate still
|
|
66
|
+
* backs every write. No trim, no case-fold: the adaptors normalize
|
|
67
|
+
* differently (lower / none / upper) and the client cannot know which.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isConfirmationExempt(exempt: unknown, args: Record<string, unknown>): boolean;
|
|
26
70
|
/**
|
|
27
71
|
* Resolve the static confirmation annotation for one invocation: service
|
|
28
72
|
* tools carry it per action (`tool.actions[args.action]`), single-action
|
|
29
73
|
* tools on `tool.cli`. Reads the merged args (not the positional) because
|
|
30
|
-
* the action may arrive via --args-file
|
|
74
|
+
* the action may arrive via --args-file — and, for the same reason, the
|
|
75
|
+
* discriminator of a per-value exemption (`op` via flag, alias or file)
|
|
76
|
+
* is read from the final merged args too.
|
|
31
77
|
*/
|
|
32
78
|
export declare function confirmationFlagsFor(tool: ToolSchema, args: Record<string, unknown>): ConfirmationFlags;
|
|
33
79
|
export interface ConfirmationContext {
|
|
@@ -49,6 +95,13 @@ export interface ConfirmationContext {
|
|
|
49
95
|
export type ConfirmationDecision = {
|
|
50
96
|
kind: 'proceed';
|
|
51
97
|
confirmed: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* A legacy skip param — not --yes — is what bypassed the prompt on a
|
|
100
|
+
* gated, non-locked action with the feature on: the caller prints the
|
|
101
|
+
* deprecation hint. Absent when the feature is off or the action is
|
|
102
|
+
* not gated (the param changed nothing there).
|
|
103
|
+
*/
|
|
104
|
+
deprecatedSkip?: boolean;
|
|
52
105
|
} | {
|
|
53
106
|
kind: 'prompt';
|
|
54
107
|
warning?: string;
|
|
@@ -65,7 +118,8 @@ export type ConfirmationDecision = {
|
|
|
65
118
|
* - explicit skip_confirmation/auto_skip_confirmation arg on a normal
|
|
66
119
|
* action → call as today, no prompt, no cli_confirmed (the server
|
|
67
120
|
* honors the skip param directly for CLI callers — existing unattended
|
|
68
|
-
* scripts keep working)
|
|
121
|
+
* scripts keep working), flagged deprecatedSkip so the caller prints
|
|
122
|
+
* the one-line [DEPRECATED] hint;
|
|
69
123
|
* - --yes on a normal action → call with cli_confirmed, no prompt;
|
|
70
124
|
* - --yes or a skip param on an interactive-only action → warn, fall into
|
|
71
125
|
* the prompt (the server strips locked skip params anyway);
|
|
@@ -101,7 +155,9 @@ export interface ConfirmIo {
|
|
|
101
155
|
/**
|
|
102
156
|
* Full pre-call flow. Returns either "call (optionally with cli_confirmed
|
|
103
157
|
* injected)" or "abort with this exit code" — the caller must not touch the
|
|
104
|
-
* server on abort.
|
|
158
|
+
* server on abort. A legacy skip param that bypassed the prompt yields a
|
|
159
|
+
* plain call (no injection) plus the deprecation hint on stderr, at most
|
|
160
|
+
* once per process.
|
|
105
161
|
*/
|
|
106
162
|
export declare function resolvePreCallConfirmation(tool: ToolSchema, args: Record<string, unknown>, ctx: ConfirmationContext, io: ConfirmIo): Promise<PreCallConfirmation>;
|
|
107
163
|
/**
|
package/dist/confirm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirm.d.ts","sourceRoot":"","sources":["../src/confirm.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"confirm.d.ts","sourceRoot":"","sources":["../src/confirm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAsB,UAAU,EAAE,MAAM,YAAY,CAAA;AAE7E,eAAO,MAAM,0BAA0B,yDACiB,CAAA;AAMxD;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,0DAGrB,CAAA;AAEV,eAAO,MAAM,4BAA4B,QAEc,CAAA;AAOvD,uEAAuE;AACvE,wBAAgB,8BAA8B,IAAI,IAAI,CAErD;AAED,MAAM,WAAW,iBAAiB;IAChC,oBAAoB,EAAE,OAAO,CAAA;IAC7B,eAAe,EAAE,OAAO,CAAA;CACzB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAmBT;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,iBAAiB,CAWnB;AAED,MAAM,WAAW,mBAAmB;IAClC,yEAAyE;IACzE,SAAS,EAAE,OAAO,CAAA;IAClB,GAAG,EAAE,OAAO,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,8EAA8E;IAC9E,aAAa,EAAE,OAAO,CAAA;IACtB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,MAAM,MAAM,oBAAoB,GAC5B;IACE,I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ChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,mBAAmB,EACxB,EAAE,EAAE,SAAS,GACZ,OAAO,CAAC,mBAAmB,CAAC,CAiC9B;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAI5E;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,mBAAmB,CAAC,CAoB9B"}
|
package/dist/confirm.js
CHANGED
|
@@ -12,6 +12,24 @@
|
|
|
12
12
|
* the old pending/double-call contract only remains as the server-side
|
|
13
13
|
* fail-safe for a stale schema cache (see isPendingConfirmationEnvelope).
|
|
14
14
|
*
|
|
15
|
+
* Actions that dispatch on one argument (genteam members `op`, teams api
|
|
16
|
+
* `method`) additionally carry `confirmation_exempt` — the server's list of
|
|
17
|
+
* read-only values of that argument, plus, when the server substitutes a
|
|
18
|
+
* value for an OMITTED argument, that `default`. Only an exact match
|
|
19
|
+
* against the final merged args (an omitted argument counting as the
|
|
20
|
+
* declared default) skips the prompt (see isConfirmationExempt); everything
|
|
21
|
+
* else stays gated as before, and the server's own gate still backs every
|
|
22
|
+
* write.
|
|
23
|
+
*
|
|
24
|
+
* `--yes` is the only advertised unattended path: a new-contract server
|
|
25
|
+
* omits the legacy `skip_confirmation` / `auto_skip_confirmation`
|
|
26
|
+
* parameters from the schema it serves to this CLI. They are still
|
|
27
|
+
* accepted (hidden flags, --args-file keys — see LEGACY_SKIP_PARAMS) and
|
|
28
|
+
* passed through verbatim, because the server honors them for CLI callers
|
|
29
|
+
* regardless of the feature bit, so pre-contract cron scripts keep working
|
|
30
|
+
* on any server. When such a param is what skips the prompt, the CLI prints
|
|
31
|
+
* LEGACY_SKIP_DEPRECATION_HINT once per process (stderr).
|
|
32
|
+
*
|
|
15
33
|
* Like pendingApproval.ts, every decision is a pure, unit-testable
|
|
16
34
|
* function; the readline shell at the bottom is the only impure part. The
|
|
17
35
|
* prompt reads stdin (NOT /dev/tty) so `echo y | gsk ...` and agents
|
|
@@ -20,17 +38,70 @@
|
|
|
20
38
|
export const STALE_SCHEMA_CACHE_MESSAGE = "schema cache stale, run 'gsk --refresh ls' and retry";
|
|
21
39
|
const INTERACTIVE_ONLY_WARNING = 'This action requires interactive confirmation (marketplace policy) — ' +
|
|
22
40
|
'--yes / skip_confirmation are ignored.';
|
|
41
|
+
/**
|
|
42
|
+
* The pre-contract server-side skip parameters. A new-contract server hides
|
|
43
|
+
* them from the schema served to this CLI; the CLI keeps accepting them
|
|
44
|
+
* (hidden flags + --args-file keys on confirmation-annotated tools) and
|
|
45
|
+
* forwards them unchanged — the server honors them for CLI callers with or
|
|
46
|
+
* without the feature bit, so an unattended script written against the old
|
|
47
|
+
* contract works on every server version.
|
|
48
|
+
*/
|
|
49
|
+
export const LEGACY_SKIP_PARAMS = [
|
|
50
|
+
'skip_confirmation',
|
|
51
|
+
'auto_skip_confirmation',
|
|
52
|
+
];
|
|
53
|
+
export const LEGACY_SKIP_DEPRECATION_HINT = '[DEPRECATED] --skip_confirmation / --auto_skip_confirmation still work ' +
|
|
54
|
+
'but are deprecated on this CLI — use --yes instead.';
|
|
55
|
+
// Module-level so the hint is printed at most once per process;
|
|
56
|
+
// resetLegacySkipDeprecationHint exists for tests that drive several
|
|
57
|
+
// decisions in one process.
|
|
58
|
+
let legacySkipHintShown = false;
|
|
59
|
+
/** Test hook: forget that the deprecation hint was already printed. */
|
|
60
|
+
export function resetLegacySkipDeprecationHint() {
|
|
61
|
+
legacySkipHintShown = false;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Per-value exemption declared by the server (e.g. genteam members op=list):
|
|
65
|
+
* true only when the annotation is well-formed AND the FINAL merged arg is a
|
|
66
|
+
* string exactly equal to one of the server's canonical values. An arg that
|
|
67
|
+
* is ABSENT (`undefined`, never `null` or `''`) counts as the annotation's
|
|
68
|
+
* `default` when the server declares one — that is the value its run()
|
|
69
|
+
* substitutes, so `teams api --path <x>` with no --method is the GET it
|
|
70
|
+
* really is (#60102). Non-string, unknown or differently-cased values, a
|
|
71
|
+
* default the server did not declare (or declared outside `values`) and any
|
|
72
|
+
* malformed annotation stay gated — fail-closed; the server's own gate still
|
|
73
|
+
* backs every write. No trim, no case-fold: the adaptors normalize
|
|
74
|
+
* differently (lower / none / upper) and the client cannot know which.
|
|
75
|
+
*/
|
|
76
|
+
export function isConfirmationExempt(exempt, args) {
|
|
77
|
+
if (!exempt || typeof exempt !== 'object' || Array.isArray(exempt)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
const { param, values, default: defaultValue, } = exempt;
|
|
81
|
+
if (typeof param !== 'string' || param.length === 0)
|
|
82
|
+
return false;
|
|
83
|
+
if (!Array.isArray(values))
|
|
84
|
+
return false;
|
|
85
|
+
const value = args[param] === undefined && typeof defaultValue === 'string'
|
|
86
|
+
? defaultValue
|
|
87
|
+
: args[param];
|
|
88
|
+
return (typeof value === 'string' &&
|
|
89
|
+
values.some(v => typeof v === 'string' && v === value));
|
|
90
|
+
}
|
|
23
91
|
/**
|
|
24
92
|
* Resolve the static confirmation annotation for one invocation: service
|
|
25
93
|
* tools carry it per action (`tool.actions[args.action]`), single-action
|
|
26
94
|
* tools on `tool.cli`. Reads the merged args (not the positional) because
|
|
27
|
-
* the action may arrive via --args-file
|
|
95
|
+
* the action may arrive via --args-file — and, for the same reason, the
|
|
96
|
+
* discriminator of a per-value exemption (`op` via flag, alias or file)
|
|
97
|
+
* is read from the final merged args too.
|
|
28
98
|
*/
|
|
29
99
|
export function confirmationFlagsFor(tool, args) {
|
|
30
100
|
const action = typeof args.action === 'string' ? args.action : undefined;
|
|
31
101
|
const actionInfo = action && tool.actions ? tool.actions[action] : undefined;
|
|
32
102
|
const source = actionInfo ?? tool.cli;
|
|
33
|
-
const requiresConfirmation = source?.requires_confirmation === true
|
|
103
|
+
const requiresConfirmation = source?.requires_confirmation === true &&
|
|
104
|
+
!isConfirmationExempt(source.confirmation_exempt, args);
|
|
34
105
|
return {
|
|
35
106
|
requiresConfirmation,
|
|
36
107
|
interactiveOnly: requiresConfirmation && source?.interactive_only === true,
|
|
@@ -44,7 +115,8 @@ export function confirmationFlagsFor(tool, args) {
|
|
|
44
115
|
* - explicit skip_confirmation/auto_skip_confirmation arg on a normal
|
|
45
116
|
* action → call as today, no prompt, no cli_confirmed (the server
|
|
46
117
|
* honors the skip param directly for CLI callers — existing unattended
|
|
47
|
-
* scripts keep working)
|
|
118
|
+
* scripts keep working), flagged deprecatedSkip so the caller prints
|
|
119
|
+
* the one-line [DEPRECATED] hint;
|
|
48
120
|
* - --yes on a normal action → call with cli_confirmed, no prompt;
|
|
49
121
|
* - --yes or a skip param on an interactive-only action → warn, fall into
|
|
50
122
|
* the prompt (the server strips locked skip params anyway);
|
|
@@ -56,7 +128,7 @@ export function decideConfirmation(flags, ctx) {
|
|
|
56
128
|
return { kind: 'proceed', confirmed: false };
|
|
57
129
|
}
|
|
58
130
|
if (ctx.skipRequested && !flags.interactiveOnly) {
|
|
59
|
-
return { kind: 'proceed', confirmed: false };
|
|
131
|
+
return { kind: 'proceed', confirmed: false, deprecatedSkip: true };
|
|
60
132
|
}
|
|
61
133
|
if (ctx.yes && !flags.interactiveOnly) {
|
|
62
134
|
return { kind: 'proceed', confirmed: true };
|
|
@@ -80,14 +152,14 @@ export function decideConfirmation(flags, ctx) {
|
|
|
80
152
|
};
|
|
81
153
|
}
|
|
82
154
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* the
|
|
155
|
+
* Both params reach this function as booleans: the CLI flag parser
|
|
156
|
+
* (parseBooleanFlagValue) only produces booleans, and the --args-file merge
|
|
157
|
+
* in index.ts refuses a non-boolean JSON value for either key before the
|
|
158
|
+
* request is built. Boolean() is therefore an identity here and matches
|
|
159
|
+
* what the server honors.
|
|
88
160
|
*/
|
|
89
161
|
function skipParamsRequested(args) {
|
|
90
|
-
return
|
|
162
|
+
return LEGACY_SKIP_PARAMS.some(name => Boolean(args[name]));
|
|
91
163
|
}
|
|
92
164
|
// The preview embeds request-controlled text (--args-file payloads) that
|
|
93
165
|
// reaches the terminal verbatim at the consent prompt: strip C0 controls +
|
|
@@ -135,7 +207,9 @@ export function isConfirmedAnswer(raw) {
|
|
|
135
207
|
/**
|
|
136
208
|
* Full pre-call flow. Returns either "call (optionally with cli_confirmed
|
|
137
209
|
* injected)" or "abort with this exit code" — the caller must not touch the
|
|
138
|
-
* server on abort.
|
|
210
|
+
* server on abort. A legacy skip param that bypassed the prompt yields a
|
|
211
|
+
* plain call (no injection) plus the deprecation hint on stderr, at most
|
|
212
|
+
* once per process.
|
|
139
213
|
*/
|
|
140
214
|
export async function resolvePreCallConfirmation(tool, args, ctx, io) {
|
|
141
215
|
const decision = decideConfirmation(confirmationFlagsFor(tool, args), {
|
|
@@ -143,6 +217,12 @@ export async function resolvePreCallConfirmation(tool, args, ctx, io) {
|
|
|
143
217
|
skipRequested: skipParamsRequested(args),
|
|
144
218
|
});
|
|
145
219
|
if (decision.kind === 'proceed') {
|
|
220
|
+
// The legacy param is forwarded verbatim (no cli_confirmed): only the
|
|
221
|
+
// human gets told, once, that --yes is the supported spelling.
|
|
222
|
+
if (decision.deprecatedSkip && !legacySkipHintShown) {
|
|
223
|
+
legacySkipHintShown = true;
|
|
224
|
+
io.notify(LEGACY_SKIP_DEPRECATION_HINT);
|
|
225
|
+
}
|
|
146
226
|
return { action: 'call', injectConfirmed: decision.confirmed };
|
|
147
227
|
}
|
|
148
228
|
if (decision.kind === 'refuse') {
|
package/dist/confirm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirm.js","sourceRoot":"","sources":["../src/confirm.ts"],"names":[],"mappings":"AAAA
|
|
1
|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AAC,CACpC,CAAA;YACD,IAAI,CAAC;gBACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC,CAAC,CAAA;YACrE,CAAC;oBAAS,CAAC;gBACT,EAAE,CAAC,KAAK,EAAE,CAAA;YACZ,CAAC;QACH,CAAC;QACD,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;KACpC,CAAA;IACD,OAAO,0BAA0B,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAA;AACxD,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG;AAyTH,KAAK,oBAAoB,GAAG,kBAAkB,GAAG,SAAS,GAAG,SAAS,CAAA;AAEtE,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,oBAAoB,CAAA;CAC3B;AAED,kFAAkF;AAClF,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EAAE,GACb,mBAAmB,EAAE,CAqBvB"}
|
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,7 @@ 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
36
|
import { repairJsonArrayArgs } from './arrayArgs.js';
|
|
37
37
|
import { clearToolsCache, getCachedFeatures, loadConfigFile, getConfigPath, loadToolsCache, normalizeBaseUrl, saveToolsCache, setConfigPathOverride, updateConfigFile, } from './config.js';
|
|
38
38
|
import { checkForUpdates } from './updater.js';
|
|
@@ -43,6 +43,7 @@ import { registerDesignCommand } from './commands/design.js';
|
|
|
43
43
|
import { collectUploadFiles, pickExistingUploadOperand, buildAidriveUploadQuery, } from './commands/aidrive-upload.js';
|
|
44
44
|
import { resolveAidriveDownloadOperands, normalizeDrivePath, extractReadableUrl, shouldResolveFileWrapperUrl, } from './commands/aidrive-download.js';
|
|
45
45
|
import { parseLastSeenIndex, eventStdoutLine } from './commands/chat-events.js';
|
|
46
|
+
import { defaultPiAgentDir, mergePiModelsConfig, mergePiSettingsConfig, readJsonIfExists, resolvePiAgentDir, writeJsonFile, } from './commands/pi-config.js';
|
|
46
47
|
import { mediaItemsKeyFor, mediaSummaryLines } from './mediaSummary.js';
|
|
47
48
|
import { registerMeshCommand, getMeshInvocation, runMesh, } from './commands/mesh.js';
|
|
48
49
|
import { executeCloneUrl, normalizeCloneUrlForGit, } from './commands/sb-git-clone.js';
|
|
@@ -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
|
|
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
|
/**
|
|
@@ -651,6 +653,76 @@ function addSchemaOption(cmd, name, param, o) {
|
|
|
651
653
|
}
|
|
652
654
|
}
|
|
653
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
|
+
}
|
|
654
726
|
/**
|
|
655
727
|
* Register a dynamic tool command from a server-provided schema.
|
|
656
728
|
*
|
|
@@ -792,6 +864,16 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
792
864
|
injectedDefault,
|
|
793
865
|
});
|
|
794
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
|
+
}
|
|
795
877
|
// For tools that expose an `attachments` array (email send/draft/reply/
|
|
796
878
|
// forward across gmail + outlook), also surface human-friendly aliases
|
|
797
879
|
// `--attach` and `--attachment` that funnel into the same array. The
|
|
@@ -1083,7 +1165,19 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1083
1165
|
// user) may merely be stale, so bust it and let the rerun fetch a
|
|
1084
1166
|
// fresh schema — an in-process refetch is deliberately not
|
|
1085
1167
|
// attempted here; the retry is authoritative (the #51775 shape).
|
|
1086
|
-
|
|
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)));
|
|
1087
1181
|
if (unknownKeys.length > 0) {
|
|
1088
1182
|
clearToolsCache();
|
|
1089
1183
|
const listed = unknownKeys.map(key => `"${key}"`).join(', ');
|
|
@@ -1098,6 +1192,19 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1098
1192
|
'passed as flags.');
|
|
1099
1193
|
process.exit(1);
|
|
1100
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
|
+
}
|
|
1101
1208
|
Object.assign(args, fileArgs);
|
|
1102
1209
|
for (const [key, value] of Object.entries(fileArgs)) {
|
|
1103
1210
|
if (Array.isArray(value))
|
|
@@ -1314,7 +1421,9 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1314
1421
|
}
|
|
1315
1422
|
// Attachments arrive spelled `aidrive:///a/b.pdf`; take that as-is
|
|
1316
1423
|
// rather than making the caller strip the scheme.
|
|
1317
|
-
const drivePath = sourceOperand
|
|
1424
|
+
const drivePath = sourceOperand
|
|
1425
|
+
? normalizeDrivePath(sourceOperand)
|
|
1426
|
+
: undefined;
|
|
1318
1427
|
// --id / --owner / --url resolve server-side inside get_readable_url;
|
|
1319
1428
|
// with them the path operand is optional.
|
|
1320
1429
|
const downloadLocator = {
|
|
@@ -1444,7 +1553,8 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1444
1553
|
// default the server may have moved this file aside, and
|
|
1445
1554
|
// echoing the requested destination would tell the caller it
|
|
1446
1555
|
// wrote a file that does not exist.
|
|
1447
|
-
const landed = result.data
|
|
1556
|
+
const landed = result.data
|
|
1557
|
+
?.path;
|
|
1448
1558
|
uploaded.push(landed || destination);
|
|
1449
1559
|
}
|
|
1450
1560
|
output({
|
|
@@ -1783,6 +1893,11 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1783
1893
|
description: actionScopedDescription(props[paramName].description || paramName, view.name, allActionNames),
|
|
1784
1894
|
});
|
|
1785
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
|
+
}
|
|
1786
1901
|
if (hasAttachmentsParam && view.parameters.includes('attachments')) {
|
|
1787
1902
|
sub.option('--attach <values...>', 'Attach local files or URLs (alias for --attachments; repeatable)');
|
|
1788
1903
|
sub.option('--attachment <values...>', 'Attach local files or URLs (alias for --attachments; repeatable)');
|
|
@@ -2104,14 +2219,55 @@ pathModule.resolve('opencode.json'))
|
|
|
2104
2219
|
}
|
|
2105
2220
|
});
|
|
2106
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
|
+
// ============================================
|
|
2107
2263
|
// Init Skills - sync skill docs into current project
|
|
2108
2264
|
// ============================================
|
|
2109
2265
|
program
|
|
2110
2266
|
.command('init-skills')
|
|
2111
2267
|
.description('Copy GSK skill documents into the current project for AI agent discovery. ' +
|
|
2112
|
-
'Optionally generates agent-specific config (.claude/, CONTEXT.md).')
|
|
2268
|
+
'Optionally generates agent-specific config (.claude/, AGENTS.md, CONTEXT.md).')
|
|
2113
2269
|
.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')
|
|
2270
|
+
.option('--agent <type>', 'Generate agent config: claude, gemini, pi, or all')
|
|
2115
2271
|
.action(async (opts) => {
|
|
2116
2272
|
try {
|
|
2117
2273
|
const { fileURLToPath } = await import('url');
|
|
@@ -2161,7 +2317,7 @@ program
|
|
|
2161
2317
|
.split(pathModule.sep)
|
|
2162
2318
|
.join('/') || '.';
|
|
2163
2319
|
// Validate --agent value
|
|
2164
|
-
const validAgents = ['claude', 'gemini', 'all'];
|
|
2320
|
+
const validAgents = ['claude', 'gemini', 'pi', 'all'];
|
|
2165
2321
|
if (agentType && !validAgents.includes(agentType)) {
|
|
2166
2322
|
logError(`Unknown agent type: "${agentType}". Valid values: ${validAgents.join(', ')}`);
|
|
2167
2323
|
process.exit(1);
|
|
@@ -2172,6 +2328,9 @@ program
|
|
|
2172
2328
|
if (agentType === 'gemini' || agentType === 'all') {
|
|
2173
2329
|
_generateGeminiConfig(projectRoot);
|
|
2174
2330
|
}
|
|
2331
|
+
if (agentType === 'pi' || agentType === 'all') {
|
|
2332
|
+
_generatePiConfig(projectRoot, relSkillsDir);
|
|
2333
|
+
}
|
|
2175
2334
|
// Always generate CONTEXT.md as the universal agent entry point
|
|
2176
2335
|
const created = _generateContextMd(projectRoot, relSkillsDir, skillDirs);
|
|
2177
2336
|
if (created) {
|
|
@@ -2262,6 +2421,33 @@ function _generateGeminiConfig(projectRoot) {
|
|
|
2262
2421
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
|
|
2263
2422
|
info('Generated gemini-extension.json');
|
|
2264
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
|
+
}
|
|
2265
2451
|
/** Generate CONTEXT.md as universal agent entry point. Returns true if created. */
|
|
2266
2452
|
function _generateContextMd(projectRoot, relSkillsDir, skillDirs) {
|
|
2267
2453
|
const contextPath = pathModule.join(projectRoot, 'CONTEXT.md');
|
|
@@ -2513,11 +2699,6 @@ addPhoneCallOptions(phoneCallCmd
|
|
|
2513
2699
|
// Seed the dynamic-group map so server-registered phone-call tools become
|
|
2514
2700
|
// subcommands of this static parent instead of a duplicate top-level group.
|
|
2515
2701
|
_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
2702
|
// The task command tree. Verbs are server-registered (create / status /
|
|
2522
2703
|
// info / ask / answer / messages / wait / stop / delete / rename attach as
|
|
2523
2704
|
// dynamic subcommands via the seeded group); this static parent gives the
|