@genspark/cli 1.12.0 → 1.13.1
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 +132 -5
- package/dist/client.d.ts +77 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +379 -3
- package/dist/client.js.map +1 -1
- package/dist/commands/developer-preflight.d.ts +17 -0
- package/dist/commands/developer-preflight.d.ts.map +1 -0
- package/dist/commands/developer-preflight.js +131 -0
- package/dist/commands/developer-preflight.js.map +1 -0
- package/dist/commands/developer-project.d.ts +5 -0
- package/dist/commands/developer-project.d.ts.map +1 -0
- package/dist/commands/developer-project.js +140 -0
- package/dist/commands/developer-project.js.map +1 -0
- package/dist/commands/genspark-code-skills.d.ts +23 -0
- package/dist/commands/genspark-code-skills.d.ts.map +1 -0
- package/dist/commands/genspark-code-skills.js +49 -0
- package/dist/commands/genspark-code-skills.js.map +1 -0
- package/dist/commands/genteam-download.d.ts +34 -0
- package/dist/commands/genteam-download.d.ts.map +1 -0
- package/dist/commands/genteam-download.js +95 -0
- package/dist/commands/genteam-download.js.map +1 -0
- package/dist/commands/hosted-local.d.ts +10 -0
- package/dist/commands/hosted-local.d.ts.map +1 -0
- package/dist/commands/hosted-local.js +116 -0
- package/dist/commands/hosted-local.js.map +1 -0
- package/dist/commands/local-command-routing.d.ts +8 -0
- package/dist/commands/local-command-routing.d.ts.map +1 -0
- package/dist/commands/local-command-routing.js +33 -0
- package/dist/commands/local-command-routing.js.map +1 -0
- package/dist/commands/local-preview.d.ts +5 -0
- package/dist/commands/local-preview.d.ts.map +1 -0
- package/dist/commands/local-preview.js +35 -0
- package/dist/commands/local-preview.js.map +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/developer-contract.d.ts +24 -0
- package/dist/developer-contract.d.ts.map +1 -0
- package/dist/developer-contract.js +64 -0
- package/dist/developer-contract.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +358 -19
- package/dist/index.js.map +1 -1
- package/dist/local-source.d.ts +22 -0
- package/dist/local-source.d.ts.map +1 -0
- package/dist/local-source.js +204 -0
- package/dist/local-source.js.map +1 -0
- package/dist/project-binding.d.ts +31 -0
- package/dist/project-binding.d.ts.map +1 -0
- package/dist/project-binding.js +141 -0
- package/dist/project-binding.js.map +1 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/skills.md +1 -1
- package/package.json +4 -2
- package/skills/gsk-aidrive/SKILL.md +94 -24
- package/skills/gsk-audio-generation/SKILL.md +1 -1
- package/skills/gsk-claw-share-link/SKILL.md +1 -1
- package/skills/gsk-genteam/SKILL.md +1 -1
- package/skills/gsk-google-calendar/SKILL.md +2 -1
- package/skills/gsk-meeting/SKILL.md +1 -0
- package/skills/gsk-outlook-calendar/SKILL.md +2 -1
- package/skills/gsk-sb-brain/SKILL.md +13 -82
- package/skills/gsk-second-brain/SKILL.md +179 -0
- package/skills/gsk-shared/SKILL.md +18 -0
- package/skills/gsk-slack/SKILL.md +8 -7
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { ApiHttpError } from '../client.js';
|
|
5
|
+
export const PREFLIGHT_OPERATIONS = [
|
|
6
|
+
'preview',
|
|
7
|
+
'hosted-deploy',
|
|
8
|
+
'github',
|
|
9
|
+
'cloudflare',
|
|
10
|
+
'shopify',
|
|
11
|
+
'android',
|
|
12
|
+
];
|
|
13
|
+
async function hasBinary(name) {
|
|
14
|
+
const extensions = process.platform === 'win32'
|
|
15
|
+
? (process.env.PATHEXT || '.EXE;.CMD;.BAT').split(';')
|
|
16
|
+
: [''];
|
|
17
|
+
const directories = [
|
|
18
|
+
path.resolve('node_modules', '.bin'),
|
|
19
|
+
...(process.env.PATH || '').split(path.delimiter).filter(Boolean),
|
|
20
|
+
];
|
|
21
|
+
for (const directory of directories) {
|
|
22
|
+
for (const extension of extensions) {
|
|
23
|
+
try {
|
|
24
|
+
const filename = path.join(directory, name + extension);
|
|
25
|
+
await fs.access(filename, constants.X_OK);
|
|
26
|
+
if ((await fs.stat(filename)).isFile())
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
// A missing or inaccessible PATH entry is not an installed binary.
|
|
31
|
+
if (!(error &&
|
|
32
|
+
typeof error === 'object' &&
|
|
33
|
+
'code' in error &&
|
|
34
|
+
['ENOENT', 'EACCES', 'ENOTDIR'].includes(String(error.code)))) {
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
/** Check only host binaries relevant to this operation; never execute project code. */
|
|
43
|
+
export async function localPreflightChecks(kind, operation) {
|
|
44
|
+
const binaries = {
|
|
45
|
+
preview: kind === 'flutter' ? ['flutter', 'dart'] : ['node', 'npm'],
|
|
46
|
+
'hosted-deploy': ['node'],
|
|
47
|
+
github: ['git', 'gh'],
|
|
48
|
+
cloudflare: ['node', 'npm'],
|
|
49
|
+
shopify: ['node', 'shopify'],
|
|
50
|
+
android: kind === 'flutter'
|
|
51
|
+
? ['flutter', 'dart', 'java']
|
|
52
|
+
: ['node', 'npm', 'java'],
|
|
53
|
+
};
|
|
54
|
+
const checks = [];
|
|
55
|
+
for (const name of binaries[operation] || []) {
|
|
56
|
+
const ready = await hasBinary(name);
|
|
57
|
+
checks.push({
|
|
58
|
+
name: `Local ${name}`,
|
|
59
|
+
status: ready ? 'ready' : 'action_required',
|
|
60
|
+
code: ready ? `local_${name}_ready` : `local_${name}_missing`,
|
|
61
|
+
message: ready
|
|
62
|
+
? `${name} is available on PATH.`
|
|
63
|
+
: `Install ${name} on this machine and add it to PATH.`,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (['github', 'cloudflare', 'shopify'].includes(operation)) {
|
|
67
|
+
const login = {
|
|
68
|
+
github: 'gh auth login',
|
|
69
|
+
cloudflare: 'npx wrangler login (using your project-pinned Wrangler version)',
|
|
70
|
+
shopify: 'shopify auth login',
|
|
71
|
+
};
|
|
72
|
+
checks.push({
|
|
73
|
+
name: 'Local provider authorization',
|
|
74
|
+
status: 'unknown',
|
|
75
|
+
code: 'local_provider_auth_unchecked',
|
|
76
|
+
message: `Use ${login[operation]} for your local shell. Platform connector checks and sandbox_auth_* do not configure local credentials.`,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return checks;
|
|
80
|
+
}
|
|
81
|
+
/** Retain local results even when authentication or remote advisory checks are unavailable. */
|
|
82
|
+
export async function runDeveloperPreflight(options) {
|
|
83
|
+
const checks = await localPreflightChecks(options.kind, options.operation);
|
|
84
|
+
let project;
|
|
85
|
+
if (!options.client) {
|
|
86
|
+
checks.push({
|
|
87
|
+
name: 'Genspark account',
|
|
88
|
+
status: 'action_required',
|
|
89
|
+
code: options.configurationError
|
|
90
|
+
? 'project_configuration_error'
|
|
91
|
+
: 'gsk_login_required',
|
|
92
|
+
message: options.configurationError ||
|
|
93
|
+
'Run `gsk login` for platform checks. Local preview remains available without login.',
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
try {
|
|
98
|
+
const remote = await options.client.developerPreflight(options.kind, options.operation);
|
|
99
|
+
checks.push(...remote.checks);
|
|
100
|
+
project = remote.project;
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
if (error instanceof ApiHttpError && error.serverDetail?.code) {
|
|
104
|
+
// A structured server verdict (e.g. project_kind_mismatch) is an
|
|
105
|
+
// actionable result, not an unreadable check — surface its own code.
|
|
106
|
+
checks.push({
|
|
107
|
+
name: 'Platform checks',
|
|
108
|
+
status: 'action_required',
|
|
109
|
+
code: error.serverDetail.code,
|
|
110
|
+
message: error.serverDetail.message || error.message,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
checks.push({
|
|
115
|
+
name: 'Platform checks',
|
|
116
|
+
status: 'unknown',
|
|
117
|
+
code: 'platform_preflight_unavailable',
|
|
118
|
+
message: error instanceof Error ? error.message : String(error),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
status: checks.some(check => ['action_required', 'unknown'].includes(check.status))
|
|
125
|
+
? 'action_required'
|
|
126
|
+
: 'ok',
|
|
127
|
+
checks,
|
|
128
|
+
...(project ? { project } : {}),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=developer-preflight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"developer-preflight.js","sourceRoot":"","sources":["../../src/commands/developer-preflight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAI3C,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,SAAS;IACT,eAAe;IACf,QAAQ;IACR,YAAY;IACZ,SAAS;IACT,SAAS;CACD,CAAA;AAEV,KAAK,UAAU,SAAS,CAAC,IAAY;IACnC,MAAM,UAAU,GACd,OAAO,CAAC,QAAQ,KAAK,OAAO;QAC1B,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;QACtD,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;IACV,MAAM,WAAW,GAAG;QAClB,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,MAAM,CAAC;QACpC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IA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SAAS;oBACjB,IAAI,EAAE,gCAAgC;oBACtC,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;iBAChE,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAC1B,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CACtD;YACC,CAAC,CAAC,iBAAiB;YACnB,CAAC,CAAC,IAAI;QACR,MAAM;QACN,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { GlobalOptions } from '../types.js';
|
|
3
|
+
/** Register static developer commands independently of server tool metadata. */
|
|
4
|
+
export declare function registerDeveloperCommands(program: Command, getOptions: () => GlobalOptions): void;
|
|
5
|
+
//# sourceMappingURL=developer-project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"developer-project.d.ts","sourceRoot":"","sources":["../../src/commands/developer-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAA;AAG3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAgChD,gFAAgF;AAChF,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CA0HN"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Option } from 'commander';
|
|
2
|
+
import { createInterface } from 'node:readline/promises';
|
|
3
|
+
import { ApiClient } from '../client.js';
|
|
4
|
+
import { output, setOutputFormat } from '../logger.js';
|
|
5
|
+
import { findProjectBinding, writeProjectBinding } from '../project-binding.js';
|
|
6
|
+
import { PREFLIGHT_OPERATIONS, runDeveloperPreflight, } from './developer-preflight.js';
|
|
7
|
+
async function confirmCreate(options) {
|
|
8
|
+
if (options.yes)
|
|
9
|
+
return;
|
|
10
|
+
if (options.noInput || !process.stdin.isTTY || !process.stderr.isTTY) {
|
|
11
|
+
throw new Error('Project creation requires explicit confirmation. Re-run with --yes to create a new private project.');
|
|
12
|
+
}
|
|
13
|
+
const reader = createInterface({
|
|
14
|
+
input: process.stdin,
|
|
15
|
+
output: process.stderr,
|
|
16
|
+
});
|
|
17
|
+
try {
|
|
18
|
+
if ((await reader.question('Create a new private Genspark project? [y/N] '))
|
|
19
|
+
.trim()
|
|
20
|
+
.toLowerCase() !== 'y') {
|
|
21
|
+
throw new Error('Project creation cancelled');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
reader.close();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Register static developer commands independently of server tool metadata. */
|
|
29
|
+
export function registerDeveloperCommands(program, getOptions) {
|
|
30
|
+
const project = program
|
|
31
|
+
.command('project')
|
|
32
|
+
.description('Create, bind, or inspect a project for this checkout');
|
|
33
|
+
project
|
|
34
|
+
.command('create')
|
|
35
|
+
.allowExcessArguments(false)
|
|
36
|
+
.requiredOption('--kind <kind>', 'Project kind, e.g. web')
|
|
37
|
+
.requiredOption('--name <name>', 'Project name')
|
|
38
|
+
// Declared here only so `--help` shows it: `--yes` is the global flag, and
|
|
39
|
+
// commander still routes it to the root options this action reads.
|
|
40
|
+
.option('-y, --yes', 'Skip the prompt and create the new private project non-interactively.')
|
|
41
|
+
.action(async (flags) => {
|
|
42
|
+
const options = getOptions();
|
|
43
|
+
setOutputFormat(options.output);
|
|
44
|
+
if (findProjectBinding()) {
|
|
45
|
+
throw new Error('This checkout already has a binding. Create from an unbound checkout.');
|
|
46
|
+
}
|
|
47
|
+
if (!flags.name.trim() || !/^[a-z][a-z0-9_-]{0,63}$/.test(flags.kind)) {
|
|
48
|
+
throw new Error('Provide a valid kind and non-empty name');
|
|
49
|
+
}
|
|
50
|
+
await confirmCreate({ ...options, yes: options.yes || flags.yes });
|
|
51
|
+
let created;
|
|
52
|
+
try {
|
|
53
|
+
created = await new ApiClient(options).createDeveloperProject(flags.kind, flags.name);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
throw new Error(`${error instanceof Error ? error.message : String(error)} ` +
|
|
57
|
+
'Creation was not retried. If the connection failed, check your project list before creating again, then use `gsk project bind <id>`.');
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const bindingFile = writeProjectBinding({
|
|
61
|
+
version: 1,
|
|
62
|
+
project_id: created.project_id,
|
|
63
|
+
kind: created.kind,
|
|
64
|
+
base_url: options.baseUrl,
|
|
65
|
+
});
|
|
66
|
+
output({ status: 'ok', project: created, binding_file: bindingFile });
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
output({
|
|
70
|
+
status: 'error',
|
|
71
|
+
project: created,
|
|
72
|
+
message: `Project created, but binding failed: ${error instanceof Error ? error.message : String(error)}. Do not create again; bind ${created.project_id}.`,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
project
|
|
77
|
+
.command('bind <id>')
|
|
78
|
+
.allowExcessArguments(false)
|
|
79
|
+
.description('Validate server ownership and bind this checkout')
|
|
80
|
+
.action(async (id) => {
|
|
81
|
+
const options = getOptions();
|
|
82
|
+
setOutputFormat(options.output);
|
|
83
|
+
const project = await new ApiClient(options).getDeveloperProject(id);
|
|
84
|
+
const bindingFile = writeProjectBinding({
|
|
85
|
+
version: 1,
|
|
86
|
+
project_id: project.project_id,
|
|
87
|
+
kind: project.kind,
|
|
88
|
+
base_url: options.baseUrl,
|
|
89
|
+
});
|
|
90
|
+
output({ status: 'ok', project, binding_file: bindingFile });
|
|
91
|
+
});
|
|
92
|
+
project
|
|
93
|
+
.command('status')
|
|
94
|
+
.allowExcessArguments(false)
|
|
95
|
+
.description('Inspect local selection and verify server ownership')
|
|
96
|
+
.action(async () => {
|
|
97
|
+
const options = getOptions();
|
|
98
|
+
setOutputFormat(options.output);
|
|
99
|
+
const local = findProjectBinding();
|
|
100
|
+
if (!options.projectId || !options.apiKey) {
|
|
101
|
+
output({
|
|
102
|
+
status: 'action_required',
|
|
103
|
+
binding: local?.binding || null,
|
|
104
|
+
project_id: options.projectId || null,
|
|
105
|
+
message: !options.apiKey
|
|
106
|
+
? 'Run `gsk login` to verify ownership. Local preview needs no login.'
|
|
107
|
+
: 'Use `gsk project bind <id>` or explicitly create a project.',
|
|
108
|
+
});
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const project = await new ApiClient(options).getDeveloperProject(options.projectId);
|
|
112
|
+
output({ status: 'ok', project, binding: local?.binding || null });
|
|
113
|
+
});
|
|
114
|
+
program
|
|
115
|
+
.command('preflight')
|
|
116
|
+
.allowExcessArguments(false)
|
|
117
|
+
.requiredOption('--kind <kind>', 'Project kind')
|
|
118
|
+
.addOption(new Option('--operation <operation>', 'Operation to check')
|
|
119
|
+
.choices([...PREFLIGHT_OPERATIONS])
|
|
120
|
+
.makeOptionMandatory())
|
|
121
|
+
.action(async (flags) => {
|
|
122
|
+
let options;
|
|
123
|
+
let configurationError;
|
|
124
|
+
try {
|
|
125
|
+
options = getOptions();
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
configurationError =
|
|
129
|
+
error instanceof Error ? error.message : String(error);
|
|
130
|
+
}
|
|
131
|
+
if (options)
|
|
132
|
+
setOutputFormat(options.output);
|
|
133
|
+
output(await runDeveloperPreflight({
|
|
134
|
+
...flags,
|
|
135
|
+
configurationError,
|
|
136
|
+
client: options?.apiKey ? new ApiClient(options) : undefined,
|
|
137
|
+
}));
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=developer-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"developer-project.js","sourceRoot":"","sources":["../../src/commands/developer-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC/E,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,0BAA0B,CAAA;AAEjC,KAAK,UAAU,aAAa,CAAC,OAAsB;IACjD,IAAI,OAAO,CAAC,GAAG;QAAE,OAAM;IACvB,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACrE,MAAM,IAAI,KAAK,CACb,qGAAqG,CACtG,CAAA;IACH,CAAC;IACD,MAAM,MAAM,GAAG,eAAe,CAAC;QAC7B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAA;IACF,IAAI,CAAC;QACH,IACE,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,+CAA+C,CAAC,CAAC;aACrE,IAAI,EAAE;aACN,WAAW,EAAE,KAAK,GAAG,EACxB,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;QAC/C,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,KAAK,EAAE,CAAA;IAChB,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,yBAAyB,CACvC,OAAgB,EAChB,UAA+B;IAE/B,MAAM,OAAO,GAAG,OAAO;SACpB,OA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AM,CAAC,KAAK,EAAE,KAA0C,EAAE,EAAE;QAC3D,IAAI,OAAkC,CAAA;QACtC,IAAI,kBAAsC,CAAA;QAC1C,IAAI,CAAC;YACH,OAAO,GAAG,UAAU,EAAE,CAAA;QACxB,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,kBAAkB;gBAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC1D,CAAC;QACD,IAAI,OAAO;YAAE,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAC5C,MAAM,CACJ,MAAM,qBAAqB,CAAC;YAC1B,GAAG,KAAK;YACR,kBAAkB;YAClB,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS;SAC7D,CAAC,CACH,CAAA;IACH,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `gsk init-genspark-code-skills` — client-side writer for the backend
|
|
3
|
+
* `/api/tool_cli/genspark-code-skills` bundle.
|
|
4
|
+
*
|
|
5
|
+
* Why client-side: an HTTP/JSON response can't materialise a file tree on the
|
|
6
|
+
* user's machine, so the server ships the genspark-code (code sandbox) skill
|
|
7
|
+
* docs as `{ name, files: [{ path, content }] }` rows and this helper writes
|
|
8
|
+
* them under `--out`. Server-served rather than baked into the npm package so
|
|
9
|
+
* newly edited skill docs reach released CLIs without a republish.
|
|
10
|
+
*
|
|
11
|
+
* Path handling re-uses `safeJoin` / `SLUG_RE` from the `skills pull` writer:
|
|
12
|
+
* both the skill name and each file path come from the server, so they are
|
|
13
|
+
* validated before any file is written (a crafted payload must not escape
|
|
14
|
+
* `--out`, and a malformed one must not leave a half-written tree).
|
|
15
|
+
*/
|
|
16
|
+
import type { CodeSkill } from '../types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Write a genspark-code skill bundle under `destDir/<skill-name>/...`.
|
|
19
|
+
* Returns the number of files written. Throws on an unsafe name/path or an
|
|
20
|
+
* empty bundle; nothing is written before the whole payload validates.
|
|
21
|
+
*/
|
|
22
|
+
export declare function writeCodeSkills(skills: CodeSkill[] | null | undefined, destDir: string): number;
|
|
23
|
+
//# sourceMappingURL=genspark-code-skills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genspark-code-skills.d.ts","sourceRoot":"","sources":["../../src/commands/genspark-code-skills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,GAAG,SAAS,EACtC,OAAO,EAAE,MAAM,GACd,MAAM,CA0BR"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `gsk init-genspark-code-skills` — client-side writer for the backend
|
|
3
|
+
* `/api/tool_cli/genspark-code-skills` bundle.
|
|
4
|
+
*
|
|
5
|
+
* Why client-side: an HTTP/JSON response can't materialise a file tree on the
|
|
6
|
+
* user's machine, so the server ships the genspark-code (code sandbox) skill
|
|
7
|
+
* docs as `{ name, files: [{ path, content }] }` rows and this helper writes
|
|
8
|
+
* them under `--out`. Server-served rather than baked into the npm package so
|
|
9
|
+
* newly edited skill docs reach released CLIs without a republish.
|
|
10
|
+
*
|
|
11
|
+
* Path handling re-uses `safeJoin` / `SLUG_RE` from the `skills pull` writer:
|
|
12
|
+
* both the skill name and each file path come from the server, so they are
|
|
13
|
+
* validated before any file is written (a crafted payload must not escape
|
|
14
|
+
* `--out`, and a malformed one must not leave a half-written tree).
|
|
15
|
+
*/
|
|
16
|
+
import * as fs from 'fs';
|
|
17
|
+
import * as path from 'path';
|
|
18
|
+
import { safeJoin, SLUG_RE } from './skills-pull.js';
|
|
19
|
+
/**
|
|
20
|
+
* Write a genspark-code skill bundle under `destDir/<skill-name>/...`.
|
|
21
|
+
* Returns the number of files written. Throws on an unsafe name/path or an
|
|
22
|
+
* empty bundle; nothing is written before the whole payload validates.
|
|
23
|
+
*/
|
|
24
|
+
export function writeCodeSkills(skills, destDir) {
|
|
25
|
+
if (!Array.isArray(skills) || skills.length === 0) {
|
|
26
|
+
throw new Error('Server returned no genspark-code skills');
|
|
27
|
+
}
|
|
28
|
+
for (const skill of skills) {
|
|
29
|
+
if (!SLUG_RE.test(skill.name)) {
|
|
30
|
+
throw new Error(`Unsafe skill name in payload: ${skill.name}`);
|
|
31
|
+
}
|
|
32
|
+
const skillDir = path.join(destDir, skill.name);
|
|
33
|
+
for (const file of skill.files) {
|
|
34
|
+
safeJoin(skillDir, file.path);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
let fileCount = 0;
|
|
38
|
+
for (const skill of skills) {
|
|
39
|
+
const skillDir = path.join(destDir, skill.name);
|
|
40
|
+
for (const file of skill.files) {
|
|
41
|
+
const destPath = safeJoin(skillDir, file.path);
|
|
42
|
+
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
43
|
+
fs.writeFileSync(destPath, file.content);
|
|
44
|
+
fileCount += 1;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return fileCount;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=genspark-code-skills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genspark-code-skills.js","sourceRoot":"","sources":["../../src/commands/genspark-code-skills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAGpD;;;;GAIG;AACH,MAA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O,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-CLI route (under `/api/tool_cli`) that streams one GenTeam attachment
|
|
3
|
+
* to a gsk-token caller — the same membership-gated lane the web and mobile
|
|
4
|
+
* clients download through. `gsk genteam download` fetches it straight into
|
|
5
|
+
* a local file instead of asking the server for a URL (#61834).
|
|
6
|
+
*/
|
|
7
|
+
export declare const GENTEAM_ATTACHMENT_ENDPOINT = "/genteam/attachment";
|
|
8
|
+
export declare function genteamAttachmentEndpoint(channelId: string, attachmentRef: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* File name carried by a Content-Disposition header. The RFC 6266
|
|
11
|
+
* `filename*=UTF-8''<pct-encoded>` form holds the full Unicode name and wins
|
|
12
|
+
* over the ASCII `filename="…"` fallback the server writes beside it. Only a
|
|
13
|
+
* basename ever comes back: the header is server data, not a path the caller
|
|
14
|
+
* chose, so it must not steer the write outside the destination directory.
|
|
15
|
+
*/
|
|
16
|
+
export declare function fileNameFromContentDisposition(header: string | null | undefined): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Destination of `gsk genteam download`: `--local_file`, else the first bare
|
|
19
|
+
* operand, else `./<file name the server reported>`. A destination naming an
|
|
20
|
+
* existing directory receives the server's file name inside it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveGenteamDownloadDestination(operands: readonly string[], localFile: string | undefined, serverFileName: string | undefined): string;
|
|
23
|
+
export interface SavedAttachment {
|
|
24
|
+
local_path: string;
|
|
25
|
+
size_bytes: number;
|
|
26
|
+
sha256: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Stream a response body to `destPath`, hashing it on the way. Nothing is
|
|
30
|
+
* buffered: GenTeam attachments reach GiB scale, and the sha256 lets the
|
|
31
|
+
* caller compare against the value `gsk genteam read` already reports.
|
|
32
|
+
*/
|
|
33
|
+
export declare function saveBodyToFile(body: NonNullable<Response['body']>, destPath: string): Promise<SavedAttachment>;
|
|
34
|
+
//# sourceMappingURL=genteam-download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genteam-download.d.ts","sourceRoot":"","sources":["../../src/commands/genteam-download.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,wBAAwB,CAAA;AAEhE,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,GACpB,MAAM,CAMR;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAChC,MAAM,GAAG,SAAS,CAepB;AAOD;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,cAAc,EAAE,MAAM,GAAG,SAAS,GACjC,MAAM,CAQR;AAWD,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EACnC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,CAAC,CAgB1B"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as pathModule from 'path';
|
|
4
|
+
import { Readable, Transform } from 'stream';
|
|
5
|
+
import { pipeline } from 'stream/promises';
|
|
6
|
+
/**
|
|
7
|
+
* Tool-CLI route (under `/api/tool_cli`) that streams one GenTeam attachment
|
|
8
|
+
* to a gsk-token caller — the same membership-gated lane the web and mobile
|
|
9
|
+
* clients download through. `gsk genteam download` fetches it straight into
|
|
10
|
+
* a local file instead of asking the server for a URL (#61834).
|
|
11
|
+
*/
|
|
12
|
+
export const GENTEAM_ATTACHMENT_ENDPOINT = '/genteam/attachment';
|
|
13
|
+
export function genteamAttachmentEndpoint(channelId, attachmentRef) {
|
|
14
|
+
const query = new URLSearchParams({
|
|
15
|
+
channel_id: channelId,
|
|
16
|
+
attachment_ref: attachmentRef,
|
|
17
|
+
});
|
|
18
|
+
return `${GENTEAM_ATTACHMENT_ENDPOINT}?${query.toString()}`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* File name carried by a Content-Disposition header. The RFC 6266
|
|
22
|
+
* `filename*=UTF-8''<pct-encoded>` form holds the full Unicode name and wins
|
|
23
|
+
* over the ASCII `filename="…"` fallback the server writes beside it. Only a
|
|
24
|
+
* basename ever comes back: the header is server data, not a path the caller
|
|
25
|
+
* chose, so it must not steer the write outside the destination directory.
|
|
26
|
+
*/
|
|
27
|
+
export function fileNameFromContentDisposition(header) {
|
|
28
|
+
if (!header)
|
|
29
|
+
return undefined;
|
|
30
|
+
const encoded = /filename\*=utf-8''([^;]+)/i.exec(header);
|
|
31
|
+
if (encoded) {
|
|
32
|
+
try {
|
|
33
|
+
const decoded = safeBasename(decodeURIComponent(encoded[1].trim()));
|
|
34
|
+
if (decoded)
|
|
35
|
+
return decoded;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// Malformed percent-encoding: fall through to the ASCII fallback.
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const quoted = /filename="([^"]*)"/.exec(header);
|
|
42
|
+
if (quoted)
|
|
43
|
+
return safeBasename(quoted[1]);
|
|
44
|
+
const bare = /filename=([^;]+)/.exec(header);
|
|
45
|
+
return bare ? safeBasename(bare[1].trim()) : undefined;
|
|
46
|
+
}
|
|
47
|
+
function safeBasename(name) {
|
|
48
|
+
const base = pathModule.basename(name.replace(/\\/g, '/'));
|
|
49
|
+
return base && base !== '.' && base !== '..' ? base : undefined;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Destination of `gsk genteam download`: `--local_file`, else the first bare
|
|
53
|
+
* operand, else `./<file name the server reported>`. A destination naming an
|
|
54
|
+
* existing directory receives the server's file name inside it.
|
|
55
|
+
*/
|
|
56
|
+
export function resolveGenteamDownloadDestination(operands, localFile, serverFileName) {
|
|
57
|
+
const fallbackName = serverFileName || 'attachment';
|
|
58
|
+
const bareOperands = operands.filter(operand => operand.length > 0 && !operand.startsWith('-'));
|
|
59
|
+
const chosen = localFile || bareOperands[0] || fallbackName;
|
|
60
|
+
if (isExistingDirectory(chosen))
|
|
61
|
+
return pathModule.join(chosen, fallbackName);
|
|
62
|
+
return chosen;
|
|
63
|
+
}
|
|
64
|
+
function isExistingDirectory(candidate) {
|
|
65
|
+
try {
|
|
66
|
+
return fs.statSync(candidate).isDirectory();
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// A destination that does not exist yet is a file path to create.
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Stream a response body to `destPath`, hashing it on the way. Nothing is
|
|
75
|
+
* buffered: GenTeam attachments reach GiB scale, and the sha256 lets the
|
|
76
|
+
* caller compare against the value `gsk genteam read` already reports.
|
|
77
|
+
*/
|
|
78
|
+
export async function saveBodyToFile(body, destPath) {
|
|
79
|
+
const hash = createHash('sha256');
|
|
80
|
+
let sizeBytes = 0;
|
|
81
|
+
const tap = new Transform({
|
|
82
|
+
transform(chunk, _encoding, callback) {
|
|
83
|
+
hash.update(chunk);
|
|
84
|
+
sizeBytes += chunk.length;
|
|
85
|
+
callback(null, chunk);
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
await pipeline(Readable.fromWeb(body), tap, fs.createWriteStream(destPath));
|
|
89
|
+
return {
|
|
90
|
+
local_path: pathModule.resolve(destPath),
|
|
91
|
+
size_bytes: sizeBytes,
|
|
92
|
+
sha256: hash.digest('hex'),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=genteam-download.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genteam-download.js","sourceRoot":"","sources":["../../src/commands/genteam-download.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,UAAU,MAAM,MAAM,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE1C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,qBAAqB,CAAA;AAEhE,MAAM,UAAU,yBAAyB,CACvC,SAAiB,EACjB,aAAqB;IAErB,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC;QAChC,UAAU,EAAE,SAAS;QACrB,cAAc,EAAE,aAAa;KAC9B,CAAC,CAAA;IACF,OAAO,GAAG,2BAA2B,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAA;AAC7D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B,CAC5C,MAAiC;IAEjC,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAA;IAC7B,MAAM,OAAO,GAAG,4BAA4B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACzD,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;YACnE,IAAI,OAAO;gBAAE,OAAO,OAAO,CAAA;QAC7B,CAAC;QAAC,MAAM,CAAC;YACP,kEAAkE;QACpE,CAAC;IACH,CAAC;IACD,MAAM,MAAM,GAAG,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAChD,IAAI,MAAM;QAA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,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAQD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,IAAmC,EACnC,QAAgB;IAEhB,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;IACjC,IAAI,SAAS,GAAG,CAAC,CAAA;IACjB,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC;QACxB,SAAS,CAAC,KAAa,EAAE,SAAS,EAAE,QAAQ;YAC1C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YAClB,SAAS,IAAI,KAAK,CAAC,MAAM,CAAA;YACzB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QACvB,CAAC;KACF,CAAC,CAAA;IACF,MAAM,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAA;IAC3E,OAAO;QACL,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC;QACxC,UAAU,EAAE,SAAS;QACrB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;KAC3B,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { GlobalOptions } from '../types.js';
|
|
3
|
+
import type { PackagedSource } from '../local-source.js';
|
|
4
|
+
/** Verify the server receipt describes the exact uploaded snapshot. */
|
|
5
|
+
export declare function validateSourceReceipt(receipt: Record<string, unknown>, source: PackagedSource, projectId: string): void;
|
|
6
|
+
/** Upload a local snapshot and submit it once to the existing approval state machine. */
|
|
7
|
+
export declare function deployLocalSource(options: GlobalOptions, sourceDirectory: string): Promise<void>;
|
|
8
|
+
/** Seed the static hosted parent so server-provided hosted commands share it. */
|
|
9
|
+
export declare function registerHostedLocalCommand(program: Command, getOptions: () => GlobalOptions): Command;
|
|
10
|
+
//# sourceMappingURL=hosted-local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-local.d.ts","sourceRoot":"","sources":["../../src/commands/hosted-local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAKxD,uEAAuE;AACvE,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,GAChB,IAAI,CAoBN;AAED,yFAAyF;AACzF,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,aAAa,EACtB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC,CAqFf;AAED,iFAAiF;AACjF,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,OAAO,CAeT"}
|