clikit-plugin 0.2.1 → 0.2.2

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.js +14 -5
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -44,15 +44,16 @@ function ensureConfigDir() {
44
44
  function parseConfig(configPath) {
45
45
  try {
46
46
  if (!fs.existsSync(configPath)) {
47
- return {};
47
+ return { config: {}, raw: "", parseError: null };
48
48
  }
49
49
  const content = fs.readFileSync(configPath, "utf-8");
50
50
  const cleaned = content.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
51
51
  const cleanedTrailing = cleaned.replace(/,\s*([}\]])/g, "$1");
52
- return JSON.parse(cleanedTrailing);
52
+ const parsed = JSON.parse(cleanedTrailing);
53
+ return { config: parsed, raw: content, parseError: null };
53
54
  } catch (err) {
54
- console.error(`Warning: Failed to parse config at ${configPath}: ${err}`);
55
- return {};
55
+ const raw = fs.existsSync(configPath) ? fs.readFileSync(configPath, "utf-8") : "";
56
+ return { config: {}, raw, parseError: String(err) };
56
57
  }
57
58
  }
58
59
  function backupConfig(configPath) {
@@ -93,7 +94,15 @@ async function install() {
93
94
  if (backupPath) {
94
95
  console.log(` Backup created: ${backupPath}`);
95
96
  }
96
- const config = parseConfig(configPath);
97
+ const result = parseConfig(configPath);
98
+ if (result.parseError && result.raw.trim()) {
99
+ console.error(`\u2717 Config file has syntax errors and cannot be safely modified.`);
100
+ console.error(` Error: ${result.parseError}`);
101
+ console.error(` Please fix the config file manually or restore from backup.`);
102
+ console.error(` Backup: ${backupPath}`);
103
+ return 1;
104
+ }
105
+ const config = result.config;
97
106
  const existingPlugins = Array.isArray(config.plugin) ? config.plugin : [];
98
107
  const preservedKeys = Object.keys(config).filter((k) => k !== "plugin");
99
108
  if (preservedKeys.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clikit-plugin",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "OpenCode plugin with 10 agents, 19 commands, 48 skills, 14 hooks",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",