@ectplsm/relic 0.1.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 +21 -0
- package/README.md +324 -0
- package/dist/adapters/local/index.d.ts +1 -0
- package/dist/adapters/local/index.js +1 -0
- package/dist/adapters/local/local-engram-repository.d.ts +28 -0
- package/dist/adapters/local/local-engram-repository.js +130 -0
- package/dist/adapters/shells/claude-shell.d.ts +13 -0
- package/dist/adapters/shells/claude-shell.js +33 -0
- package/dist/adapters/shells/codex-shell.d.ts +14 -0
- package/dist/adapters/shells/codex-shell.js +34 -0
- package/dist/adapters/shells/copilot-shell.d.ts +14 -0
- package/dist/adapters/shells/copilot-shell.js +43 -0
- package/dist/adapters/shells/gemini-shell.d.ts +14 -0
- package/dist/adapters/shells/gemini-shell.js +43 -0
- package/dist/adapters/shells/index.d.ts +4 -0
- package/dist/adapters/shells/index.js +4 -0
- package/dist/adapters/shells/override-preamble.d.ts +8 -0
- package/dist/adapters/shells/override-preamble.js +19 -0
- package/dist/adapters/shells/spawn-shell.d.ts +16 -0
- package/dist/adapters/shells/spawn-shell.js +47 -0
- package/dist/core/entities/engram.d.ts +180 -0
- package/dist/core/entities/engram.js +67 -0
- package/dist/core/entities/index.d.ts +1 -0
- package/dist/core/entities/index.js +1 -0
- package/dist/core/ports/engram-repository.d.ts +17 -0
- package/dist/core/ports/engram-repository.js +1 -0
- package/dist/core/ports/index.d.ts +2 -0
- package/dist/core/ports/index.js +1 -0
- package/dist/core/ports/shell-launcher.d.ts +27 -0
- package/dist/core/ports/shell-launcher.js +1 -0
- package/dist/core/usecases/extract.d.ts +49 -0
- package/dist/core/usecases/extract.js +190 -0
- package/dist/core/usecases/index.d.ts +8 -0
- package/dist/core/usecases/index.js +8 -0
- package/dist/core/usecases/init.d.ts +19 -0
- package/dist/core/usecases/init.js +19 -0
- package/dist/core/usecases/inject.d.ts +28 -0
- package/dist/core/usecases/inject.js +57 -0
- package/dist/core/usecases/list-engrams.d.ts +10 -0
- package/dist/core/usecases/list-engrams.js +12 -0
- package/dist/core/usecases/memory-search.d.ts +23 -0
- package/dist/core/usecases/memory-search.js +59 -0
- package/dist/core/usecases/memory-write.d.ts +20 -0
- package/dist/core/usecases/memory-write.js +47 -0
- package/dist/core/usecases/summon.d.ts +23 -0
- package/dist/core/usecases/summon.js +31 -0
- package/dist/core/usecases/sync.d.ts +40 -0
- package/dist/core/usecases/sync.js +94 -0
- package/dist/interfaces/cli/commands/extract.d.ts +2 -0
- package/dist/interfaces/cli/commands/extract.js +41 -0
- package/dist/interfaces/cli/commands/init.d.ts +2 -0
- package/dist/interfaces/cli/commands/init.js +19 -0
- package/dist/interfaces/cli/commands/inject.d.ts +2 -0
- package/dist/interfaces/cli/commands/inject.js +33 -0
- package/dist/interfaces/cli/commands/list.d.ts +2 -0
- package/dist/interfaces/cli/commands/list.js +30 -0
- package/dist/interfaces/cli/commands/shell.d.ts +2 -0
- package/dist/interfaces/cli/commands/shell.js +69 -0
- package/dist/interfaces/cli/commands/show.d.ts +2 -0
- package/dist/interfaces/cli/commands/show.js +26 -0
- package/dist/interfaces/cli/commands/sync.d.ts +2 -0
- package/dist/interfaces/cli/commands/sync.js +91 -0
- package/dist/interfaces/cli/index.d.ts +2 -0
- package/dist/interfaces/cli/index.js +22 -0
- package/dist/interfaces/mcp/index.d.ts +2 -0
- package/dist/interfaces/mcp/index.js +418 -0
- package/dist/shared/config.d.ts +37 -0
- package/dist/shared/config.js +122 -0
- package/dist/shared/engram-composer.d.ts +18 -0
- package/dist/shared/engram-composer.js +48 -0
- package/dist/shared/openclaw.d.ts +9 -0
- package/dist/shared/openclaw.js +21 -0
- package/package.json +44 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { exec } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { spawnShell, writeTempPrompt } from "./spawn-shell.js";
|
|
5
|
+
import { wrapWithOverride } from "./override-preamble.js";
|
|
6
|
+
const execAsync = promisify(exec);
|
|
7
|
+
/**
|
|
8
|
+
* Gemini CLI アダプター
|
|
9
|
+
* プロンプトをtempファイルに書き出し、
|
|
10
|
+
* --prompt-interactive で読み込んで注入する。
|
|
11
|
+
*/
|
|
12
|
+
export class GeminiShell {
|
|
13
|
+
command;
|
|
14
|
+
name = "Gemini CLI";
|
|
15
|
+
injectionMode = "user-message";
|
|
16
|
+
constructor(command = "gemini") {
|
|
17
|
+
this.command = command;
|
|
18
|
+
}
|
|
19
|
+
async isAvailable() {
|
|
20
|
+
try {
|
|
21
|
+
await execAsync(`which ${this.command}`);
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async launch(prompt, extraArgs = [], cwd) {
|
|
29
|
+
const tmp = writeTempPrompt(wrapWithOverride(prompt));
|
|
30
|
+
try {
|
|
31
|
+
const fileContent = readFileSync(tmp.path, "utf-8");
|
|
32
|
+
const args = [
|
|
33
|
+
"--prompt-interactive",
|
|
34
|
+
fileContent,
|
|
35
|
+
...extraArgs,
|
|
36
|
+
];
|
|
37
|
+
await spawnShell(this.command, args, cwd);
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
tmp.cleanup();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Override preamble for Shells that cannot directly replace
|
|
3
|
+
* the system prompt (instruction-file / user-message modes).
|
|
4
|
+
*
|
|
5
|
+
* Forces the Shell to adopt the Engram's identity by explicitly
|
|
6
|
+
* overriding its default persona.
|
|
7
|
+
*/
|
|
8
|
+
export declare function wrapWithOverride(engramPrompt: string): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Override preamble for Shells that cannot directly replace
|
|
3
|
+
* the system prompt (instruction-file / user-message modes).
|
|
4
|
+
*
|
|
5
|
+
* Forces the Shell to adopt the Engram's identity by explicitly
|
|
6
|
+
* overriding its default persona.
|
|
7
|
+
*/
|
|
8
|
+
export function wrapWithOverride(engramPrompt) {
|
|
9
|
+
return [
|
|
10
|
+
"[IMPORTANT: PERSONA OVERRIDE]",
|
|
11
|
+
"The following persona definition overrides ALL of your default identity, including your name, personality, and tone.",
|
|
12
|
+
"For the duration of this session, you MUST act according to the definition below. Do NOT reference your original identity.",
|
|
13
|
+
'When asked "who are you?" or to introduce yourself, respond based on the IDENTITY section below.',
|
|
14
|
+
"",
|
|
15
|
+
"---",
|
|
16
|
+
"",
|
|
17
|
+
engramPrompt,
|
|
18
|
+
].join("\n");
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI CLIをフォアグラウンドで起動し、stdin/stdout/stderrを引き継ぐ。
|
|
3
|
+
* ユーザーが終了するまでブロックする。
|
|
4
|
+
*
|
|
5
|
+
* shell: false で起動し、引数をそのまま渡す。
|
|
6
|
+
* これにより長いプロンプト文字列がシェルに壊されない。
|
|
7
|
+
*/
|
|
8
|
+
export declare function spawnShell(command: string, args: string[], cwd?: string): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* プロンプトをtempファイルに書き出し、パスを返す。
|
|
11
|
+
* Shell終了後にcleanup()を呼んで削除する。
|
|
12
|
+
*/
|
|
13
|
+
export declare function writeTempPrompt(prompt: string): {
|
|
14
|
+
path: string;
|
|
15
|
+
cleanup: () => void;
|
|
16
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { writeFileSync, unlinkSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
/**
|
|
6
|
+
* AI CLIをフォアグラウンドで起動し、stdin/stdout/stderrを引き継ぐ。
|
|
7
|
+
* ユーザーが終了するまでブロックする。
|
|
8
|
+
*
|
|
9
|
+
* shell: false で起動し、引数をそのまま渡す。
|
|
10
|
+
* これにより長いプロンプト文字列がシェルに壊されない。
|
|
11
|
+
*/
|
|
12
|
+
export function spawnShell(command, args, cwd) {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
const child = spawn(command, args, {
|
|
15
|
+
stdio: "inherit",
|
|
16
|
+
cwd,
|
|
17
|
+
});
|
|
18
|
+
child.on("error", (err) => {
|
|
19
|
+
reject(new Error(`Failed to launch ${command}: ${err.message}`));
|
|
20
|
+
});
|
|
21
|
+
child.on("close", (code) => {
|
|
22
|
+
if (code === 0 || code === null) {
|
|
23
|
+
resolve();
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
reject(new Error(`${command} exited with code ${code}`));
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* プロンプトをtempファイルに書き出し、パスを返す。
|
|
33
|
+
* Shell終了後にcleanup()を呼んで削除する。
|
|
34
|
+
*/
|
|
35
|
+
export function writeTempPrompt(prompt) {
|
|
36
|
+
const path = join(tmpdir(), `relic-engram-${Date.now()}.md`);
|
|
37
|
+
writeFileSync(path, prompt, "utf-8");
|
|
38
|
+
return {
|
|
39
|
+
path,
|
|
40
|
+
cleanup: () => {
|
|
41
|
+
try {
|
|
42
|
+
unlinkSync(path);
|
|
43
|
+
}
|
|
44
|
+
catch { /* ignore */ }
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Engramを構成する各Markdownファイルのスキーマ。
|
|
4
|
+
* OpenClawのworkspaceディレクトリ構造と1:1で対応する。
|
|
5
|
+
*/
|
|
6
|
+
export declare const EngramFileSchema: z.ZodObject<{
|
|
7
|
+
/** 人格の核となる指示・行動原理 */
|
|
8
|
+
soul: z.ZodString;
|
|
9
|
+
/** アイデンティティ定義(名前、口調、背景) */
|
|
10
|
+
identity: z.ZodString;
|
|
11
|
+
/** エージェント設定(ツール利用方針等) */
|
|
12
|
+
agents: z.ZodOptional<z.ZodString>;
|
|
13
|
+
/** ユーザー情報 */
|
|
14
|
+
user: z.ZodOptional<z.ZodString>;
|
|
15
|
+
/** 記憶インデックス */
|
|
16
|
+
memory: z.ZodOptional<z.ZodString>;
|
|
17
|
+
/** ハートビート(定期振り返り) */
|
|
18
|
+
heartbeat: z.ZodOptional<z.ZodString>;
|
|
19
|
+
/** 日付別の記憶エントリ */
|
|
20
|
+
memoryEntries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
soul: string;
|
|
23
|
+
identity: string;
|
|
24
|
+
agents?: string | undefined;
|
|
25
|
+
user?: string | undefined;
|
|
26
|
+
memory?: string | undefined;
|
|
27
|
+
heartbeat?: string | undefined;
|
|
28
|
+
memoryEntries?: Record<string, string> | undefined;
|
|
29
|
+
}, {
|
|
30
|
+
soul: string;
|
|
31
|
+
identity: string;
|
|
32
|
+
agents?: string | undefined;
|
|
33
|
+
user?: string | undefined;
|
|
34
|
+
memory?: string | undefined;
|
|
35
|
+
heartbeat?: string | undefined;
|
|
36
|
+
memoryEntries?: Record<string, string> | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
export type EngramFiles = z.infer<typeof EngramFileSchema>;
|
|
39
|
+
/**
|
|
40
|
+
* Engramメタデータ — Mikoshiでの管理情報
|
|
41
|
+
*/
|
|
42
|
+
export declare const EngramMetaSchema: z.ZodObject<{
|
|
43
|
+
/** 一意識別子 (例: "ghost-in-the-shell") */
|
|
44
|
+
id: z.ZodString;
|
|
45
|
+
/** 表示名 (例: "攻殻機動隊の少佐") */
|
|
46
|
+
name: z.ZodString;
|
|
47
|
+
/** 説明 */
|
|
48
|
+
description: z.ZodOptional<z.ZodString>;
|
|
49
|
+
/** 作成日時 */
|
|
50
|
+
createdAt: z.ZodString;
|
|
51
|
+
/** 最終更新日時 */
|
|
52
|
+
updatedAt: z.ZodString;
|
|
53
|
+
/** タグ */
|
|
54
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
createdAt: string;
|
|
59
|
+
updatedAt: string;
|
|
60
|
+
description?: string | undefined;
|
|
61
|
+
tags?: string[] | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
id: string;
|
|
64
|
+
name: string;
|
|
65
|
+
createdAt: string;
|
|
66
|
+
updatedAt: string;
|
|
67
|
+
description?: string | undefined;
|
|
68
|
+
tags?: string[] | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
export type EngramMeta = z.infer<typeof EngramMetaSchema>;
|
|
71
|
+
/**
|
|
72
|
+
* Engram — 完全な人格データセット
|
|
73
|
+
* メタデータとファイル群の統合体
|
|
74
|
+
*/
|
|
75
|
+
export declare const EngramSchema: z.ZodObject<{
|
|
76
|
+
meta: z.ZodObject<{
|
|
77
|
+
/** 一意識別子 (例: "ghost-in-the-shell") */
|
|
78
|
+
id: z.ZodString;
|
|
79
|
+
/** 表示名 (例: "攻殻機動隊の少佐") */
|
|
80
|
+
name: z.ZodString;
|
|
81
|
+
/** 説明 */
|
|
82
|
+
description: z.ZodOptional<z.ZodString>;
|
|
83
|
+
/** 作成日時 */
|
|
84
|
+
createdAt: z.ZodString;
|
|
85
|
+
/** 最終更新日時 */
|
|
86
|
+
updatedAt: z.ZodString;
|
|
87
|
+
/** タグ */
|
|
88
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
89
|
+
}, "strip", z.ZodTypeAny, {
|
|
90
|
+
id: string;
|
|
91
|
+
name: string;
|
|
92
|
+
createdAt: string;
|
|
93
|
+
updatedAt: string;
|
|
94
|
+
description?: string | undefined;
|
|
95
|
+
tags?: string[] | undefined;
|
|
96
|
+
}, {
|
|
97
|
+
id: string;
|
|
98
|
+
name: string;
|
|
99
|
+
createdAt: string;
|
|
100
|
+
updatedAt: string;
|
|
101
|
+
description?: string | undefined;
|
|
102
|
+
tags?: string[] | undefined;
|
|
103
|
+
}>;
|
|
104
|
+
files: z.ZodObject<{
|
|
105
|
+
/** 人格の核となる指示・行動原理 */
|
|
106
|
+
soul: z.ZodString;
|
|
107
|
+
/** アイデンティティ定義(名前、口調、背景) */
|
|
108
|
+
identity: z.ZodString;
|
|
109
|
+
/** エージェント設定(ツール利用方針等) */
|
|
110
|
+
agents: z.ZodOptional<z.ZodString>;
|
|
111
|
+
/** ユーザー情報 */
|
|
112
|
+
user: z.ZodOptional<z.ZodString>;
|
|
113
|
+
/** 記憶インデックス */
|
|
114
|
+
memory: z.ZodOptional<z.ZodString>;
|
|
115
|
+
/** ハートビート(定期振り返り) */
|
|
116
|
+
heartbeat: z.ZodOptional<z.ZodString>;
|
|
117
|
+
/** 日付別の記憶エントリ */
|
|
118
|
+
memoryEntries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
119
|
+
}, "strip", z.ZodTypeAny, {
|
|
120
|
+
soul: string;
|
|
121
|
+
identity: string;
|
|
122
|
+
agents?: string | undefined;
|
|
123
|
+
user?: string | undefined;
|
|
124
|
+
memory?: string | undefined;
|
|
125
|
+
heartbeat?: string | undefined;
|
|
126
|
+
memoryEntries?: Record<string, string> | undefined;
|
|
127
|
+
}, {
|
|
128
|
+
soul: string;
|
|
129
|
+
identity: string;
|
|
130
|
+
agents?: string | undefined;
|
|
131
|
+
user?: string | undefined;
|
|
132
|
+
memory?: string | undefined;
|
|
133
|
+
heartbeat?: string | undefined;
|
|
134
|
+
memoryEntries?: Record<string, string> | undefined;
|
|
135
|
+
}>;
|
|
136
|
+
}, "strip", z.ZodTypeAny, {
|
|
137
|
+
meta: {
|
|
138
|
+
id: string;
|
|
139
|
+
name: string;
|
|
140
|
+
createdAt: string;
|
|
141
|
+
updatedAt: string;
|
|
142
|
+
description?: string | undefined;
|
|
143
|
+
tags?: string[] | undefined;
|
|
144
|
+
};
|
|
145
|
+
files: {
|
|
146
|
+
soul: string;
|
|
147
|
+
identity: string;
|
|
148
|
+
agents?: string | undefined;
|
|
149
|
+
user?: string | undefined;
|
|
150
|
+
memory?: string | undefined;
|
|
151
|
+
heartbeat?: string | undefined;
|
|
152
|
+
memoryEntries?: Record<string, string> | undefined;
|
|
153
|
+
};
|
|
154
|
+
}, {
|
|
155
|
+
meta: {
|
|
156
|
+
id: string;
|
|
157
|
+
name: string;
|
|
158
|
+
createdAt: string;
|
|
159
|
+
updatedAt: string;
|
|
160
|
+
description?: string | undefined;
|
|
161
|
+
tags?: string[] | undefined;
|
|
162
|
+
};
|
|
163
|
+
files: {
|
|
164
|
+
soul: string;
|
|
165
|
+
identity: string;
|
|
166
|
+
agents?: string | undefined;
|
|
167
|
+
user?: string | undefined;
|
|
168
|
+
memory?: string | undefined;
|
|
169
|
+
heartbeat?: string | undefined;
|
|
170
|
+
memoryEntries?: Record<string, string> | undefined;
|
|
171
|
+
};
|
|
172
|
+
}>;
|
|
173
|
+
export type Engram = z.infer<typeof EngramSchema>;
|
|
174
|
+
export declare const ConstructStatusSchema: z.ZodEnum<["summoning", "active", "suspended", "banished"]>;
|
|
175
|
+
export type ConstructStatus = z.infer<typeof ConstructStatusSchema>;
|
|
176
|
+
/**
|
|
177
|
+
* Shell — LLMの種別を表す列挙
|
|
178
|
+
*/
|
|
179
|
+
export declare const ShellTypeSchema: z.ZodEnum<["claude", "gemini", "gpt", "local"]>;
|
|
180
|
+
export type ShellType = z.infer<typeof ShellTypeSchema>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// Engram — OpenClaw Workspace 互換の人格データセット
|
|
4
|
+
// ============================================================
|
|
5
|
+
/**
|
|
6
|
+
* Engramを構成する各Markdownファイルのスキーマ。
|
|
7
|
+
* OpenClawのworkspaceディレクトリ構造と1:1で対応する。
|
|
8
|
+
*/
|
|
9
|
+
export const EngramFileSchema = z.object({
|
|
10
|
+
/** 人格の核となる指示・行動原理 */
|
|
11
|
+
soul: z.string(),
|
|
12
|
+
/** アイデンティティ定義(名前、口調、背景) */
|
|
13
|
+
identity: z.string(),
|
|
14
|
+
/** エージェント設定(ツール利用方針等) */
|
|
15
|
+
agents: z.string().optional(),
|
|
16
|
+
/** ユーザー情報 */
|
|
17
|
+
user: z.string().optional(),
|
|
18
|
+
/** 記憶インデックス */
|
|
19
|
+
memory: z.string().optional(),
|
|
20
|
+
/** ハートビート(定期振り返り) */
|
|
21
|
+
heartbeat: z.string().optional(),
|
|
22
|
+
/** 日付別の記憶エントリ */
|
|
23
|
+
memoryEntries: z.record(z.string(), z.string()).optional(),
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Engramメタデータ — Mikoshiでの管理情報
|
|
27
|
+
*/
|
|
28
|
+
export const EngramMetaSchema = z.object({
|
|
29
|
+
/** 一意識別子 (例: "ghost-in-the-shell") */
|
|
30
|
+
id: z.string(),
|
|
31
|
+
/** 表示名 (例: "攻殻機動隊の少佐") */
|
|
32
|
+
name: z.string(),
|
|
33
|
+
/** 説明 */
|
|
34
|
+
description: z.string().optional(),
|
|
35
|
+
/** 作成日時 */
|
|
36
|
+
createdAt: z.string().datetime(),
|
|
37
|
+
/** 最終更新日時 */
|
|
38
|
+
updatedAt: z.string().datetime(),
|
|
39
|
+
/** タグ */
|
|
40
|
+
tags: z.array(z.string()).optional(),
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Engram — 完全な人格データセット
|
|
44
|
+
* メタデータとファイル群の統合体
|
|
45
|
+
*/
|
|
46
|
+
export const EngramSchema = z.object({
|
|
47
|
+
meta: EngramMetaSchema,
|
|
48
|
+
files: EngramFileSchema,
|
|
49
|
+
});
|
|
50
|
+
// ============================================================
|
|
51
|
+
// Construct — ShellにEngramがロードされた稼働中プロセス
|
|
52
|
+
// ============================================================
|
|
53
|
+
export const ConstructStatusSchema = z.enum([
|
|
54
|
+
"summoning", // 召喚中(Engramロード中)
|
|
55
|
+
"active", // 稼働中
|
|
56
|
+
"suspended", // 一時停止
|
|
57
|
+
"banished", // 退去済み
|
|
58
|
+
]);
|
|
59
|
+
/**
|
|
60
|
+
* Shell — LLMの種別を表す列挙
|
|
61
|
+
*/
|
|
62
|
+
export const ShellTypeSchema = z.enum([
|
|
63
|
+
"claude",
|
|
64
|
+
"gemini",
|
|
65
|
+
"gpt",
|
|
66
|
+
"local", // ローカルLLM (Ollama等)
|
|
67
|
+
]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EngramSchema, EngramFileSchema, EngramMetaSchema, ConstructStatusSchema, ShellTypeSchema, type Engram, type EngramFiles, type EngramMeta, type ConstructStatus, type ShellType, } from "./engram.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EngramSchema, EngramFileSchema, EngramMetaSchema, ConstructStatusSchema, ShellTypeSchema, } from "./engram.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Engram, EngramMeta } from "../entities/engram.js";
|
|
2
|
+
/**
|
|
3
|
+
* EngramRepository — Engram永続化層の抽象ポート
|
|
4
|
+
*
|
|
5
|
+
* Mikoshi (リモートAPI) やローカルファイルシステムなど、
|
|
6
|
+
* 具象実装はadapters層で提供される。
|
|
7
|
+
*/
|
|
8
|
+
export interface EngramRepository {
|
|
9
|
+
/** 全Engramのメタデータ一覧を取得 */
|
|
10
|
+
list(): Promise<EngramMeta[]>;
|
|
11
|
+
/** IDで完全なEngramを取得 */
|
|
12
|
+
get(id: string): Promise<Engram | null>;
|
|
13
|
+
/** Engramを保存(作成 or 更新) */
|
|
14
|
+
save(engram: Engram): Promise<void>;
|
|
15
|
+
/** Engramを削除 */
|
|
16
|
+
delete(id: string): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 注入モード — ShellがEngramをどの経路で受け取るか
|
|
3
|
+
*
|
|
4
|
+
* - system-prompt: システムプロンプトとして直接上書き(最も強力)
|
|
5
|
+
* - instruction-file: 設定ファイルに書き出して補助指示として注入
|
|
6
|
+
* - user-message: 初回ユーザーメッセージとして送り込む
|
|
7
|
+
*/
|
|
8
|
+
export type InjectionMode = "system-prompt" | "instruction-file" | "user-message";
|
|
9
|
+
/**
|
|
10
|
+
* ShellLauncher — AI CLIにEngramを注入して起動する抽象ポート
|
|
11
|
+
*
|
|
12
|
+
* 各Shell(LLM CLI)ごとにシステムプロンプトの渡し方が異なるため、
|
|
13
|
+
* 具象実装はadapters/shells/に配置される。
|
|
14
|
+
*/
|
|
15
|
+
export interface ShellLauncher {
|
|
16
|
+
/** Shell種別の表示名 */
|
|
17
|
+
readonly name: string;
|
|
18
|
+
/** このShellの注入モード */
|
|
19
|
+
readonly injectionMode: InjectionMode;
|
|
20
|
+
/** このShellが利用可能か(CLIがインストールされているか) */
|
|
21
|
+
isAvailable(): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* EngramプロンプトをShellに注入して起動する。
|
|
24
|
+
* プロセスはフォアグラウンドで実行され、ユーザーが終了するまでブロックする。
|
|
25
|
+
*/
|
|
26
|
+
launch(prompt: string, extraArgs?: string[], cwd?: string): Promise<void>;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { EngramRepository } from "../ports/engram-repository.js";
|
|
2
|
+
export interface ExtractResult {
|
|
3
|
+
engramId: string;
|
|
4
|
+
engramName: string;
|
|
5
|
+
sourcePath: string;
|
|
6
|
+
filesRead: string[];
|
|
7
|
+
memoryMerged: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Extract — OpenClawワークスペースからEngramを作成する
|
|
11
|
+
*
|
|
12
|
+
* agent名 = Engram ID の規約に基づき、agents/<engramId>/agent/ から読み取る。
|
|
13
|
+
*
|
|
14
|
+
* 既存Engramがある場合:
|
|
15
|
+
* - --force なし → memoryエントリのみマージ(persona部分は変更しない)
|
|
16
|
+
* - --force あり → persona部分を上書き + memoryをマージ
|
|
17
|
+
* 既存Engramがない場合:
|
|
18
|
+
* - 新規作成(全ファイル含む)
|
|
19
|
+
*/
|
|
20
|
+
export declare class Extract {
|
|
21
|
+
private readonly repository;
|
|
22
|
+
constructor(repository: EngramRepository);
|
|
23
|
+
execute(engramId: string, options?: {
|
|
24
|
+
name?: string;
|
|
25
|
+
openclawDir?: string;
|
|
26
|
+
force?: boolean;
|
|
27
|
+
}): Promise<ExtractResult>;
|
|
28
|
+
/**
|
|
29
|
+
* --force時: persona上書き + memoryマージ
|
|
30
|
+
*/
|
|
31
|
+
private mergeAndSave;
|
|
32
|
+
/**
|
|
33
|
+
* --forceなし時: memoryエントリのみ追記(repositoryのAPIを使用)
|
|
34
|
+
*/
|
|
35
|
+
private mergeMemoryOnly;
|
|
36
|
+
private readFiles;
|
|
37
|
+
}
|
|
38
|
+
export declare class WorkspaceNotFoundError extends Error {
|
|
39
|
+
constructor(path: string);
|
|
40
|
+
}
|
|
41
|
+
export declare class WorkspaceEmptyError extends Error {
|
|
42
|
+
constructor(path: string);
|
|
43
|
+
}
|
|
44
|
+
export declare class EngramAlreadyExistsError extends Error {
|
|
45
|
+
constructor(id: string);
|
|
46
|
+
}
|
|
47
|
+
export declare class ExtractNameRequiredError extends Error {
|
|
48
|
+
constructor(id: string);
|
|
49
|
+
}
|