opencode-arise 0.1.0 → 0.1.1

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.
Binary file
Binary file
package/dist/cli/index.js CHANGED
@@ -36,13 +36,88 @@ function findOpencodeConfig() {
36
36
  return null;
37
37
  }
38
38
  function parseJsonc(content) {
39
- let cleaned = content.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/,(\s*[}\]])/g, "$1");
40
- return JSON.parse(cleaned);
39
+ let result = "";
40
+ let inString = false;
41
+ let inSingleLineComment = false;
42
+ let inMultiLineComment = false;
43
+ let i = 0;
44
+ while (i < content.length) {
45
+ const char = content[i];
46
+ const nextChar = content[i + 1];
47
+ if (inSingleLineComment) {
48
+ if (char === `
49
+ `) {
50
+ inSingleLineComment = false;
51
+ result += char;
52
+ }
53
+ i++;
54
+ continue;
55
+ }
56
+ if (inMultiLineComment) {
57
+ if (char === "*" && nextChar === "/") {
58
+ inMultiLineComment = false;
59
+ i += 2;
60
+ continue;
61
+ }
62
+ i++;
63
+ continue;
64
+ }
65
+ if (inString) {
66
+ result += char;
67
+ if (char === "\\") {
68
+ result += nextChar ?? "";
69
+ i += 2;
70
+ continue;
71
+ }
72
+ if (char === '"') {
73
+ inString = false;
74
+ }
75
+ i++;
76
+ continue;
77
+ }
78
+ if (char === '"') {
79
+ inString = true;
80
+ result += char;
81
+ i++;
82
+ continue;
83
+ }
84
+ if (char === "/" && nextChar === "/") {
85
+ inSingleLineComment = true;
86
+ i += 2;
87
+ continue;
88
+ }
89
+ if (char === "/" && nextChar === "*") {
90
+ inMultiLineComment = true;
91
+ i += 2;
92
+ continue;
93
+ }
94
+ result += char;
95
+ i++;
96
+ }
97
+ result = result.replace(/,(\s*[}\]])/g, "$1");
98
+ return JSON.parse(result);
41
99
  }
42
100
  function addPluginToConfig(configPath) {
101
+ let content;
102
+ try {
103
+ content = readFileSync(configPath, "utf-8");
104
+ } catch (err) {
105
+ console.error(`\u2717 Failed to read config file: ${configPath}`);
106
+ console.error(` Error: ${err instanceof Error ? err.message : err}`);
107
+ return false;
108
+ }
109
+ let config;
110
+ try {
111
+ config = parseJsonc(content);
112
+ } catch (err) {
113
+ console.error(`\u2717 Failed to parse config file: ${configPath}`);
114
+ console.error(` Error: ${err instanceof Error ? err.message : err}`);
115
+ console.error(`
116
+ Your config file may have invalid JSON syntax.`);
117
+ console.error(` You can manually add "${PLUGIN_NAME}" to the "plugin" array.`);
118
+ return false;
119
+ }
43
120
  try {
44
- const content = readFileSync(configPath, "utf-8");
45
- const config = parseJsonc(content);
46
121
  if (!config.plugin) {
47
122
  config.plugin = [];
48
123
  }
@@ -69,7 +144,6 @@ function createDefaultAriseConfig() {
69
144
  return;
70
145
  }
71
146
  const defaultConfig = {
72
- $schema: "https://raw.githubusercontent.com/your-repo/opencode-arise/main/assets/opencode-arise.schema.json",
73
147
  show_banner: true,
74
148
  disabled_shadows: [],
75
149
  disabled_hooks: []
@@ -134,7 +208,7 @@ function doctor() {
134
208
  console.log(` Run: bunx ${PLUGIN_NAME} install`);
135
209
  }
136
210
  } catch (err) {
137
- console.log(`\u2717 Failed to read config:`, err);
211
+ console.log(`\u2717 Failed to read config:`, err instanceof Error ? err.message : err);
138
212
  }
139
213
  const ariseConfigPath = join(process.env.HOME ?? "", ".config/opencode/opencode-arise.json");
140
214
  if (existsSync(ariseConfigPath)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-arise",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Solo Leveling themed orchestrator harness for OpenCode - Arise, Shadow Army!",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",