@ectplsm/relic 0.3.2 → 0.4.0

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 (60) hide show
  1. package/LICENCE.md +1 -1
  2. package/README.md +19 -12
  3. package/dist/adapters/mikoshi/client.d.ts +21 -0
  4. package/dist/adapters/mikoshi/client.js +84 -0
  5. package/dist/core/ports/index.d.ts +1 -0
  6. package/dist/core/ports/mikoshi.d.ts +937 -0
  7. package/dist/core/ports/mikoshi.js +209 -0
  8. package/dist/core/sync/crypto.d.ts +55 -0
  9. package/dist/core/sync/crypto.js +189 -0
  10. package/dist/core/sync/memory-hash.d.ts +35 -0
  11. package/dist/core/sync/memory-hash.js +61 -0
  12. package/dist/core/sync/memory-merge.d.ts +13 -0
  13. package/dist/core/sync/memory-merge.js +84 -0
  14. package/dist/core/sync/normalize.d.ts +10 -0
  15. package/dist/core/sync/normalize.js +21 -0
  16. package/dist/core/sync/persona-hash.d.ts +15 -0
  17. package/dist/core/sync/persona-hash.js +36 -0
  18. package/dist/core/usecases/claw-pull.d.ts +44 -0
  19. package/dist/core/usecases/claw-pull.js +117 -0
  20. package/dist/core/usecases/extract.d.ts +0 -1
  21. package/dist/core/usecases/extract.js +13 -27
  22. package/dist/core/usecases/index.d.ts +8 -0
  23. package/dist/core/usecases/index.js +8 -0
  24. package/dist/core/usecases/inject.d.ts +1 -0
  25. package/dist/core/usecases/inject.js +2 -0
  26. package/dist/core/usecases/mikoshi-clone.d.ts +29 -0
  27. package/dist/core/usecases/mikoshi-clone.js +94 -0
  28. package/dist/core/usecases/mikoshi-download.d.ts +29 -0
  29. package/dist/core/usecases/mikoshi-download.js +94 -0
  30. package/dist/core/usecases/mikoshi-memory-pull.d.ts +38 -0
  31. package/dist/core/usecases/mikoshi-memory-pull.js +142 -0
  32. package/dist/core/usecases/mikoshi-memory-push.d.ts +34 -0
  33. package/dist/core/usecases/mikoshi-memory-push.js +105 -0
  34. package/dist/core/usecases/mikoshi-memory-sync.d.ts +36 -0
  35. package/dist/core/usecases/mikoshi-memory-sync.js +175 -0
  36. package/dist/core/usecases/mikoshi-pull.d.ts +44 -0
  37. package/dist/core/usecases/mikoshi-pull.js +124 -0
  38. package/dist/core/usecases/mikoshi-push.d.ts +39 -0
  39. package/dist/core/usecases/mikoshi-push.js +127 -0
  40. package/dist/core/usecases/mikoshi-status.d.ts +37 -0
  41. package/dist/core/usecases/mikoshi-status.js +92 -0
  42. package/dist/core/usecases/sync.d.ts +0 -5
  43. package/dist/core/usecases/sync.js +23 -61
  44. package/dist/interfaces/cli/commands/claw.js +134 -85
  45. package/dist/interfaces/cli/commands/config.js +59 -0
  46. package/dist/interfaces/cli/commands/create.js +17 -16
  47. package/dist/interfaces/cli/commands/init.js +11 -10
  48. package/dist/interfaces/cli/commands/list.js +9 -7
  49. package/dist/interfaces/cli/commands/migrate.js +8 -7
  50. package/dist/interfaces/cli/commands/mikoshi.d.ts +2 -0
  51. package/dist/interfaces/cli/commands/mikoshi.js +565 -0
  52. package/dist/interfaces/cli/commands/refresh-samples.js +10 -9
  53. package/dist/interfaces/cli/index.js +2 -0
  54. package/dist/interfaces/cli/output.d.ts +5 -0
  55. package/dist/interfaces/cli/output.js +16 -0
  56. package/dist/interfaces/cli/spinner.d.ts +13 -0
  57. package/dist/interfaces/cli/spinner.js +47 -0
  58. package/dist/shared/config.d.ts +23 -3
  59. package/dist/shared/config.js +30 -2
  60. package/package.json +1 -1
