@vibemastery/zurf 0.2.3 → 0.3.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 +69 -17
- package/dist/commands/ask/index.d.ts +17 -0
- package/dist/commands/ask/index.js +102 -0
- package/dist/commands/browse/index.js +2 -2
- package/dist/commands/config/which.js +51 -44
- package/dist/commands/fetch/index.js +1 -1
- package/dist/commands/search/index.js +1 -1
- package/dist/commands/setup/index.d.ts +14 -0
- package/dist/commands/setup/index.js +123 -0
- package/dist/lib/browserbase-client.js +1 -1
- package/dist/lib/config.d.ts +22 -1
- package/dist/lib/config.js +91 -19
- package/dist/lib/perplexity-client.d.ts +33 -0
- package/dist/lib/perplexity-client.js +59 -0
- package/dist/lib/setup-prompts.d.ts +10 -0
- package/dist/lib/setup-prompts.js +34 -0
- package/oclif.manifest.json +157 -102
- package/package.json +4 -3
- package/dist/commands/init/index.d.ts +0 -18
- package/dist/commands/init/index.js +0 -116
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibemastery/zurf",
|
|
3
3
|
"description": "A lightweight CLI for searching and fetching web pages, powered by Browserbase.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"author": "Luis Güette",
|
|
6
6
|
"bin": {
|
|
7
7
|
"zurf": "./bin/run.js"
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"bugs": "https://github.com/vibemastery/zurf/issues",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@browserbasehq/sdk": "^2.9.0",
|
|
12
|
+
"@inquirer/prompts": "^8.3.2",
|
|
12
13
|
"@oclif/core": "^4",
|
|
13
14
|
"@oclif/plugin-autocomplete": "^3.2.42",
|
|
14
15
|
"@oclif/plugin-help": "^6",
|
|
@@ -73,8 +74,8 @@
|
|
|
73
74
|
"config": {
|
|
74
75
|
"description": "Inspect zurf configuration"
|
|
75
76
|
},
|
|
76
|
-
"
|
|
77
|
-
"description": "Configure Browserbase
|
|
77
|
+
"setup": {
|
|
78
|
+
"description": "Configure API keys for Browserbase and Perplexity"
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
},
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
|
-
export default class Init extends Command {
|
|
3
|
-
static description: string;
|
|
4
|
-
static examples: string[];
|
|
5
|
-
static flags: {
|
|
6
|
-
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
-
gitignore: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
-
global: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
-
local: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
-
'project-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
html: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
-
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
-
};
|
|
14
|
-
static summary: string;
|
|
15
|
-
run(): Promise<void>;
|
|
16
|
-
private readApiKeyForInit;
|
|
17
|
-
private readProjectIdForInit;
|
|
18
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { Command, Flags } from '@oclif/core';
|
|
2
|
-
import * as fs from 'node:fs/promises';
|
|
3
|
-
import { cliError, errorMessage } from '../../lib/cli-errors.js';
|
|
4
|
-
import { globalConfigFilePath, localConfigPathForCwd, writeConfig } from '../../lib/config.js';
|
|
5
|
-
import { zurfBaseFlags } from '../../lib/flags.js';
|
|
6
|
-
import { dotGitignoreMentionsZurf, ensureZurfGitignoreEntry, gitignorePathForCwd, } from '../../lib/gitignore-zurf.js';
|
|
7
|
-
import { promptLine, readStdinIfPiped } from '../../lib/init-input.js';
|
|
8
|
-
import { printJson } from '../../lib/json-output.js';
|
|
9
|
-
export default class Init extends Command {
|
|
10
|
-
static description = `Save your Browserbase API key and optional Project ID to global or project config.
|
|
11
|
-
Global path follows oclif config (same as \`zurf config which\`).`;
|
|
12
|
-
static examples = [
|
|
13
|
-
'<%= config.bin %> <%= command.id %> --global',
|
|
14
|
-
'<%= config.bin %> <%= command.id %> --local',
|
|
15
|
-
'<%= config.bin %> <%= command.id %> --global --api-key KEY --project-id PROJ_ID',
|
|
16
|
-
'printenv BROWSERBASE_API_KEY | <%= config.bin %> <%= command.id %> --global',
|
|
17
|
-
];
|
|
18
|
-
static flags = {
|
|
19
|
-
...zurfBaseFlags,
|
|
20
|
-
'api-key': Flags.string({
|
|
21
|
-
description: 'API key for non-interactive use. Prefer piping stdin or using a TTY prompt — values on the command line are visible in shell history and process listings.',
|
|
22
|
-
}),
|
|
23
|
-
gitignore: Flags.boolean({
|
|
24
|
-
description: 'Append .zurf/ to ./.gitignore if that entry is missing',
|
|
25
|
-
}),
|
|
26
|
-
global: Flags.boolean({
|
|
27
|
-
description: 'Store API key in user config (oclif config dir for this CLI)',
|
|
28
|
-
exactlyOne: ['global', 'local'],
|
|
29
|
-
}),
|
|
30
|
-
local: Flags.boolean({
|
|
31
|
-
description: 'Store API key in ./.zurf/config.json for this directory',
|
|
32
|
-
exactlyOne: ['global', 'local'],
|
|
33
|
-
}),
|
|
34
|
-
'project-id': Flags.string({
|
|
35
|
-
description: 'Browserbase Project ID (optional; needed for browse, screenshot, pdf commands)',
|
|
36
|
-
}),
|
|
37
|
-
};
|
|
38
|
-
static summary = 'Configure Browserbase API key and Project ID storage';
|
|
39
|
-
async run() {
|
|
40
|
-
const { flags } = await this.parse(Init);
|
|
41
|
-
const apiKey = await this.readApiKeyForInit(flags);
|
|
42
|
-
const targetPath = flags.global
|
|
43
|
-
? globalConfigFilePath(this.config.configDir)
|
|
44
|
-
: localConfigPathForCwd();
|
|
45
|
-
const projectId = await this.readProjectIdForInit(flags);
|
|
46
|
-
const configUpdate = { apiKey: apiKey.trim() };
|
|
47
|
-
if (projectId)
|
|
48
|
-
configUpdate.projectId = projectId;
|
|
49
|
-
try {
|
|
50
|
-
await writeConfig(targetPath, configUpdate);
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
cliError({ command: this, exitCode: 1, json: flags.json, message: errorMessage(error) });
|
|
54
|
-
}
|
|
55
|
-
if (flags.gitignore) {
|
|
56
|
-
try {
|
|
57
|
-
await ensureZurfGitignoreEntry(gitignorePathForCwd());
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
cliError({ command: this, exitCode: 1, json: flags.json, message: errorMessage(error) });
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (flags.json) {
|
|
64
|
-
const payload = { ok: true, path: targetPath, scope: flags.global ? 'global' : 'local' };
|
|
65
|
-
if (projectId)
|
|
66
|
-
payload.projectId = true;
|
|
67
|
-
printJson(payload);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.log(`Saved API key to ${targetPath}`);
|
|
71
|
-
if (projectId) {
|
|
72
|
-
this.log(`Saved Project ID to ${targetPath}`);
|
|
73
|
-
}
|
|
74
|
-
if (flags.local) {
|
|
75
|
-
let showTip = true;
|
|
76
|
-
try {
|
|
77
|
-
const gi = await fs.readFile(gitignorePathForCwd(), 'utf8');
|
|
78
|
-
if (dotGitignoreMentionsZurf(gi)) {
|
|
79
|
-
showTip = false;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
// no .gitignore yet
|
|
84
|
-
}
|
|
85
|
-
if (showTip) {
|
|
86
|
-
this.log('Tip: add .zurf/ to .gitignore so the key is not committed (or run with --gitignore).');
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
async readApiKeyForInit(flags) {
|
|
92
|
-
let apiKey = flags['api-key']?.trim();
|
|
93
|
-
if (!apiKey) {
|
|
94
|
-
apiKey = await readStdinIfPiped();
|
|
95
|
-
}
|
|
96
|
-
if (!apiKey && process.stdin.isTTY) {
|
|
97
|
-
apiKey = await promptLine('Browserbase API key: ');
|
|
98
|
-
}
|
|
99
|
-
if (!apiKey) {
|
|
100
|
-
cliError({
|
|
101
|
-
command: this,
|
|
102
|
-
exitCode: 2,
|
|
103
|
-
json: flags.json,
|
|
104
|
-
message: 'No API key provided. Pipe stdin, use --api-key, or run interactively in a TTY.',
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
return apiKey;
|
|
108
|
-
}
|
|
109
|
-
async readProjectIdForInit(flags) {
|
|
110
|
-
let projectId = flags['project-id']?.trim();
|
|
111
|
-
if (!projectId && !flags.json && process.stdin.isTTY) {
|
|
112
|
-
projectId = await promptLine('Browserbase Project ID (optional, press Enter to skip): ');
|
|
113
|
-
}
|
|
114
|
-
return projectId || undefined;
|
|
115
|
-
}
|
|
116
|
-
}
|