opencontext 1.0.2 → 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.
Files changed (2) hide show
  1. package/dist/cli/index.js +62 -9
  2. 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.2';
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
@@ -235,11 +235,60 @@ function getDownloadsPath() {
235
235
  return path.join(os.homedir(), 'Downloads');
236
236
  }
237
237
  // Generate filename from company name
238
- function generateFilename(companyName) {
238
+ function generateFilename(companyName, ext = 'json') {
239
239
  return companyName
240
240
  .toLowerCase()
241
241
  .replace(/[^a-z0-9]+/g, '-')
242
- .replace(/^-|-$/g, '') + '-context.json';
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');
243
292
  }
244
293
  // Commands
245
294
  async function analyzeCommand(url, options) {
@@ -261,18 +310,22 @@ async function analyzeCommand(url, options) {
261
310
  else {
262
311
  console.log(formatAnalysisResult(result));
263
312
  }
264
- // Always save to Downloads (or custom path if specified)
313
+ // Always save to Downloads (both JSON and CSV)
265
314
  const downloadsDir = getDownloadsPath();
266
- const filename = generateFilename(result.company_name);
267
- const outputPath = options.output || path.join(downloadsDir, filename);
268
- const dir = path.dirname(outputPath);
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);
269
318
  if (!fs.existsSync(dir)) {
270
319
  fs.mkdirSync(dir, { recursive: true });
271
320
  }
272
- fs.writeFileSync(outputPath, JSON.stringify(result, null, 2));
321
+ // Save JSON
322
+ fs.writeFileSync(jsonPath, JSON.stringify(result, null, 2));
323
+ // Save CSV
324
+ fs.writeFileSync(csvPath, resultToCSV(result));
273
325
  console.log();
274
326
  console.log((0, boxen_1.default)(chalk_1.default.green.bold('Saved!') + '\n\n' +
275
- chalk_1.default.dim('File: ') + chalk_1.default.white(outputPath), { padding: 1, borderColor: 'green', borderStyle: 'round' }));
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' }));
276
329
  }
277
330
  catch (error) {
278
331
  spinner.fail('Analysis failed');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencontext",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "AI-powered company context analysis from your terminal. Extract comprehensive company profiles with a single command.",
5
5
  "main": "dist/cli/index.js",
6
6
  "bin": {