@ectplsm/relic 0.3.1 → 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.
- package/LICENCE.md +1 -1
- package/README.md +19 -12
- package/dist/adapters/mikoshi/client.d.ts +21 -0
- package/dist/adapters/mikoshi/client.js +84 -0
- package/dist/adapters/shells/claude-shell.js +6 -5
- package/dist/adapters/shells/codex-shell.js +6 -5
- package/dist/adapters/shells/gemini-shell.js +8 -0
- package/dist/adapters/shells/resume-detect.d.ts +19 -0
- package/dist/adapters/shells/resume-detect.js +51 -0
- package/dist/core/ports/index.d.ts +1 -0
- package/dist/core/ports/mikoshi.d.ts +937 -0
- package/dist/core/ports/mikoshi.js +209 -0
- package/dist/core/ports/shell-launcher.d.ts +6 -0
- package/dist/core/sync/crypto.d.ts +55 -0
- package/dist/core/sync/crypto.js +189 -0
- package/dist/core/sync/memory-hash.d.ts +35 -0
- package/dist/core/sync/memory-hash.js +61 -0
- package/dist/core/sync/memory-merge.d.ts +13 -0
- package/dist/core/sync/memory-merge.js +84 -0
- package/dist/core/sync/normalize.d.ts +10 -0
- package/dist/core/sync/normalize.js +21 -0
- package/dist/core/sync/persona-hash.d.ts +15 -0
- package/dist/core/sync/persona-hash.js +36 -0
- package/dist/core/usecases/claw-pull.d.ts +44 -0
- package/dist/core/usecases/claw-pull.js +117 -0
- package/dist/core/usecases/extract.d.ts +0 -1
- package/dist/core/usecases/extract.js +13 -27
- package/dist/core/usecases/index.d.ts +8 -0
- package/dist/core/usecases/index.js +8 -0
- package/dist/core/usecases/inject.d.ts +1 -0
- package/dist/core/usecases/inject.js +2 -0
- package/dist/core/usecases/mikoshi-clone.d.ts +29 -0
- package/dist/core/usecases/mikoshi-clone.js +94 -0
- package/dist/core/usecases/mikoshi-download.d.ts +29 -0
- package/dist/core/usecases/mikoshi-download.js +94 -0
- package/dist/core/usecases/mikoshi-memory-pull.d.ts +38 -0
- package/dist/core/usecases/mikoshi-memory-pull.js +142 -0
- package/dist/core/usecases/mikoshi-memory-push.d.ts +34 -0
- package/dist/core/usecases/mikoshi-memory-push.js +105 -0
- package/dist/core/usecases/mikoshi-memory-sync.d.ts +36 -0
- package/dist/core/usecases/mikoshi-memory-sync.js +175 -0
- package/dist/core/usecases/mikoshi-pull.d.ts +44 -0
- package/dist/core/usecases/mikoshi-pull.js +124 -0
- package/dist/core/usecases/mikoshi-push.d.ts +39 -0
- package/dist/core/usecases/mikoshi-push.js +127 -0
- package/dist/core/usecases/mikoshi-status.d.ts +37 -0
- package/dist/core/usecases/mikoshi-status.js +92 -0
- package/dist/core/usecases/sync.d.ts +0 -5
- package/dist/core/usecases/sync.js +23 -61
- package/dist/interfaces/cli/commands/claw.js +134 -85
- package/dist/interfaces/cli/commands/config.js +59 -0
- package/dist/interfaces/cli/commands/create.js +17 -16
- package/dist/interfaces/cli/commands/init.js +11 -10
- package/dist/interfaces/cli/commands/list.js +9 -7
- package/dist/interfaces/cli/commands/migrate.js +8 -7
- package/dist/interfaces/cli/commands/mikoshi.d.ts +2 -0
- package/dist/interfaces/cli/commands/mikoshi.js +565 -0
- package/dist/interfaces/cli/commands/refresh-samples.js +10 -9
- package/dist/interfaces/cli/commands/shell.js +17 -3
- package/dist/interfaces/cli/index.js +2 -0
- package/dist/interfaces/cli/output.d.ts +5 -0
- package/dist/interfaces/cli/output.js +16 -0
- package/dist/interfaces/cli/spinner.d.ts +13 -0
- package/dist/interfaces/cli/spinner.js +47 -0
- package/dist/shared/config.d.ts +23 -3
- package/dist/shared/config.js +30 -2
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const DETAIL_PREFIX = " ";
|
|
2
|
+
export function printLine(message = "") {
|
|
3
|
+
console.log(message);
|
|
4
|
+
}
|
|
5
|
+
export function printBlank() {
|
|
6
|
+
printLine();
|
|
7
|
+
}
|
|
8
|
+
export function printDetail(message) {
|
|
9
|
+
console.log(`${DETAIL_PREFIX}${message}`);
|
|
10
|
+
}
|
|
11
|
+
export function printErrorLine(message) {
|
|
12
|
+
console.error(message);
|
|
13
|
+
}
|
|
14
|
+
export function printErrorDetail(message) {
|
|
15
|
+
console.error(`${DETAIL_PREFIX}${message}`);
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface Spinner {
|
|
2
|
+
/** Update the message while spinning. */
|
|
3
|
+
update(message: string): void;
|
|
4
|
+
/** Stop with a final message (replaces the spinner line). */
|
|
5
|
+
stop(finalMessage?: string): void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Start a CLI spinner that overwrites the current line.
|
|
9
|
+
*
|
|
10
|
+
* Falls back to a single static line when stdout is not a TTY
|
|
11
|
+
* (e.g. CI, piped output).
|
|
12
|
+
*/
|
|
13
|
+
export declare function startSpinner(message: string): Spinner;
|
|
@@ -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
|
+
}
|
package/dist/shared/config.d.ts
CHANGED
|
@@ -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.
|
|
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
|
|
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 };
|
package/dist/shared/config.js
CHANGED
|
@@ -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().
|
|
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 };
|