opencontext 1.0.2 → 1.0.4

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 +33 -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.4';
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,31 @@ 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 (columns = fields, one row of data)
245
+ function resultToCSV(result) {
246
+ // Helper to escape CSV values
247
+ const escape = (val) => `"${val.replace(/"/g, '""')}"`;
248
+ // Define headers and values
249
+ const headers = [];
250
+ const values = [];
251
+ // Basic fields
252
+ headers.push('Company Name', 'Website', 'Industry', 'Description', 'Target Audience', 'Brand Tone');
253
+ values.push(escape(result.company_name), escape(result.company_url), escape(result.industry), escape(result.description), escape(result.target_audience), escape(result.tone));
254
+ // Arrays as semicolon-separated
255
+ headers.push('Products', 'Competitors', 'Pain Points', 'Value Propositions', 'Use Cases', 'Content Themes');
256
+ values.push(escape(result.products?.join('; ') || ''), escape(result.competitors?.join('; ') || ''), escape(result.pain_points?.join('; ') || ''), escape(result.value_propositions?.join('; ') || ''), escape(result.use_cases?.join('; ') || ''), escape(result.content_themes?.join('; ') || ''));
257
+ // Voice persona
258
+ if (result.voice_persona) {
259
+ headers.push('ICP Profile', 'Voice Style', 'Do List', 'Dont List', 'Example Phrases');
260
+ values.push(escape(result.voice_persona.icp_profile || ''), escape(result.voice_persona.voice_style || ''), escape(result.voice_persona.do_list?.join('; ') || ''), escape(result.voice_persona.dont_list?.join('; ') || ''), escape(result.voice_persona.example_phrases?.join('; ') || ''));
261
+ }
262
+ return headers.join(',') + '\n' + values.join(',');
243
263
  }
244
264
  // Commands
245
265
  async function analyzeCommand(url, options) {
@@ -261,18 +281,22 @@ async function analyzeCommand(url, options) {
261
281
  else {
262
282
  console.log(formatAnalysisResult(result));
263
283
  }
264
- // Always save to Downloads (or custom path if specified)
284
+ // Always save to Downloads (both JSON and CSV)
265
285
  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);
286
+ const jsonPath = options.output || path.join(downloadsDir, generateFilename(result.company_name, 'json'));
287
+ const csvPath = jsonPath.replace(/\.json$/, '.csv');
288
+ const dir = path.dirname(jsonPath);
269
289
  if (!fs.existsSync(dir)) {
270
290
  fs.mkdirSync(dir, { recursive: true });
271
291
  }
272
- fs.writeFileSync(outputPath, JSON.stringify(result, null, 2));
292
+ // Save JSON
293
+ fs.writeFileSync(jsonPath, JSON.stringify(result, null, 2));
294
+ // Save CSV
295
+ fs.writeFileSync(csvPath, resultToCSV(result));
273
296
  console.log();
274
297
  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' }));
298
+ chalk_1.default.dim('JSON: ') + chalk_1.default.white(jsonPath) + '\n' +
299
+ chalk_1.default.dim('CSV: ') + chalk_1.default.white(csvPath), { padding: 1, borderColor: 'green', borderStyle: 'round' }));
276
300
  }
277
301
  catch (error) {
278
302
  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.4",
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": {