<commit_before>var readline = require('readline'),
    path = require('path'),
    fs = require('fs'),
    IM = require('./index.js');

var CLI = function(idFile) {
  this.id = null; // The user's profile (nickname and keypair).
  this.rl = null; // Readline interface.
  this.session = null; // Instance of the IM.
  this.nicks = {};
  this.idFile = idFile || './id.json';
};

CLI.prototype.run = function() {
  this.rl = readline.createInterface(process.stdin, process.stdout, null);

  if (fs.existsSync(this.idFile)) {
    this.id = require(path.resolve(this.idFile));
    this.connect();
  } else {
    this.createId(this.connect.bind(this));
  }
};

CLI.prototype.createId = function(callback) {
  IM.genkey(function(err, key){
    if (err) {
      return cmds.quit(err);
    }

    this.id = key;

    this.rl.question('nickname? ', function(nick) {
      this.id.nick = nick;

      fs.writeFileSync(this.idFile, JSON.stringify(this.id, null, 4));
      callback();
    });
  });
};

CLI.prototype.connect = function() {
  // Register input handler and set up the prompt.
  this.rl.on('line', this.didReadLine.bind(this));
  this.rl.setPrompt(this.id.nick + "> ");
  this.rl.prompt();

  var seeds = require(__dirname + '/../seeds.json');

  this.session = IM.connect(this.id, seeds, this.didConnect.bind(this));
  this.session.on('message', this.didReceiveMessage.bind(this));
}

CLI.prototype.didReadLine = function(line) {
  var isCommand = line.indexOf('/') == 0;

  if (isCommand) {
    this.didReadCommand(line);
  } else {
    this.didReadMessage(line);
  }
<commit_msg>Fix profile creation<commit_after>var readline = require('readline'),
    path = require('path'),
    fs = require('fs'),
    IM = require('./index.js');

var CLI = function(idFile) {
  this.id = null; // The user's profile (nickname and keypair).
  this.rl = null; // Readline interface.
  this.session = null; // Instance of the IM.
  this.nicks = {};
  this.idFile = idFile || './id.json';
};

CLI.prototype.run = function() {
  this.rl = readline.createInterface(process.stdin, process.stdout, null);

  if (fs.existsSync(this.idFile)) {
    this.id = require(path.resolve(this.idFile));
    this.connect();
  } else {
    this.createId(this.connect.bind(this));
  }
};

CLI.prototype.createId = function(callback) {
  IM.genkey(function(err, key){
    if (err) {
      return cmds.quit(err);
    }

    this.id = key;

    this.rl.question('nickname? ', function(nick) {
      this.id.nick = nick;

      fs.writeFileSync(this.idFile, JSON.stringify(this.id, null, 4));
      callback();
    }.bind(this));
  }.bind(this));
};

CLI.prototype.connect = function() {
  // Register input handler and set up the prompt.
  this.rl.on('line', this.didReadLine.bind(this));
  this.rl.setPrompt(this.id.nick + "> ");
  this.rl.prompt();

  var seeds = require(__dirname + '/../seeds.json');

  this.session = IM.connect(this.id, seeds, this.didConnect.bind(this));
  this.session.on('message', this.didReceiveMessage.bind(this));
}

CLI.prototype.didReadLine = function(line) {
  var isCommand = line.indexOf('/') == 0;

  if (isCommand) {
    this.didReadCommand(line);
  } else {
    this.didReadMessage(line);
  }

{'fraction_non_alphanumeric': 0.1806814629571741, 'fraction_numerical': 0.0012503907471084713, 'mean_word_length': 3.28380187416332, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6286586', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1100, 'n_words': 206}