opencode-akane 0.1.2 → 0.1.3

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.
package/README.md CHANGED
@@ -65,12 +65,14 @@ For package-based installation, publish this repository to npm and add it to the
65
65
  "$schema": "https://opencode.ai/config.json",
66
66
  "plugin": [
67
67
  "oh-my-opencode@latest",
68
- "opencode-akane@0.1.0"
68
+ "opencode-akane@latest"
69
69
  ]
70
70
  }
71
71
  ```
72
72
 
73
73
  Akane still reads its runtime config from `~/.config/opencode/akane.json`.
74
+ If that file does not exist yet, the plugin now bootstraps it automatically on first load with the default config.
75
+ You only need to edit it when you want to override the default role or artifact settings.
74
76
 
75
77
  ## Publish flow
76
78
 
package/dist/config.d.ts CHANGED
@@ -3,7 +3,7 @@ type DeepPartial<T> = {
3
3
  [K in keyof T]?: T[K] extends Array<infer U> ? U[] : T[K] extends Record<string, unknown> ? DeepPartial<T[K]> : T[K];
4
4
  };
5
5
  export declare function expandHome(inputPath: string): string;
6
- export declare function defaultAkaneConfig(): AkaneConfig;
6
+ export declare function defaultAkaneConfig(configPath?: string): AkaneConfig;
7
7
  export declare function mergeAkaneConfig(base: AkaneConfig, overrides: DeepPartial<AkaneConfig>): AkaneConfig;
8
8
  export declare function loadAkaneConfig(configPath?: string): Promise<LoadedAkaneConfig>;
9
9
  export {};
package/dist/config.js CHANGED
@@ -1,4 +1,4 @@
1
- import { readFile } from "node:fs/promises";
1
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
4
  import { AKANE_SERVICE_NAME, AKANE_STAGE_IDS, DEFAULT_ARTIFACT_DIR, DEFAULT_GLOBAL_CONFIG_PATH, DEFAULT_PLUGIN_OUTPUT_PATH, DEFAULT_ROLE_MODELS, DEFAULT_STAGE_FILES, DEFAULT_STAGE_ORDER, DEFAULT_STATE_FILE, } from "./constants.js";
@@ -14,12 +14,35 @@ export function expandHome(inputPath) {
14
14
  }
15
15
  return inputPath;
16
16
  }
17
- export function defaultAkaneConfig() {
17
+ function formatAkaneConfig(config) {
18
+ return `${JSON.stringify(config, null, 2)}\n`;
19
+ }
20
+ async function readAkaneConfigFile(filePath) {
21
+ const raw = await readFile(filePath, "utf8");
22
+ return parseJsonFile(raw, filePath);
23
+ }
24
+ async function bootstrapAkaneConfigFile(filePath, config) {
25
+ await mkdir(path.dirname(filePath), { recursive: true });
26
+ try {
27
+ await writeFile(filePath, formatAkaneConfig(config), {
28
+ encoding: "utf8",
29
+ flag: "wx",
30
+ });
31
+ return true;
32
+ }
33
+ catch (error) {
34
+ if (error.code === "EEXIST") {
35
+ return false;
36
+ }
37
+ throw error;
38
+ }
39
+ }
40
+ export function defaultAkaneConfig(configPath = DEFAULT_GLOBAL_CONFIG_PATH) {
18
41
  return {
19
42
  version: 1,
20
43
  serviceName: AKANE_SERVICE_NAME,
21
44
  pluginOutputPath: DEFAULT_PLUGIN_OUTPUT_PATH,
22
- globalConfigPath: DEFAULT_GLOBAL_CONFIG_PATH,
45
+ globalConfigPath: configPath,
23
46
  artifacts: {
24
47
  dir: DEFAULT_ARTIFACT_DIR,
25
48
  stateFile: DEFAULT_STATE_FILE,
@@ -109,10 +132,9 @@ export function mergeAkaneConfig(base, overrides) {
109
132
  }
110
133
  export async function loadAkaneConfig(configPath = process.env.AKANE_CONFIG_PATH ?? DEFAULT_GLOBAL_CONFIG_PATH) {
111
134
  const resolvedPath = expandHome(configPath);
112
- const defaults = defaultAkaneConfig();
135
+ const defaults = defaultAkaneConfig(configPath);
113
136
  try {
114
- const raw = await readFile(resolvedPath, "utf8");
115
- const parsed = parseJsonFile(raw, resolvedPath);
137
+ const parsed = await readAkaneConfigFile(resolvedPath);
116
138
  return {
117
139
  path: resolvedPath,
118
140
  exists: true,
@@ -121,11 +143,33 @@ export async function loadAkaneConfig(configPath = process.env.AKANE_CONFIG_PATH
121
143
  }
122
144
  catch (error) {
123
145
  if (error.code === "ENOENT") {
124
- return {
125
- path: resolvedPath,
126
- exists: false,
127
- config: defaults,
128
- };
146
+ try {
147
+ const created = await bootstrapAkaneConfigFile(resolvedPath, defaults);
148
+ if (!created) {
149
+ const parsed = await readAkaneConfigFile(resolvedPath);
150
+ return {
151
+ path: resolvedPath,
152
+ exists: true,
153
+ config: mergeAkaneConfig(defaults, parsed),
154
+ };
155
+ }
156
+ return {
157
+ path: resolvedPath,
158
+ exists: true,
159
+ config: defaults,
160
+ };
161
+ }
162
+ catch (bootstrapError) {
163
+ const message = bootstrapError instanceof Error
164
+ ? bootstrapError.message
165
+ : "unknown bootstrap error";
166
+ console.warn(`Akane: failed to auto-create config at ${resolvedPath}: ${message}`);
167
+ return {
168
+ path: resolvedPath,
169
+ exists: false,
170
+ config: defaults,
171
+ };
172
+ }
129
173
  }
130
174
  throw error;
131
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-akane",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Akane orchestration plugin for OpenCode",
5
5
  "license": "MIT",
6
6
  "type": "module",