{"record":{"id":"3a787a49c8a827d9","repo":"affaan-m/ECC","slug":"ck-save-invalid-json-on-stdin-e-message","errorCode":null,"errorMessage":"ck save: invalid JSON on stdin — ${e.message}","messagePattern":"ck save: invalid JSON on stdin — (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"skills/ck/commands/save.mjs","lineNumber":37,"sourceCode":"import { readFileSync, mkdirSync, writeFileSync } from 'fs';\nimport { resolve } from 'path';\nimport {\n  readProjects, writeProjects, loadContext, saveContext,\n  today, shortId, gitSummary, nativeMemoryDir,\n  CURRENT_SESSION,\n} from './shared.mjs';\n\nconst isInit = process.argv.includes('--init');\nconst cwd    = process.env.PWD || process.cwd();\n\n// ── Read JSON from stdin ──────────────────────────────────────────────────────\nlet input;\ntry {\n  const raw = readFileSync(0, 'utf8').trim();\n  if (!raw) throw new Error('empty stdin');\n  input = JSON.parse(raw);\n} catch (e) {\n  console.error(`ck save: invalid JSON on stdin — ${e.message}`);\n  console.log('Expected schema (save):  {\"summary\":\"...\",\"leftOff\":\"...\",\"nextSteps\":[\"...\"],\"decisions\":[{\"what\":\"...\",\"why\":\"...\"}],\"blockers\":[\"...\"]}');\n  console.log('Expected schema (--init): {\"name\":\"...\",\"path\":\"...\",\"description\":\"...\",\"stack\":[\"...\"],\"goal\":\"...\",\"constraints\":[\"...\"]}');\n  process.exit(1);\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// INIT MODE: first-time project registration\n// ─────────────────────────────────────────────────────────────────────────────\nif (isInit) {\n  const { name, path: projectPath, description, stack, goal, constraints, repo } = input;\n\n  if (!name || !projectPath) {\n    console.log('ck init: name and path are required.');\n    process.exit(1);\n  }\n\n  const projects = readProjects();\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/affaan-m/ECC/blob/06c5e118c4d3e6c3b7f9445f973a2194c82de193/skills/ck/commands/save.mjs#L19-L55","documentation":"The ck save command reads a JSON document from stdin (fd 0); reading or parsing failed — including the explicit 'empty stdin' case — so there is no record to save. The parse error message is embedded.","triggerScenarios":"Triggered when save.mjs rejects the current invocation: ck save: invalid JSON on stdin — <value>","commonSituations":"Occurs while running skills/ck/commands/save.mjs with invalid arguments, missing flags, or a failing external dependency; the guard at skills/ck/commands/save.mjs:37 aborts the command with this message.","solutions":["Fix the JSON input/output so it parses; check the cited line/error detail."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"06c5e118c4d3e6c3b7f9445f973a2194c82de193","analyzedAt":"2026-08-18T11:27:13.915Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}