opencontext 1.0.1 → 1.0.3
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/dist/cli/index.js +80 -40
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -49,7 +49,7 @@ const boxen_1 = __importDefault(require("boxen"));
|
|
|
49
49
|
const fs = __importStar(require("fs"));
|
|
50
50
|
const path = __importStar(require("path"));
|
|
51
51
|
const os = __importStar(require("os"));
|
|
52
|
-
const VERSION = '1.0.
|
|
52
|
+
const VERSION = '1.0.3';
|
|
53
53
|
const CONFIG_DIR = path.join(os.homedir(), '.opencontext');
|
|
54
54
|
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
55
55
|
// ASCII Logo
|
|
@@ -230,6 +230,66 @@ function formatAnalysisResult(result) {
|
|
|
230
230
|
sections.push(chalk_1.default.cyan('═══════════════════════════════════════════════════════════════\n'));
|
|
231
231
|
return sections.join('\n');
|
|
232
232
|
}
|
|
233
|
+
// Get Downloads folder path
|
|
234
|
+
function getDownloadsPath() {
|
|
235
|
+
return path.join(os.homedir(), 'Downloads');
|
|
236
|
+
}
|
|
237
|
+
// Generate filename from company name
|
|
238
|
+
function generateFilename(companyName, ext = 'json') {
|
|
239
|
+
return companyName
|
|
240
|
+
.toLowerCase()
|
|
241
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
242
|
+
.replace(/^-|-$/g, '') + `-context.${ext}`;
|
|
243
|
+
}
|
|
244
|
+
// Convert result to CSV format
|
|
245
|
+
function resultToCSV(result) {
|
|
246
|
+
const rows = [];
|
|
247
|
+
// Header
|
|
248
|
+
rows.push('Field,Value');
|
|
249
|
+
// Helper to escape CSV values
|
|
250
|
+
const escape = (val) => `"${val.replace(/"/g, '""')}"`;
|
|
251
|
+
// Basic fields
|
|
252
|
+
rows.push(`Company Name,${escape(result.company_name)}`);
|
|
253
|
+
rows.push(`Website,${escape(result.company_url)}`);
|
|
254
|
+
rows.push(`Industry,${escape(result.industry)}`);
|
|
255
|
+
rows.push(`Description,${escape(result.description)}`);
|
|
256
|
+
rows.push(`Target Audience,${escape(result.target_audience)}`);
|
|
257
|
+
rows.push(`Brand Tone,${escape(result.tone)}`);
|
|
258
|
+
// Arrays as semicolon-separated
|
|
259
|
+
if (result.products?.length) {
|
|
260
|
+
rows.push(`Products,${escape(result.products.join('; '))}`);
|
|
261
|
+
}
|
|
262
|
+
if (result.competitors?.length) {
|
|
263
|
+
rows.push(`Competitors,${escape(result.competitors.join('; '))}`);
|
|
264
|
+
}
|
|
265
|
+
if (result.pain_points?.length) {
|
|
266
|
+
rows.push(`Pain Points,${escape(result.pain_points.join('; '))}`);
|
|
267
|
+
}
|
|
268
|
+
if (result.value_propositions?.length) {
|
|
269
|
+
rows.push(`Value Propositions,${escape(result.value_propositions.join('; '))}`);
|
|
270
|
+
}
|
|
271
|
+
if (result.use_cases?.length) {
|
|
272
|
+
rows.push(`Use Cases,${escape(result.use_cases.join('; '))}`);
|
|
273
|
+
}
|
|
274
|
+
if (result.content_themes?.length) {
|
|
275
|
+
rows.push(`Content Themes,${escape(result.content_themes.join('; '))}`);
|
|
276
|
+
}
|
|
277
|
+
// Voice persona
|
|
278
|
+
if (result.voice_persona) {
|
|
279
|
+
rows.push(`ICP Profile,${escape(result.voice_persona.icp_profile)}`);
|
|
280
|
+
rows.push(`Voice Style,${escape(result.voice_persona.voice_style)}`);
|
|
281
|
+
if (result.voice_persona.do_list?.length) {
|
|
282
|
+
rows.push(`Do List,${escape(result.voice_persona.do_list.join('; '))}`);
|
|
283
|
+
}
|
|
284
|
+
if (result.voice_persona.dont_list?.length) {
|
|
285
|
+
rows.push(`Dont List,${escape(result.voice_persona.dont_list.join('; '))}`);
|
|
286
|
+
}
|
|
287
|
+
if (result.voice_persona.example_phrases?.length) {
|
|
288
|
+
rows.push(`Example Phrases,${escape(result.voice_persona.example_phrases.join('; '))}`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return rows.join('\n');
|
|
292
|
+
}
|
|
233
293
|
// Commands
|
|
234
294
|
async function analyzeCommand(url, options) {
|
|
235
295
|
const config = loadConfig();
|
|
@@ -250,16 +310,22 @@ async function analyzeCommand(url, options) {
|
|
|
250
310
|
else {
|
|
251
311
|
console.log(formatAnalysisResult(result));
|
|
252
312
|
}
|
|
253
|
-
//
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
fs.writeFileSync(outputPath, JSON.stringify(result, null, 2));
|
|
261
|
-
printSuccess(`Saved to ${outputPath}`);
|
|
313
|
+
// Always save to Downloads (both JSON and CSV)
|
|
314
|
+
const downloadsDir = getDownloadsPath();
|
|
315
|
+
const jsonPath = options.output || path.join(downloadsDir, generateFilename(result.company_name, 'json'));
|
|
316
|
+
const csvPath = jsonPath.replace(/\.json$/, '.csv');
|
|
317
|
+
const dir = path.dirname(jsonPath);
|
|
318
|
+
if (!fs.existsSync(dir)) {
|
|
319
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
262
320
|
}
|
|
321
|
+
// Save JSON
|
|
322
|
+
fs.writeFileSync(jsonPath, JSON.stringify(result, null, 2));
|
|
323
|
+
// Save CSV
|
|
324
|
+
fs.writeFileSync(csvPath, resultToCSV(result));
|
|
325
|
+
console.log();
|
|
326
|
+
console.log((0, boxen_1.default)(chalk_1.default.green.bold('Saved!') + '\n\n' +
|
|
327
|
+
chalk_1.default.dim('JSON: ') + chalk_1.default.white(jsonPath) + '\n' +
|
|
328
|
+
chalk_1.default.dim('CSV: ') + chalk_1.default.white(csvPath), { padding: 1, borderColor: 'green', borderStyle: 'round' }));
|
|
263
329
|
}
|
|
264
330
|
catch (error) {
|
|
265
331
|
spinner.fail('Analysis failed');
|
|
@@ -304,7 +370,7 @@ async function batchCommand(inputFile, options) {
|
|
|
304
370
|
console.log((0, boxen_1.default)(chalk_1.default.white.bold(`Batch Analysis\n\n`) +
|
|
305
371
|
chalk_1.default.dim(`Found ${chalk_1.default.cyan(urls.length.toString())} URLs to analyze`), { padding: 1, borderColor: 'cyan', borderStyle: 'round' }));
|
|
306
372
|
console.log();
|
|
307
|
-
const outputDir = options.outputDir ||
|
|
373
|
+
const outputDir = options.outputDir || path.join(getDownloadsPath(), 'opencontext-reports');
|
|
308
374
|
if (!fs.existsSync(outputDir)) {
|
|
309
375
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
310
376
|
}
|
|
@@ -430,28 +496,8 @@ async function interactiveMode() {
|
|
|
430
496
|
validate: (input) => input.trim().length > 0 || 'URL is required'
|
|
431
497
|
}
|
|
432
498
|
]);
|
|
433
|
-
const { saveToFile } = await inquirer_1.default.prompt([
|
|
434
|
-
{
|
|
435
|
-
type: 'confirm',
|
|
436
|
-
name: 'saveToFile',
|
|
437
|
-
message: 'Save result to file?',
|
|
438
|
-
default: true
|
|
439
|
-
}
|
|
440
|
-
]);
|
|
441
|
-
let outputPath;
|
|
442
|
-
if (saveToFile) {
|
|
443
|
-
const { path: outPath } = await inquirer_1.default.prompt([
|
|
444
|
-
{
|
|
445
|
-
type: 'input',
|
|
446
|
-
name: 'path',
|
|
447
|
-
message: 'Output file path:',
|
|
448
|
-
default: './context-report.json'
|
|
449
|
-
}
|
|
450
|
-
]);
|
|
451
|
-
outputPath = outPath;
|
|
452
|
-
}
|
|
453
499
|
console.log();
|
|
454
|
-
await analyzeCommand(url.trim(), {
|
|
500
|
+
await analyzeCommand(url.trim(), {});
|
|
455
501
|
break;
|
|
456
502
|
}
|
|
457
503
|
case 'batch': {
|
|
@@ -462,22 +508,16 @@ async function interactiveMode() {
|
|
|
462
508
|
console.log(chalk_1.default.dim(' Supported formats: .json, .csv, .txt (one URL per line)'));
|
|
463
509
|
break;
|
|
464
510
|
}
|
|
465
|
-
const { inputFile
|
|
511
|
+
const { inputFile } = await inquirer_1.default.prompt([
|
|
466
512
|
{
|
|
467
513
|
type: 'list',
|
|
468
514
|
name: 'inputFile',
|
|
469
515
|
message: 'Select input file:',
|
|
470
516
|
choices: files
|
|
471
|
-
},
|
|
472
|
-
{
|
|
473
|
-
type: 'input',
|
|
474
|
-
name: 'outputDir',
|
|
475
|
-
message: 'Output directory:',
|
|
476
|
-
default: config.outputDir || './context-reports'
|
|
477
517
|
}
|
|
478
518
|
]);
|
|
479
519
|
console.log();
|
|
480
|
-
await batchCommand(inputFile, {
|
|
520
|
+
await batchCommand(inputFile, {});
|
|
481
521
|
break;
|
|
482
522
|
}
|
|
483
523
|
case 'config':
|
package/package.json
CHANGED