@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zhangyy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,253 @@
1
+ # AgentBox
2
+
3
+ AgentBox is a portable agent environment collector and packager.
4
+
5
+ Current implementation status:
6
+
7
+ - TypeScript CLI scaffold
8
+ - core schemas for `box`, `resolved`, and `sources`
9
+ - host probe interface
10
+ - initial `collect` command
11
+ - initial `inspect` command
12
+ - initial `pack` command
13
+ - initial `unpack` command
14
+ - initial `bind` command
15
+ - initial `import` preview command
16
+ - initial `apply` command
17
+ - initial probes for `claude-code`, `codex`, `cursor`, and `openclaw`
18
+ - redaction pipeline for collected snapshots
19
+ - `bindings.template.env` generation
20
+ - `security-audit.json` generation
21
+ - import preview coverage for profile, settings, skills, and memory summary layers
22
+
23
+ ## Current Probe Coverage
24
+
25
+ ### Claude Code
26
+
27
+ - settings and plugin metadata
28
+ - env key extraction into bindings
29
+ - current project and user profile detection
30
+ - project memory summary
31
+ - session summary counts
32
+ - shared skill lock and shared skills inventory
33
+ - host artifact discovery for plans, tasks, todos, transcripts, shell snapshots, and IDE state
34
+
35
+ ### Codex
36
+
37
+ - `config.toml` preferences and MCP servers
38
+ - provider env key extraction into bindings
39
+ - version metadata from `version.json`
40
+ - project profile detection
41
+ - memory/session summary
42
+ - shared and Codex-local skill inventory
43
+ - host artifact discovery for sandbox, auth, state db, and vendor imports
44
+
45
+ ### Cursor
46
+
47
+ - `mcp.json` tool extraction
48
+ - extension inventory summary
49
+ - project/snapshot counts
50
+ - artifact discovery for analytics, browser logs, and IDE state
51
+
52
+ ## Commands
53
+
54
+ Install dependencies:
55
+
56
+ ```bash
57
+ npm install
58
+ ```
59
+
60
+ Run typecheck:
61
+
62
+ ```bash
63
+ npm run typecheck
64
+ ```
65
+
66
+ Run the smoke regression suite:
67
+
68
+ ```bash
69
+ npm run smoke
70
+ ```
71
+
72
+ Enable the networked installer path inside the smoke test:
73
+
74
+ ```bash
75
+ AGENTBOX_ENABLE_NETWORK_SMOKE=1 npm run smoke
76
+ ```
77
+
78
+ Run a collect:
79
+
80
+ ```bash
81
+ npm run collect -- --host codex --output ./snapshot-codex --name codex-box
82
+ ```
83
+
84
+ Inspect a collected snapshot:
85
+
86
+ ```bash
87
+ npx tsx src/cli.ts inspect ./snapshot-codex
88
+ ```
89
+
90
+ Pack a collected snapshot into a distributable bundle:
91
+
92
+ ```bash
93
+ npx tsx src/cli.ts pack ./snapshot-codex --output ./dist/codex-box.agentbox
94
+ ```
95
+
96
+ Unpack a bundle into a staging directory:
97
+
98
+ ```bash
99
+ npx tsx src/cli.ts unpack ./dist/codex-box.agentbox --output ./staging/codex-box
100
+ ```
101
+
102
+ Resolve bindings for a staging directory:
103
+
104
+ ```bash
105
+ npx tsx src/cli.ts bind ./staging/codex-box --set APIROUTER_API_KEY=your-key
106
+ ```
107
+
108
+ Resolve bindings from a dotenv file and fail if required values are still missing:
109
+
110
+ ```bash
111
+ npx tsx src/cli.ts bind ./staging/codex-box --env-file ./.env.agentbox --require-complete
112
+ ```
113
+
114
+ Generate a host-native import preview from a staging directory:
115
+
116
+ ```bash
117
+ npx tsx src/cli.ts import ./staging/claude-box --host codex --output ./import-preview/claude-to-codex
118
+ ```
119
+
120
+ Generate a project-scoped preview instead of the host default:
121
+
122
+ ```bash
123
+ npx tsx src/cli.ts import ./staging/claude-box --host codex --scope project --output ./import-preview/claude-to-codex-project
124
+ ```
125
+
126
+ Apply an import preview into a target directory:
127
+
128
+ ```bash
129
+ npx tsx src/cli.ts apply ./import-preview/claude-to-codex --execute --target-root ./apply-targets/claude-to-codex
130
+ ```
131
+
132
+ Apply directly into real host-style paths under a project root:
133
+
134
+ ```bash
135
+ npx tsx src/cli.ts apply ./import-preview/claude-to-codex-project --execute --real-home --project-root ./my-project --scope project
136
+ ```
137
+
138
+ Install skills from a generated skill install plan:
139
+
140
+ ```bash
141
+ npx tsx src/cli.ts install-skills ./import-preview/claude-to-codex --execute --target-root ./skill-targets/claude-to-codex
142
+ ```
143
+
144
+ Install skills into real host-style paths under a project root:
145
+
146
+ ```bash
147
+ npx tsx src/cli.ts install-skills ./import-preview/claude-to-codex-project --execute --real-home --project-root ./my-project --scope project
148
+ ```
149
+
150
+ The generated import preview now includes host-native config plus portable layer files for:
151
+
152
+ - `skills.preview.yaml`
153
+ - `memory.preview.yaml`
154
+ - `memory.preview.md`
155
+ - `session.preview.yaml`
156
+ - `session.preview.md`
157
+ - `skill-install-plan.yaml`
158
+ - `compatibility-report.yaml`
159
+ - host summary files such as `import-summary.yaml`
160
+
161
+ `skill-install-plan.yaml` is the current bridge between portable skill metadata and real reconstruction. It records source URLs, expected hashes when available, target-host install roots, and manual-review items for skills that cannot yet be reinstalled automatically.
162
+
163
+ `install-skills` executes that plan into an explicit target directory. It currently clones source repositories, extracts the skill folder pointed to by `skillPath`, and writes an `agentbox-skill-install-report.yaml` file. It does not mutate real host home directories automatically.
164
+
165
+ When activation succeeds, AgentBox also writes `agentbox-skill-activation-map.yaml` so the target directory clearly shows which host-visible skill entries were linked or copied into place.
166
+
167
+ `compatibility-report.yaml` summarizes whether the preview is blocked, ready, or ready-with-warnings, including missing required bindings and manual migration steps.
168
+
169
+ Session collection modes:
170
+
171
+ - `portable`: counts + compact recent excerpts suitable for safe sharing
172
+ - `rich`: more recent prompts/plans/todos for stronger context handoff
173
+ - `raw`: recent raw session entries/documents embedded into the snapshot after redaction
174
+
175
+ Example:
176
+
177
+ ```bash
178
+ npx tsx src/cli.ts collect --session-mode rich --output ./snapshot-rich
179
+ ```
180
+
181
+ Default install scope by host:
182
+
183
+ - `codex`: `user`
184
+ - `claude-code`: `user`
185
+ - `openclaw`: `project`
186
+
187
+ You can override that default with `--scope user` or `--scope project` during `import`, `apply`, and `install-skills`.
188
+
189
+ ## Current Output
190
+
191
+ `collect` writes a directory snapshot with:
192
+
193
+ - `box.yaml`
194
+ - `resolved.yaml`
195
+ - `sources.yaml`
196
+ - `layers/*.yaml`
197
+ - `bindings.template.env`
198
+ - `meta/security-audit.json`
199
+
200
+ Example snapshots already generated in this workspace:
201
+
202
+ - `snapshot-claude/`
203
+ - `snapshot-codex/`
204
+ - `snapshot-cursor/`
205
+
206
+ Example bundles already generated in this workspace:
207
+
208
+ - `dist/codex-box.agentbox`
209
+ - `dist/claude-box.agentbox`
210
+
211
+ Example unpacked staging output already generated in this workspace:
212
+
213
+ - `staging/codex-box/`
214
+ - `staging/claude-box/`
215
+
216
+ Example import previews already generated in this workspace:
217
+
218
+ - `import-preview/claude-to-codex/`
219
+ - `import-preview/codex-to-claude/`
220
+ - `import-preview/claude-to-openclaw/`
221
+
222
+ Example apply targets already generated in this workspace:
223
+
224
+ - `apply-targets/claude-to-codex/`
225
+
226
+ ## Current Limitations
227
+
228
+ - `unpack` only extracts to staging; it does not import into host-native locations yet
229
+ - `bind` is currently non-interactive; it resolves values from `--set` and optional process env
230
+ - host probes are partial and intentionally conservative
231
+ - unknown host artifact fallback is implemented at the metadata level
232
+ - import currently generates host-native preview files only; it does not write into real host config locations yet
233
+ - memory import is currently a portable summary/inventory preview, not a full semantic memory replay
234
+ - skills import now includes a reconstruction plan and a target-root installer, but still does not mutate real host home directories automatically
235
+ - `apply` and `install-skills` can now target real host-style paths, but the safest default remains sandbox mode
236
+ - compatibility is reported explicitly, but some host behaviors still require manual review
237
+ - cross-host adapters are currently implemented only for preview targets `codex`, `claude-code`, and `openclaw`
238
+ - full real-home user-scope installs should still be used carefully, because they write into live host paths
239
+
240
+ ## Current Safety Behavior
241
+
242
+ - machine-specific paths are normalized into placeholders like `{{HOME}}` and `{{PROJECT_ROOT}}`
243
+ - token-like values are redacted if they appear in collected string fields
244
+ - live secrets are not written into `bindings.template.env`
245
+ - required bindings are emitted as placeholder keys only
246
+ - every redaction is logged in `meta/security-audit.json`
247
+
248
+ ## Important Design Notes
249
+
250
+ - secrets are not exported as live values
251
+ - collector output is organized by normalized layers
252
+ - the goal is not to enumerate every host field in advance
253
+ - future host changes should be handled through structured extraction plus artifact fallback
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { exportCommand } from "./commands/export.js";
4
+ import { importSimpleCommand } from "./commands/import-simple.js";
5
+ import { inspectCommand } from "./commands/inspect.js";
6
+ const program = new Command();
7
+ program
8
+ .name("agentbox")
9
+ .description("Portable agent environment collector and packager.")
10
+ .version("0.1.0");
11
+ program
12
+ .command("export")
13
+ .description("Export current project's agent configuration to a .agentbox file.")
14
+ .option("--output <file>", "Output .agentbox file path")
15
+ .option("--host <host>", "Force a host probe", parseHost)
16
+ .action(async (options) => {
17
+ await exportCommand(options);
18
+ });
19
+ program
20
+ .command("import")
21
+ .description("Import a .agentbox file into current environment.")
22
+ .argument("<file>", "Path to .agentbox file")
23
+ .option("--host <host>", "Target host to import into", parseHost)
24
+ .option("--force", "Overwrite existing files")
25
+ .action(async (bundlePath, options) => {
26
+ await importSimpleCommand(bundlePath, options);
27
+ });
28
+ program
29
+ .command("inspect")
30
+ .description("Inspect a collected AgentBox snapshot directory.")
31
+ .argument("<path>", "Path to a collected snapshot directory")
32
+ .action(async (snapshotPath) => {
33
+ await inspectCommand(snapshotPath);
34
+ });
35
+ program.parseAsync(process.argv);
36
+ function parseHost(value) {
37
+ const supportedHosts = ["claude-code", "unknown"];
38
+ if (!supportedHosts.includes(value)) {
39
+ throw new Error(`Unsupported host: ${value}`);
40
+ }
41
+ return value;
42
+ }
43
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACl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AAC,aAAa,EAAE,SAAS,CAAC,CAAC;IACnE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAsB,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,qBAAqB,KAAK,EAAE,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,KAAsB,CAAC;AAChC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { BoxManifest, ResolvedSnapshot, SessionCaptureMode, SourceSnapshot, SupportedHost } from "../core/types.js";
2
+ import type { HostProbe } from "./probe.js";
3
+ export interface CollectOptions {
4
+ host?: SupportedHost;
5
+ outputDir: string;
6
+ boxName: string;
7
+ sessionMode?: SessionCaptureMode;
8
+ }
9
+ export interface CollectResult {
10
+ manifest: BoxManifest;
11
+ resolved: ResolvedSnapshot;
12
+ sources: SourceSnapshot;
13
+ outputDir: string;
14
+ }
15
+ export declare function runCollect(probes: HostProbe[], options: CollectOptions): Promise<CollectResult>;
@@ -0,0 +1,118 @@
1
+ import os from "node:os";
2
+ import path from "node:path";
3
+ import { mkdir, writeFile, copyFile } from "node:fs/promises";
4
+ import { createBoxManifest, createEmptyResolvedSnapshot, createEmptySources } from "../core/schemas.js";
5
+ import { toYaml } from "../core/yaml.js";
6
+ import { redactCollectedData } from "../core/redaction.js";
7
+ export async function runCollect(probes, options) {
8
+ const context = {
9
+ cwd: process.cwd(),
10
+ homeDir: os.homedir(),
11
+ sessionMode: options.sessionMode ?? "portable"
12
+ };
13
+ const probe = await selectProbe(probes, context, options.host);
14
+ const collected = probe
15
+ ? await probe.collect(context)
16
+ : {
17
+ resolved: createEmptyResolvedSnapshot("unknown"),
18
+ sources: createEmptySources()
19
+ };
20
+ const manifest = createBoxManifest({
21
+ name: options.boxName,
22
+ sourceHost: probe?.host ?? "unknown",
23
+ sourceVersion: collected.resolved.host.version
24
+ });
25
+ const redacted = redactCollectedData({
26
+ cwd: context.cwd,
27
+ homeDir: context.homeDir
28
+ }, collected.resolved, collected.sources);
29
+ await writeSnapshot(options.outputDir, manifest, redacted.resolved, redacted.sources, redacted.bindingsTemplate, redacted.audit);
30
+ return {
31
+ manifest,
32
+ resolved: redacted.resolved,
33
+ sources: redacted.sources,
34
+ outputDir: options.outputDir
35
+ };
36
+ }
37
+ async function selectProbe(probes, context, requestedHost) {
38
+ if (requestedHost && requestedHost !== "unknown") {
39
+ return probes.find((probe) => probe.host === requestedHost) ?? null;
40
+ }
41
+ const detections = await Promise.all(probes.map(async (probe) => {
42
+ const detection = await probe.detect(context);
43
+ return detection ? { probe, detection } : null;
44
+ }));
45
+ const candidates = detections.filter((entry) => entry !== null);
46
+ candidates.sort((left, right) => right.detection.confidence - left.detection.confidence);
47
+ return candidates[0]?.probe ?? null;
48
+ }
49
+ async function writeSnapshot(outputDir, manifest, resolved, sources, bindingsTemplate, audit) {
50
+ await mkdir(path.join(outputDir, "layers"), { recursive: true });
51
+ await mkdir(path.join(outputDir, "meta"), { recursive: true });
52
+ await mkdir(path.join(outputDir, "session"), { recursive: true });
53
+ await writeFile(path.join(outputDir, "box.yaml"), toYaml(manifest), "utf8");
54
+ await writeFile(path.join(outputDir, "resolved.yaml"), toYaml(resolved), "utf8");
55
+ await writeFile(path.join(outputDir, "sources.yaml"), toYaml(sources), "utf8");
56
+ await writeFile(path.join(outputDir, "bindings.template.env"), bindingsTemplate, "utf8");
57
+ await writeFile(path.join(outputDir, "meta", "security-audit.json"), JSON.stringify(audit, null, 2), "utf8");
58
+ await writeLayer(outputDir, "profile.yaml", resolved.profile);
59
+ await writeLayer(outputDir, "memory.yaml", resolved.memory);
60
+ await writeLayer(outputDir, "session.yaml", resolved.session);
61
+ await writeLayer(outputDir, "skills.yaml", resolved.skills);
62
+ await writeLayer(outputDir, "plugins.yaml", resolved.plugins);
63
+ await writeLayer(outputDir, "tools.yaml", resolved.tools);
64
+ await writeLayer(outputDir, "preferences.yaml", resolved.preferences);
65
+ await writeLayer(outputDir, "security-policy.yaml", resolved.securityPolicy);
66
+ await writeLayer(outputDir, "hooks.yaml", resolved.hooks);
67
+ await writeLayer(outputDir, "runtime.yaml", resolved.runtime);
68
+ await writeLayer(outputDir, "bindings.yaml", { bindings: resolved.bindings });
69
+ await writeLayer(outputDir, "host-artifacts.yaml", { artifacts: resolved.hostArtifacts });
70
+ // Copy session files
71
+ const session = resolved.session;
72
+ const transcriptFiles = session.transcriptFiles;
73
+ const planFiles = session.planFiles;
74
+ const historyFile = session.historyFile;
75
+ if (transcriptFiles) {
76
+ for (const file of transcriptFiles) {
77
+ const sourcePath = file.path.replace(/\{\{HOME\}\}/g, os.homedir());
78
+ const fileName = path.basename(sourcePath);
79
+ const destPath = path.join(outputDir, "session", "transcripts", fileName);
80
+ await mkdir(path.dirname(destPath), { recursive: true });
81
+ try {
82
+ await copyFile(sourcePath, destPath);
83
+ }
84
+ catch {
85
+ // Ignore copy errors
86
+ }
87
+ }
88
+ }
89
+ if (planFiles) {
90
+ for (const file of planFiles) {
91
+ const sourcePath = file.path.replace(/\{\{HOME\}\}/g, os.homedir());
92
+ const fileName = path.basename(sourcePath);
93
+ const destPath = path.join(outputDir, "session", "plans", fileName);
94
+ await mkdir(path.dirname(destPath), { recursive: true });
95
+ try {
96
+ await copyFile(sourcePath, destPath);
97
+ }
98
+ catch {
99
+ // Ignore copy errors
100
+ }
101
+ }
102
+ }
103
+ if (historyFile) {
104
+ const sourcePath = historyFile.replace(/\{\{HOME\}\}/g, os.homedir());
105
+ const destPath = path.join(outputDir, "session", "history.jsonl");
106
+ await mkdir(path.dirname(destPath), { recursive: true });
107
+ try {
108
+ await copyFile(sourcePath, destPath);
109
+ }
110
+ catch {
111
+ // Ignore copy errors
112
+ }
113
+ }
114
+ }
115
+ async function writeLayer(outputDir, filename, value) {
116
+ await writeFile(path.join(outputDir, "layers", filename), toYaml(value), "utf8");
117
+ }
118
+ //# sourceMappingURL=collector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collector.js","sourceRoot":"","sources":["../../src/collector/collector.ts"],"names":[],"mappings":"AAAA,O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AAW,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACtE,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;QAClE,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACvC,CAAC;QAAC,MAAM,CAAC;YACP,qBAAqB;QACvB,CAAC;IACH,CAAC;AACH,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,SAAiB,EAAE,QAAgB,EAAE,KAAc;IAC3E,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;AACnF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const COLLECTOR_LAYERS: readonly ["profile", "memory", "session", "skills", "plugins", "tools", "preferences", "securityPolicy", "hooks", "runtime", "bindings", "hostArtifacts"];
2
+ export type CollectorLayer = (typeof COLLECTOR_LAYERS)[number];
@@ -0,0 +1,15 @@
1
+ export const COLLECTOR_LAYERS = [
2
+ "profile",
3
+ "memory",
4
+ "session",
5
+ "skills",
6
+ "plugins",
7
+ "tools",
8
+ "preferences",
9
+ "securityPolicy",
10
+ "hooks",
11
+ "runtime",
12
+ "bindings",
13
+ "hostArtifacts"
14
+ ];
15
+ //# sourceMappingURL=known-layers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"known-layers.js","sourceRoot":"","sources":["../../src/collector/known-layers.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,SAAS;IACT,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,SAAS;IACT,OAAO;IACP,aAAa;IACb,gBAAgB;IAChB,OAAO;IACP,SAAS;IACT,UAAU;IACV,eAAe;CACP,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { ResolvedSnapshot, SessionCaptureMode, SourceSnapshot, SupportedHost } from "../core/types.js";
2
+ export interface ProbeContext {
3
+ cwd: string;
4
+ homeDir: string;
5
+ sessionMode: SessionCaptureMode;
6
+ }
7
+ export interface HostDetection {
8
+ host: SupportedHost;
9
+ confidence: number;
10
+ reason: string;
11
+ }
12
+ export interface HostProbe {
13
+ readonly host: SupportedHost;
14
+ detect(context: ProbeContext): Promise<HostDetection | null>;
15
+ collect(context: ProbeContext): Promise<{
16
+ resolved: ResolvedSnapshot;
17
+ sources: SourceSnapshot;
18
+ }>;
19
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=probe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe.js","sourceRoot":"","sources":["../../src/collector/probe.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import type { InstallScope } from "../core/materialize.js";
2
+ export interface ApplyCommandOptions {
3
+ execute?: boolean;
4
+ targetRoot?: string;
5
+ realHome?: boolean;
6
+ projectRoot?: string;
7
+ scope?: InstallScope;
8
+ force?: boolean;
9
+ }
10
+ export declare function applyCommand(importPreviewPath: string, options: ApplyCommandOptions): Promise<void>;