   constructor: ->
     @startServer()
 
-  runCmd: (str) ->
+  runCmd: (cmd) ->
     return new Promise (resolve,reject) =>
       command = @pscIde
       args = ['-p', @pscIdePort]
       stdout = (output) =>
-        console.debug "psc-ide", str, "-->", output
-        resolve (@trimQuote output).trim()
+        try
+          output = JSON.parse output
+        console.debug "psc-ide", cmd, "-->", output
+        resolve output
       exit = (code) =>
         console.debug "exited with code #{code}"
         reject code if code is not 0
       bp = new BufferedProcess({command,args,stdout,exit})
-      bp.process.stdin.write str + '\n'
+      bp.process.stdin.write JSON.stringify(cmd) + '\n'
 
   startServer: ->
     # should watch these and restart

        @getCompletion(prefix,@editors.activeModules)
          .then (completions) =>
            resolve completions.map (c) =>
              text: c.ident
              displayText: c.ident + ": " + @abbrevType c.type
              description: c.type
              type: if /->/.test(c.type) then "function" else "value"


  loadDeps: (editor) ->
    res = XRegExp.exec(editor.getText(), /^module (\S+) where/)
    if res
      @runCmd
        command: "load"
        params:
          dependencies: [res[1]]
    else
      Promise.resolve()

