@nuomiji/agentbox 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.
Files changed (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +253 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +43 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/collector/collector.d.ts +15 -0
  7. package/dist/collector/collector.js +118 -0
  8. package/dist/collector/collector.js.map +1 -0
  9. package/dist/collector/known-layers.d.ts +2 -0
  10. package/dist/collector/known-layers.js +15 -0
  11. package/dist/collector/known-layers.js.map +1 -0
  12. package/dist/collector/probe.d.ts +19 -0
  13. package/dist/collector/probe.js +2 -0
  14. package/dist/collector/probe.js.map +1 -0
  15. package/dist/commands/apply.d.ts +10 -0
  16. package/dist/commands/apply.js +234 -0
  17. package/dist/commands/apply.js.map +1 -0
  18. package/dist/commands/bind.d.ts +8 -0
  19. package/dist/commands/bind.js +78 -0
  20. package/dist/commands/bind.js.map +1 -0
  21. package/dist/commands/collect.d.ts +8 -0
  22. package/dist/commands/collect.js +22 -0
  23. package/dist/commands/collect.js.map +1 -0
  24. package/dist/commands/export.d.ts +6 -0
  25. package/dist/commands/export.js +24 -0
  26. package/dist/commands/export.js.map +1 -0
  27. package/dist/commands/import-simple.d.ts +6 -0
  28. package/dist/commands/import-simple.js +96 -0
  29. package/dist/commands/import-simple.js.map +1 -0
  30. package/dist/commands/import.d.ts +8 -0
  31. package/dist/commands/import.js +108 -0
  32. package/dist/commands/import.js.map +1 -0
  33. package/dist/commands/inspect.d.ts +1 -0
  34. package/dist/commands/inspect.js +21 -0
  35. package/dist/commands/inspect.js.map +1 -0
  36. package/dist/commands/install-skills.d.ts +11 -0
  37. package/dist/commands/install-skills.js +316 -0
  38. package/dist/commands/install-skills.js.map +1 -0
  39. package/dist/commands/pack.d.ts +4 -0
  40. package/dist/commands/pack.js +37 -0
  41. package/dist/commands/pack.js.map +1 -0
  42. package/dist/commands/preview.d.ts +8 -0
  43. package/dist/commands/preview.js +108 -0
  44. package/dist/commands/preview.js.map +1 -0
  45. package/dist/commands/unpack.d.ts +4 -0
  46. package/dist/commands/unpack.js +45 -0
  47. package/dist/commands/unpack.js.map +1 -0
  48. package/dist/core/archive.d.ts +2 -0
  49. package/dist/core/archive.js +46 -0
  50. package/dist/core/archive.js.map +1 -0
  51. package/dist/core/bindings.d.ts +22 -0
  52. package/dist/core/bindings.js +46 -0
  53. package/dist/core/bindings.js.map +1 -0
  54. package/dist/core/env.d.ts +13 -0
  55. package/dist/core/env.js +49 -0
  56. package/dist/core/env.js.map +1 -0
  57. package/dist/core/fs.d.ts +12 -0
  58. package/dist/core/fs.js +233 -0
  59. package/dist/core/fs.js.map +1 -0
  60. package/dist/core/materialize.d.ts +10 -0
  61. package/dist/core/materialize.js +54 -0
  62. package/dist/core/materialize.js.map +1 -0
  63. package/dist/core/redaction.d.ts +25 -0
  64. package/dist/core/redaction.js +184 -0
  65. package/dist/core/redaction.js.map +1 -0
  66. package/dist/core/schemas.d.ts +9 -0
  67. package/dist/core/schemas.js +60 -0
  68. package/dist/core/schemas.js.map +1 -0
  69. package/dist/core/types.d.ts +125 -0
  70. package/dist/core/types.js +2 -0
  71. package/dist/core/types.js.map +1 -0
  72. package/dist/core/yaml.d.ts +1 -0
  73. package/dist/core/yaml.js +8 -0
  74. package/dist/core/yaml.js.map +1 -0
  75. package/dist/import/claude-code.d.ts +3 -0
  76. package/dist/import/claude-code.js +182 -0
  77. package/dist/import/claude-code.js.map +1 -0
  78. package/dist/import/codex.d.ts +3 -0
  79. package/dist/import/codex.js +162 -0
  80. package/dist/import/codex.js.map +1 -0
  81. package/dist/import/compatibility.d.ts +42 -0
  82. package/dist/import/compatibility.js +99 -0
  83. package/dist/import/compatibility.js.map +1 -0
  84. package/dist/import/install-plan.d.ts +43 -0
  85. package/dist/import/install-plan.js +125 -0
  86. package/dist/import/install-plan.js.map +1 -0
  87. package/dist/import/openclaw.d.ts +3 -0
  88. package/dist/import/openclaw.js +128 -0
  89. package/dist/import/openclaw.js.map +1 -0
  90. package/dist/import/portable.d.ts +6 -0
  91. package/dist/import/portable.js +394 -0
  92. package/dist/import/portable.js.map +1 -0
  93. package/dist/import/types.d.ts +21 -0
  94. package/dist/import/types.js +2 -0
  95. package/dist/import/types.js.map +1 -0
  96. package/dist/probes/claude-code.d.ts +9 -0
  97. package/dist/probes/claude-code.js +244 -0
  98. package/dist/probes/claude-code.js.map +1 -0
  99. package/dist/probes/codex.d.ts +10 -0
  100. package/dist/probes/codex.js +219 -0
  101. package/dist/probes/codex.js.map +1 -0
  102. package/dist/probes/cursor.d.ts +9 -0
  103. package/dist/probes/cursor.js +102 -0
  104. package/dist/probes/cursor.js.map +1 -0
  105. package/dist/probes/openclaw.d.ts +9 -0
  106. package/dist/probes/openclaw.js +52 -0
  107. package/dist/probes/openclaw.js.map +1 -0
  108. package/package.json +54 -0
@@ -0,0 +1,234 @@
1
+ import { copyFile, mkdir, readFile, stat } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { parse } from "yaml";
4
+ import { describeMaterializationMode, getDefaultInstallScope, resolvePortablePath } from "../core/materialize.js";
5
+ import { pathExists } from "../core/fs.js";
6
+ export async function applyCommand(importPreviewPath, options) {
7
+ const previewRoot = path.resolve(importPreviewPath);
8
+ const reportPath = path.join(previewRoot, "import-report.yaml");
9
+ if (!(await pathExists(reportPath))) {
10
+ throw new Error(`import-report.yaml not found in: ${previewRoot}`);
11
+ }
12
+ const report = parse(await readFile(reportPath, "utf8"));
13
+ const scope = options.scope ?? report.targetScope ?? getDefaultInstallScope(report.targetHost);
14
+ const resolutionContext = getResolutionContext(options);
15
+ validateResolutionContext(resolutionContext, options.execute === true);
16
+ const plannedWrites = planWrites(previewRoot, report.targetHost, scope);
17
+ if (!options.execute) {
18
+ printDryRun(report.targetHost, scope, plannedWrites, resolutionContext);
19
+ return;
20
+ }
21
+ await performWrites(plannedWrites, resolutionContext, options.force === true);
22
+ process.stdout.write(`Applied import preview for host: ${report.targetHost}\n`);
23
+ process.stdout.write(`Target scope: ${scope}\n`);
24
+ process.stdout.write(`Mode: ${describeMaterializationMode(resolutionContext)}\n`);
25
+ process.stdout.write(`Files written: ${plannedWrites.length}\n`);
26
+ }
27
+ function planWrites(previewRoot, targetHost, scope) {
28
+ if (targetHost === "codex") {
29
+ const base = scope === "user" ? "{{HOME}}\\.codex" : "{{PROJECT_ROOT}}\\.codex";
30
+ const reportsBase = `${base}\\agentbox`;
31
+ return [
32
+ {
33
+ source: path.join(previewRoot, "codex", "config.preview.toml"),
34
+ destination: `${base}\\config.toml`,
35
+ required: true
36
+ },
37
+ {
38
+ source: path.join(previewRoot, "codex", "skills.preview.yaml"),
39
+ destination: `${base}\\skills\\agentbox-skills.yaml`,
40
+ required: false
41
+ },
42
+ {
43
+ source: path.join(previewRoot, "codex", "memory.preview.yaml"),
44
+ destination: `${base}\\memories\\agentbox-memory.yaml`,
45
+ required: false
46
+ },
47
+ {
48
+ source: path.join(previewRoot, "codex", "memory.preview.md"),
49
+ destination: `${base}\\memories\\agentbox-memory.md`,
50
+ required: false
51
+ },
52
+ {
53
+ source: path.join(previewRoot, "codex", "session.preview.yaml"),
54
+ destination: `${base}\\memories\\agentbox-session.yaml`,
55
+ required: false
56
+ },
57
+ {
58
+ source: path.join(previewRoot, "codex", "session.preview.md"),
59
+ destination: `${base}\\memories\\agentbox-session.md`,
60
+ required: false
61
+ },
62
+ {
63
+ source: path.join(previewRoot, "codex", "import-summary.yaml"),
64
+ destination: `${reportsBase}\\import-summary.yaml`,
65
+ required: false
66
+ },
67
+ {
68
+ source: path.join(previewRoot, "skill-install-plan.yaml"),
69
+ destination: `${reportsBase}\\skill-install-plan.yaml`,
70
+ required: false
71
+ },
72
+ {
73
+ source: path.join(previewRoot, "compatibility-report.yaml"),
74
+ destination: `${reportsBase}\\compatibility-report.yaml`,
75
+ required: false
76
+ }
77
+ ];
78
+ }
79
+ if (targetHost === "claude-code") {
80
+ const base = scope === "user" ? "{{HOME}}\\.claude" : "{{PROJECT_ROOT}}\\.claude";
81
+ const claudeProfile = scope === "user" ? "{{HOME}}\\.claude\\CLAUDE.md" : "{{PROJECT_ROOT}}\\CLAUDE.md";
82
+ const reportsBase = `${base}\\agentbox`;
83
+ return [
84
+ {
85
+ source: path.join(previewRoot, "claude-code", "settings.preview.json"),
86
+ destination: `${base}\\settings.json`,
87
+ required: true
88
+ },
89
+ {
90
+ source: path.join(previewRoot, "claude-code", "skills.preview.yaml"),
91
+ destination: `${base}\\skills\\agentbox-skills.yaml`,
92
+ required: false
93
+ },
94
+ {
95
+ source: path.join(previewRoot, "claude-code", "memory.preview.yaml"),
96
+ destination: `${base}\\memory\\agentbox-memory.yaml`,
97
+ required: false
98
+ },
99
+ {
100
+ source: path.join(previewRoot, "claude-code", "memory.preview.md"),
101
+ destination: `${base}\\memory\\agentbox-memory.md`,
102
+ required: false
103
+ },
104
+ {
105
+ source: path.join(previewRoot, "claude-code", "session.preview.yaml"),
106
+ destination: `${base}\\memory\\agentbox-session.yaml`,
107
+ required: false
108
+ },
109
+ {
110
+ source: path.join(previewRoot, "claude-code", "session.preview.md"),
111
+ destination: `${base}\\memory\\agentbox-session.md`,
112
+ required: false
113
+ },
114
+ {
115
+ source: path.join(previewRoot, "claude-code", "CLAUDE.preview.md"),
116
+ destination: claudeProfile,
117
+ required: false
118
+ },
119
+ {
120
+ source: path.join(previewRoot, "claude-code", "import-summary.yaml"),
121
+ destination: `${reportsBase}\\import-summary.yaml`,
122
+ required: false
123
+ },
124
+ {
125
+ source: path.join(previewRoot, "skill-install-plan.yaml"),
126
+ destination: `${reportsBase}\\skill-install-plan.yaml`,
127
+ required: false
128
+ },
129
+ {
130
+ source: path.join(previewRoot, "compatibility-report.yaml"),
131
+ destination: `${reportsBase}\\compatibility-report.yaml`,
132
+ required: false
133
+ }
134
+ ];
135
+ }
136
+ const base = scope === "user" ? "{{HOME}}\\.openclaw" : "{{PROJECT_ROOT}}\\.openclaw";
137
+ const reportsBase = `${base}\\agentbox`;
138
+ return [
139
+ {
140
+ source: path.join(previewRoot, "openclaw", "agent-config.preview.yaml"),
141
+ destination: `${base}\\agent-config.yaml`,
142
+ required: true
143
+ },
144
+ {
145
+ source: path.join(previewRoot, "openclaw", "skills.preview.yaml"),
146
+ destination: `${base}\\skills\\agentbox-skills.yaml`,
147
+ required: false
148
+ },
149
+ {
150
+ source: path.join(previewRoot, "openclaw", "memory.preview.yaml"),
151
+ destination: `${base}\\memory\\agentbox-memory.yaml`,
152
+ required: false
153
+ },
154
+ {
155
+ source: path.join(previewRoot, "openclaw", "memory.preview.md"),
156
+ destination: `${base}\\memory\\agentbox-memory.md`,
157
+ required: false
158
+ },
159
+ {
160
+ source: path.join(previewRoot, "openclaw", "session.preview.yaml"),
161
+ destination: `${base}\\memory\\agentbox-session.yaml`,
162
+ required: false
163
+ },
164
+ {
165
+ source: path.join(previewRoot, "openclaw", "session.preview.md"),
166
+ destination: `${base}\\memory\\agentbox-session.md`,
167
+ required: false
168
+ },
169
+ {
170
+ source: path.join(previewRoot, "openclaw", "import-summary.yaml"),
171
+ destination: `${reportsBase}\\import-summary.yaml`,
172
+ required: false
173
+ },
174
+ {
175
+ source: path.join(previewRoot, "skill-install-plan.yaml"),
176
+ destination: `${reportsBase}\\skill-install-plan.yaml`,
177
+ required: false
178
+ },
179
+ {
180
+ source: path.join(previewRoot, "compatibility-report.yaml"),
181
+ destination: `${reportsBase}\\compatibility-report.yaml`,
182
+ required: false
183
+ }
184
+ ];
185
+ }
186
+ function getResolutionContext(options) {
187
+ if (options.realHome) {
188
+ return {
189
+ mode: "real-home",
190
+ projectRoot: options.projectRoot
191
+ };
192
+ }
193
+ return {
194
+ mode: "sandbox",
195
+ targetRoot: options.targetRoot
196
+ };
197
+ }
198
+ function validateResolutionContext(context, isExecute) {
199
+ if (context.mode === "sandbox" && isExecute && !context.targetRoot) {
200
+ throw new Error("`apply --execute` requires `--target-root <dir>` unless `--real-home` is used.");
201
+ }
202
+ }
203
+ function printDryRun(targetHost, scope, plannedWrites, resolutionContext) {
204
+ process.stdout.write(`Apply dry-run for host: ${targetHost}\n`);
205
+ process.stdout.write(`Target scope: ${scope}\n`);
206
+ process.stdout.write(`Mode: ${describeMaterializationMode(resolutionContext)}\n`);
207
+ for (const write of plannedWrites) {
208
+ process.stdout.write(`- ${write.source} -> ${resolvePortablePath(write.destination, resolutionContext)}${write.required ? " [required]" : ""}\n`);
209
+ }
210
+ process.stdout.write("Use --execute to materialize these files.\n");
211
+ }
212
+ async function performWrites(plannedWrites, resolutionContext, force) {
213
+ for (const write of plannedWrites) {
214
+ const exists = await pathExists(write.source);
215
+ if (!exists) {
216
+ if (write.required) {
217
+ throw new Error(`Required preview file missing: ${write.source}`);
218
+ }
219
+ continue;
220
+ }
221
+ const destinationPath = resolvePortablePath(write.destination, resolutionContext);
222
+ const destinationExists = await pathExists(destinationPath);
223
+ if (destinationExists && !force) {
224
+ throw new Error(`Target file already exists: ${destinationPath}. Re-run with --force to overwrite.`);
225
+ }
226
+ await mkdir(path.dirname(destinationPath), { recursive: true });
227
+ await copyFile(write.source, destinationPath);
228
+ const sourceStat = await stat(write.source);
229
+ if (sourceStat.size === 0 && write.required) {
230
+ throw new Error(`Required preview file is empty: ${write.source}`);
231
+ }
232
+ }
233
+ }
234
+ //# sourceMappingURL=apply.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply.js","sourceRoot":"","sources":["../../src/commands/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AA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C5C,MAAM,IAAI,KAAK,CAAC,mCAAmC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ export interface BindCommandOptions {
2
+ output?: string;
3
+ fromEnv?: boolean;
4
+ envFile?: string;
5
+ requireComplete?: boolean;
6
+ set?: string[];
7
+ }
8
+ export declare function bindCommand(targetPath: string, options: BindCommandOptions): Promise<void>;
@@ -0,0 +1,78 @@
1
+ import { readFile, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { parse } from "yaml";
4
+ import { resolveBindings } from "../core/bindings.js";
5
+ import { parseEnvObject, parseKeyValueArg, serializeEnvObject } from "../core/env.js";
6
+ import { pathExists } from "../core/fs.js";
7
+ import { toYaml } from "../core/yaml.js";
8
+ export async function bindCommand(targetPath, options) {
9
+ const root = path.resolve(targetPath);
10
+ const templatePath = path.join(root, "bindings.template.env");
11
+ const resolvedPath = path.join(root, "resolved.yaml");
12
+ if (!(await pathExists(templatePath))) {
13
+ throw new Error(`bindings.template.env not found in: ${root}`);
14
+ }
15
+ if (!(await pathExists(resolvedPath))) {
16
+ throw new Error(`resolved.yaml not found in: ${root}`);
17
+ }
18
+ const templateRaw = await readFile(templatePath, "utf8");
19
+ const templateEntries = parseEnvObject(templateRaw);
20
+ const resolved = parse(await readFile(resolvedPath, "utf8"));
21
+ const envFileValues = options.envFile && (await pathExists(path.resolve(options.envFile)))
22
+ ? parseEnvObject(await readFile(path.resolve(options.envFile), "utf8"))
23
+ : {};
24
+ const explicitValues = collectExplicitValues(options.set ?? []);
25
+ const bindingResolution = resolveBindings(resolved.bindings, templateEntries, [
26
+ {
27
+ kind: "explicit",
28
+ name: "--set",
29
+ values: explicitValues
30
+ },
31
+ {
32
+ kind: "env-file",
33
+ name: options.envFile ? path.resolve(options.envFile) : "(not provided)",
34
+ values: envFileValues
35
+ },
36
+ {
37
+ kind: "process-env",
38
+ name: "process.env",
39
+ values: options.fromEnv ? process.env : {}
40
+ }
41
+ ]);
42
+ const outputPath = path.resolve(options.output ?? path.join(root, "bindings.env"));
43
+ await writeFile(outputPath, serializeEnvObject(bindingResolution.values), "utf8");
44
+ const reportPath = path.join(root, "bindings.report.yaml");
45
+ await writeFile(reportPath, toYaml({
46
+ resolvedBindings: bindingResolution.entries.length,
47
+ providedBindings: bindingResolution.providedCount,
48
+ missingRequiredBindings: bindingResolution.missingRequired.map((entry) => entry.key),
49
+ entries: bindingResolution.entries.map((entry) => ({
50
+ key: entry.key,
51
+ kind: entry.kind,
52
+ required: entry.required,
53
+ provided: entry.provided,
54
+ source: entry.source,
55
+ description: entry.description
56
+ }))
57
+ }), "utf8");
58
+ process.stdout.write(`Bindings file written to: ${outputPath}\n`);
59
+ process.stdout.write(`Bindings report written to: ${reportPath}\n`);
60
+ process.stdout.write(`Resolved bindings: ${bindingResolution.entries.length}\n`);
61
+ process.stdout.write(`Provided bindings: ${bindingResolution.providedCount}\n`);
62
+ process.stdout.write(`Missing required bindings: ${bindingResolution.missingRequired.length}\n`);
63
+ if (bindingResolution.missingRequired.length > 0) {
64
+ process.stdout.write(`Missing keys: ${bindingResolution.missingRequired.map((entry) => entry.key).join(", ")}\n`);
65
+ }
66
+ if (options.requireComplete && bindingResolution.missingRequired.length > 0) {
67
+ throw new Error("Required bindings are still missing. Re-run bind with --set, --env-file, or --from-env.");
68
+ }
69
+ }
70
+ function collectExplicitValues(values) {
71
+ const result = {};
72
+ for (const raw of values) {
73
+ const parsed = parseKeyValueArg(raw);
74
+ result[parsed.key] = parsed.value;
75
+ }
76
+ return result;
77
+ }
78
+ //# sourceMappingURL=bind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bind.js","sourceRoot":"","sources":["../../src/commands/bind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,E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,KAAK,CAAC,yFAAyF,CAAC,CAAC;IAC7G,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,MAAgB;IAC7C,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;IACpC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { SessionCaptureMode, SupportedHost } from "../core/types.js";
2
+ export interface CollectCommandOptions {
3
+ host?: SupportedHost;
4
+ output?: string;
5
+ name?: string;
6
+ sessionMode?: SessionCaptureMode;
7
+ }
8
+ export declare function collectCommand(options: CollectCommandOptions): Promise<void>;
@@ -0,0 +1,22 @@
1
+ import path from "node:path";
2
+ import { runCollect } from "../collector/collector.js";
3
+ import { ClaudeCodeProbe } from "../probes/claude-code.js";
4
+ import { CodexProbe } from "../probes/codex.js";
5
+ import { CursorProbe } from "../probes/cursor.js";
6
+ import { OpenClawProbe } from "../probes/openclaw.js";
7
+ export async function collectCommand(options) {
8
+ const outputDir = path.resolve(options.output ?? "snapshot");
9
+ const boxName = options.name ?? path.basename(process.cwd());
10
+ const result = await runCollect([new ClaudeCodeProbe(), new CodexProbe(), new CursorProbe(), new OpenClawProbe()], {
11
+ host: options.host,
12
+ outputDir,
13
+ boxName,
14
+ sessionMode: options.sessionMode ?? "portable"
15
+ });
16
+ process.stdout.write(`Collected host: ${result.manifest.metadata.sourceHost}\n`);
17
+ process.stdout.write(`Snapshot written to: ${result.outputDir}\n`);
18
+ process.stdout.write(`Bindings required: ${result.resolved.bindings.length}\n`);
19
+ process.stdout.write(`Host artifacts discovered: ${result.resolved.hostArtifacts.length}\n`);
20
+ process.stdout.write(`Session capture mode: ${options.sessionMode ?? "portable"}\n`);
21
+ }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,CAAC,CAAC;IAChF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,IAAI,CAAC,CAAC;IAC7F,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,OAAO,CAAC,WAAW,IAAI,UAAU,IAAI,CAAC,CAAC;AACvF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { SupportedHost } from "../core/types.js";
2
+ export interface ExportCommandOptions {
3
+ output?: string;
4
+ host?: SupportedHost;
5
+ }
6
+ export declare function exportCommand(options: ExportCommandOptions): Promise<void>;
@@ -0,0 +1,24 @@
1
+ import path from "node:path";
2
+ import { runCollect } from "../collector/collector.js";
3
+ import { createArchiveFromDirectory } from "../core/archive.js";
4
+ import { ClaudeCodeProbe } from "../probes/claude-code.js";
5
+ export async function exportCommand(options) {
6
+ const cwd = process.cwd();
7
+ const projectName = path.basename(cwd);
8
+ const tempDir = path.join(cwd, ".agentbox-temp");
9
+ const outputFile = path.resolve(options.output ?? `${projectName}.agentbox`);
10
+ console.log(`Exporting agent configuration from: ${cwd}`);
11
+ // Collect snapshot
12
+ const result = await runCollect([new ClaudeCodeProbe()], {
13
+ host: options.host,
14
+ outputDir: tempDir,
15
+ boxName: projectName,
16
+ sessionMode: "portable"
17
+ });
18
+ console.log(`Collected host: ${result.manifest.metadata.sourceHost}`);
19
+ // Pack into .agentbox file
20
+ await createArchiveFromDirectory(tempDir, outputFile);
21
+ console.log(`\nExported to: ${outputFile}`);
22
+ console.log(`Share this file to migrate your agent configuration.`);
23
+ }
24
+ //# sourceMappingURL=export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAQ3D,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA6B;IAC/D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,GAAG,WAAW,WAAW,CAAC,CAAC;IAE7E,OAAO,CAAC,GAAG,CAAC,uCAAuC,GAAG,EAAE,CAAC,CAAC;IAE1D,mBAAmB;IACnB,MAAM,MAAM,GAAG,MAAM,UAAU,CAC7B,CAAC,IAAI,eAAe,EAAE,CAAC,EACvB;QACE,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,SAAS,EAAE,OAAO;QAClB,OAAO,EAAE,WAAW;QACpB,WAAW,EAAE,UAAU;KACxB,CACF,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,mBAAmB,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAEtE,2BAA2B;IAC3B,MAAM,0BAA0B,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAEtD,OAAO,CAAC,GAAG,CAAC,kBAAkB,UAAU,EAAE,CAAC,CAAC;IAC5C,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC;AACtE,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { SupportedHost } from "../core/types.js";
2
+ export interface ImportSimpleCommandOptions {
3
+ force?: boolean;
4
+ host?: SupportedHost;
5
+ }
6
+ export declare function importSimpleCommand(bundlePath: string, options: ImportSimpleCommandOptions): Promise<void>;
@@ -0,0 +1,96 @@
1
+ import path from "node:path";
2
+ import os from "node:os";
3
+ import { readFile, writeFile, mkdir } from "node:fs/promises";
4
+ import { parse } from "yaml";
5
+ import { extractArchiveToDirectory } from "../core/archive.js";
6
+ import { pathExists } from "../core/fs.js";
7
+ import { ClaudeCodeProbe } from "../probes/claude-code.js";
8
+ import { generateClaudeCodePreview } from "../import/claude-code.js";
9
+ export async function importSimpleCommand(bundlePath, options) {
10
+ const cwd = process.cwd();
11
+ const homeDir = os.homedir();
12
+ const agentboxDir = path.join(cwd, ".agentbox");
13
+ console.log(`Importing agent configuration from: ${bundlePath}`);
14
+ // Step 1: Unpack
15
+ await extractArchiveToDirectory(bundlePath, agentboxDir);
16
+ console.log(`Unpacked to: ${agentboxDir}`);
17
+ // Step 2: Read snapshot
18
+ const resolvedPath = path.join(agentboxDir, "resolved.yaml");
19
+ const resolved = parse(await readFile(resolvedPath, "utf8"));
20
+ // Step 3: Detect target host
21
+ const probes = [new ClaudeCodeProbe()];
22
+ let targetHost = options.host ?? "claude-code";
23
+ if (!options.host) {
24
+ for (const probe of probes) {
25
+ const detection = await probe.detect({ homeDir, cwd, sessionMode: "portable" });
26
+ if (detection) {
27
+ targetHost = detection.host;
28
+ break;
29
+ }
30
+ }
31
+ }
32
+ console.log(`Target host: ${targetHost}`);
33
+ // Step 4: Generate preview files
34
+ const previewDir = path.join(agentboxDir, "preview");
35
+ await generateClaudeCodePreview(previewDir, resolved, {
36
+ sourceHost: resolved.host.id,
37
+ targetHost,
38
+ bindings: {},
39
+ tempDir: agentboxDir
40
+ });
41
+ console.log(`Generated preview files in: ${previewDir}`);
42
+ // Step 5: Import based on target host
43
+ if (targetHost === "claude-code") {
44
+ await importToClaudeCode(resolved, homeDir, cwd, options.force);
45
+ }
46
+ else {
47
+ throw new Error(`Unsupported target host: ${targetHost}`);
48
+ }
49
+ console.log(`\nImport complete!`);
50
+ }
51
+ async function importToClaudeCode(resolved, homeDir, cwd, force) {
52
+ const projectClaudeDir = path.join(cwd, ".claude");
53
+ const profile = resolved.profile;
54
+ const plugins = resolved.plugins;
55
+ const tools = resolved.tools;
56
+ // Import CLAUDE.md
57
+ const projectInstruction = profile.projectInstructionContent;
58
+ if (projectInstruction) {
59
+ const targetPath = path.join(cwd, "CLAUDE.md");
60
+ if (force || !(await pathExists(targetPath))) {
61
+ await writeFile(targetPath, projectInstruction, "utf8");
62
+ console.log(`Wrote: ${targetPath}`);
63
+ }
64
+ }
65
+ // Import settings.local.json (project-level, not user-level)
66
+ const settingsPath = path.join(projectClaudeDir, "settings.local.json");
67
+ let settings = {};
68
+ if (await pathExists(settingsPath)) {
69
+ settings = JSON.parse(await readFile(settingsPath, "utf8"));
70
+ }
71
+ if (plugins.enabledPlugins) {
72
+ settings.enabledPlugins = { ...(settings.enabledPlugins || {}), ...plugins.enabledPlugins };
73
+ }
74
+ if (tools.mcpServers) {
75
+ settings.mcpServers = { ...(settings.mcpServers || {}), ...replaceTemplates(tools.mcpServers, homeDir) };
76
+ }
77
+ await mkdir(projectClaudeDir, { recursive: true });
78
+ await writeFile(settingsPath, JSON.stringify(settings, null, 2), "utf8");
79
+ console.log(`Updated: ${settingsPath}`);
80
+ }
81
+ function replaceTemplates(obj, homeDir) {
82
+ const result = {};
83
+ for (const [key, value] of Object.entries(obj)) {
84
+ if (typeof value === "string") {
85
+ result[key] = value.replace(/\{\{HOME\}\}/g, homeDir);
86
+ }
87
+ else if (value && typeof value === "object") {
88
+ result[key] = replaceTemplates(value, homeDir);
89
+ }
90
+ else {
91
+ result[key] = value;
92
+ }
93
+ }
94
+ return result;
95
+ }
96
+ //# sourceMappingURL=import-simple.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-simple.js","sourceRoot":"","sources":["../../src/commands/import-simple.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAY,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM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,CAAC,GAAG,CAAC,YAAY,YAAY,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,gBAAgB,CAAC,GAA4B,EAAE,OAAe;IACrE,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;aAAM,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9C,MAAM,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC,KAAgC,EAAE,OAAO,CAAC,CAAC;QAC5E,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { InstallScope } from "../core/materialize.js";
2
+ import type { SupportedHost } from "../core/types.js";
3
+ export interface ImportCommandOptions {
4
+ host: SupportedHost;
5
+ output?: string;
6
+ scope?: InstallScope;
7
+ }
8
+ export declare function importCommand(stagingPath: string, options: ImportCommandOptions): Promise<void>;
@@ -0,0 +1,108 @@
1
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { parse } from "yaml";
4
+ import { resolveBindings } from "../core/bindings.js";
5
+ import { parseEnvObject } from "../core/env.js";
6
+ import { pathExists } from "../core/fs.js";
7
+ import { toYaml } from "../core/yaml.js";
8
+ import { buildCompatibilityReport } from "../import/compatibility.js";
9
+ import { generateClaudeCodePreview } from "../import/claude-code.js";
10
+ import { generateCodexPreview } from "../import/codex.js";
11
+ import { buildSkillInstallPlan } from "../import/install-plan.js";
12
+ import { generateOpenClawPreview } from "../import/openclaw.js";
13
+ export async function importCommand(stagingPath, options) {
14
+ const root = path.resolve(stagingPath);
15
+ const resolvedPath = path.join(root, "resolved.yaml");
16
+ const bindingsPath = path.join(root, "bindings.env");
17
+ if (!(await pathExists(resolvedPath))) {
18
+ throw new Error(`resolved.yaml not found in: ${root}`);
19
+ }
20
+ const resolved = parse(await readFile(resolvedPath, "utf8"));
21
+ const bindings = (await pathExists(bindingsPath))
22
+ ? parseEnvObject(await readFile(bindingsPath, "utf8"))
23
+ : {};
24
+ const outputDir = path.resolve(options.output ?? path.join(root, "import-preview"));
25
+ await mkdir(outputDir, { recursive: true });
26
+ const context = {
27
+ sourceHost: resolved.host.id,
28
+ targetHost: options.host,
29
+ bindings
30
+ };
31
+ const result = await generatePreviewForTarget(outputDir, resolved, context);
32
+ const bindingResolution = resolveBindings(resolved.bindings, resolvedBindingsTemplate(resolved), [
33
+ {
34
+ kind: "explicit",
35
+ name: "bindings.env",
36
+ values: bindings
37
+ }
38
+ ]);
39
+ const skillInstallPlan = buildSkillInstallPlan(resolved, context.sourceHost, context.targetHost, {
40
+ scope: options.scope
41
+ });
42
+ const skillInstallPlanPath = path.join(outputDir, "skill-install-plan.yaml");
43
+ await writeFile(skillInstallPlanPath, toYaml(skillInstallPlan), "utf8");
44
+ const compatibilityReport = buildCompatibilityReport({
45
+ resolved,
46
+ sourceHost: context.sourceHost,
47
+ targetHost: context.targetHost,
48
+ bindingResolution,
49
+ preview: result,
50
+ skillInstallPlan
51
+ });
52
+ const compatibilityReportPath = path.join(outputDir, "compatibility-report.yaml");
53
+ await writeFile(compatibilityReportPath, toYaml(compatibilityReport), "utf8");
54
+ const generatedFiles = [...result.generatedFiles, skillInstallPlanPath, compatibilityReportPath];
55
+ const warnings = [...new Set([...result.warnings, ...skillInstallPlan.warnings, ...compatibilityReport.warnings])];
56
+ const planEntries = [
57
+ ...result.plan,
58
+ {
59
+ sourceLayer: "skills",
60
+ targetPath: skillInstallPlanPath,
61
+ action: "create-preview",
62
+ risk: "low",
63
+ notes: ["Portable skill reconstruction plan with source URLs, expected hashes, and target host install hints."]
64
+ },
65
+ {
66
+ sourceLayer: "bindings, compatibility",
67
+ targetPath: compatibilityReportPath,
68
+ action: "create-preview",
69
+ risk: "low",
70
+ notes: ["Compatibility summary covering binding readiness, manual migration steps, and blocked layers."]
71
+ }
72
+ ];
73
+ await writeFile(path.join(outputDir, "import-report.yaml"), toYaml({
74
+ sourceHost: context.sourceHost,
75
+ targetHost: result.targetHost,
76
+ targetScope: skillInstallPlan.scope,
77
+ generatedFiles,
78
+ warnings
79
+ }), "utf8");
80
+ await writeFile(path.join(outputDir, "write-plan.yaml"), toYaml({
81
+ sourceHost: context.sourceHost,
82
+ targetHost: result.targetHost,
83
+ targetScope: skillInstallPlan.scope,
84
+ mode: "preview-only",
85
+ entries: planEntries,
86
+ warnings
87
+ }), "utf8");
88
+ process.stdout.write(`Import preview generated for host: ${options.host}\n`);
89
+ process.stdout.write(`Preview directory: ${result.outputDir}\n`);
90
+ process.stdout.write(`Generated files: ${generatedFiles.length}\n`);
91
+ process.stdout.write(`Warnings: ${warnings.length}\n`);
92
+ }
93
+ function resolvedBindingsTemplate(resolved) {
94
+ return Object.fromEntries(resolved.bindings.map((binding) => [binding.key, ""]));
95
+ }
96
+ async function generatePreviewForTarget(outputDir, resolved, context) {
97
+ if (context.targetHost === "codex") {
98
+ return generateCodexPreview(outputDir, resolved, context);
99
+ }
100
+ if (context.targetHost === "claude-code") {
101
+ return generateClaudeCodePreview(outputDir, resolved, context);
102
+ }
103
+ if (context.targetHost === "openclaw") {
104
+ return generateOpenClawPreview(outputDir, resolved, context);
105
+ }
106
+ throw new Error(`Import preview target is not implemented yet: ${context.targetHost}`);
107
+ }
108
+ //# sourceMappingURL=import.js.map