@@ -0,0 +1,47 @@
1
+ const FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
2
+ const INTERVAL_MS = 80;
3
+ /**
4
+ * Start a CLI spinner that overwrites the current line.
5
+ *
6
+ * Falls back to a single static line when stdout is not a TTY
7
+ * (e.g. CI, piped output).
8
+ */
9
+ export function startSpinner(message) {
10
+ const isTTY = process.stdout.isTTY ?? false;
11
+ let currentMessage = message;
12
+ if (!isTTY) {
13
+ process.stdout.write(`${message}\n`);
14
+ return {
15
+ update(msg) {
16
+ currentMessage = msg;
17
+ process.stdout.write(`${msg}\n`);
18
+ },
19
+ stop(finalMessage) {
20
+ if (finalMessage) {
21
+ process.stdout.write(`${finalMessage}\n`);
22
+ }
23
+ },
24
+ };
25
+ }
26
+ let frameIndex = 0;
27
+ const render = () => {
28
+ const frame = FRAMES[frameIndex % FRAMES.length];
29
+ process.stdout.write(`\r${frame} ${currentMessage}`);
30
+ frameIndex++;
31
+ };
32
+ render();
33
+ const timer = setInterval(render, INTERVAL_MS);
34
+ return {
35
+ update(msg) {
36
+ currentMessage = msg;
37
+ },
38
+ stop(finalMessage) {
39
+ clearInterval(timer);
40
+ // Clear the spinner line
41
+ process.stdout.write("\r\x1b[2K");
42
+ if (finalMessage) {
43
+ process.stdout.write(`${finalMessage}\n`);
44
+ }
45
+ },
46
+ };
47
+ }
@@ -5,8 +5,12 @@ declare const CONFIG_PATH: string;
5
5
  export declare const RelicConfigSchema: z.ZodObject<{
6
6
  /** Engramデータの格納ディレクトリ */
7
7
  engramsPath: z.ZodDefault<z.ZodString>;
8
- /** Mikoshi APIのベースURL(将来用) */
9
- mikoshiUrl: z.ZodOptional<z.ZodString>;
8
+ /** Mikoshi APIのベースURL */
9
+ mikoshiUrl: z.ZodDefault<z.ZodString>;
10
+ /** Mikoshi APIキー */
11
+ mikoshiApiKey: z.ZodOptional<z.ZodString>;
12
+ /** Mikoshi memory 暗号化パスフレーズ */
13
+ mikoshiPassphrase: z.ZodOptional<z.ZodString>;
10
14
  /** --engram 未指定時に召喚するデフォルトEngram ID */
11
15
  defaultEngram: z.ZodOptional<z.ZodString>;
12
16
  /** claw inject/extract/sync で使うClawディレクトリ (default: ~/.openclaw) */
@@ -19,7 +23,9 @@ export declare const RelicConfigSchema: z.ZodObject<{
19
23
  memoryWindowSize: number;
20
24
  distillationBatchSize: number;
21
25
  engramsPath: string;
22
- mikoshiUrl?: string | undefined;
26
+ mikoshiUrl: string;
27
+ mikoshiApiKey?: string | undefined;
28
+ mikoshiPassphrase?: string | undefined;
23
29
  defaultEngram?: string | undefined;
24
30
  clawPath?: string | undefined;
25
31
  }, {
@@ -27,6 +33,8 @@ export declare const RelicConfigSchema: z.ZodObject<{
27
33
  distillationBatchSize?: number | undefined;
28
34
  engramsPath?: string | undefined;
29
35
  mikoshiUrl?: string | undefined;
36
+ mikoshiApiKey?: string | undefined;
37
+ mikoshiPassphrase?: string | undefined;
30
38
  defaultEngram?: string | undefined;
31
39
  clawPath?: string | undefined;
32
40
  }>;
@@ -75,4 +83,16 @@ export declare function resolveMemoryWindowSize(): Promise<number>;
75
83
  * 優先順位: config.distillationBatchSize > 30 (デフォルト)
76
84
  */
77
85
  export declare function resolveDistillationBatchSize(): Promise<number>;
86
+ /**
87
+ * Mikoshi URLを解決する。
88
+ */
89
+ export declare function resolveMikoshiUrl(): Promise<string>;
90
+ /**
91
+ * Mikoshi APIキーを解決する。未設定時はundefined。
92
+ */
93
+ export declare function resolveMikoshiApiKey(): Promise<string | undefined>;
94
+ /**
95
+ * Mikoshi パスフレーズを解決する。未設定時はundefined。
96
+ */
97
+ export declare function resolveMikoshiPassphrase(): Promise<string | undefined>;
78
98
  export { CONFIG_PATH, RELIC_DIR, TEMPLATES_DIR };
@@ -12,8 +12,12 @@ const CONFIG_PATH = join(RELIC_DIR, "config.json");
12
12
  export const RelicConfigSchema = z.object({
13
13
  /** Engramデータの格納ディレクトリ */
14
14
  engramsPath: z.string().default(join(homedir(), ".relic", "engrams")),
15
- /** Mikoshi APIのベースURL(将来用) */
16
- mikoshiUrl: z.string().optional(),
15
+ /** Mikoshi APIのベースURL */
16
+ mikoshiUrl: z.string().default("https://mikoshi.ectplsm.com"),
17
+ /** Mikoshi APIキー */
18
+ mikoshiApiKey: z.string().optional(),
19
+ /** Mikoshi memory 暗号化パスフレーズ */
20
+ mikoshiPassphrase: z.string().optional(),
17
21
  /** --engram 未指定時に召喚するデフォルトEngram ID */
18
22
  defaultEngram: z.string().optional(),
19
23
  /** claw inject/extract/sync で使うClawディレクトリ (default: ~/.openclaw) */
@@ -166,4 +170,28 @@ export async function resolveDistillationBatchSize() {
166
170
  const config = await loadConfig();
167
171
  return config.distillationBatchSize;
168
172
  }
173
+ /**
174
+ * Mikoshi URLを解決する。
175
+ */
176
+ export async function resolveMikoshiUrl() {
177
+ await ensureInitialized();
178
+ const config = await loadConfig();
179
+ return config.mikoshiUrl;
180
+ }
181
+ /**
182
+ * Mikoshi APIキーを解決する。未設定時はundefined。
183
+ */
184
+ export async function resolveMikoshiApiKey() {
185
+ await ensureInitialized();
186
+ const config = await loadConfig();
187
+ return config.mikoshiApiKey;
188
+ }
189
+ /**
190
+ * Mikoshi パスフレーズを解決する。未設定時はundefined。
191
+ */
192
+ export async function resolveMikoshiPassphrase() {
193
+ await ensureInitialized();
194
+ const config = await loadConfig();
195
+ return config.mikoshiPassphrase;
196
+ }
169
197
  export { CONFIG_PATH, RELIC_DIR, TEMPLATES_DIR };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ectplsm/relic",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "PROJECT RELIC — Engram injection system for AI constructs",
5
5
  "license": "MIT",
6
6
  "repository": {