@@ -37,17 +37,16 @@ If the file does not exist or cannot be read, show:
3737Check the path and try again.
3838```
3939
40- Verify the file is valid JSON with the required structure:
41- - Must have a ` schema_version ` field
42- - Must have a ` profile ` field containing the profile data
43- - The ` profile ` must have at least a ` belt ` field
40+ Verify the file is valid JSON in one of these formats:
41+ - Preferred export format: must have a ` schema_version ` field and a ` profile ` field containing the profile data
42+ - Legacy/raw export format: may be the raw profile JSON itself, as long as it has at least a ` belt ` field
4443
4544If validation fails, show:
4645```
4746❌ Import failed: Invalid export file
4847
4948The file at [path] does not appear to be a valid CodeSensei export.
50- Expected fields: schema_version, profile
49+ Expected either a wrapped export (` schema_version` + ` profile`) or a raw profile JSON with `belt`.
5150
5251To create a valid export, run: /code-sensei:export
5352```
@@ -61,7 +60,7 @@ Show the user what will be imported and ask for confirmation:
6160━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
6261
6362Import file: [path]
64- Exported at: [exported_at from metadata, or "unknown"]
63+ Exported at: [exported_at from metadata, or "unknown" for legacy/raw exports ]
6564
6665Profile to import:
6766 [Belt Emoji] Belt: [belt]
@@ -92,16 +91,26 @@ Wait for the user's response.
9291 cp ~ /.code-sensei/profile.json ~ /.code-sensei/profile.json.backup 2> /dev/null && echo " backed_up" || echo " no_existing_profile"
9392 ```
9493
95- 2. Extract and write the profile data:
96- - The profile data is in the ` profile` field of the import file
97- - Write the contents of ` import_data.profile` to ` ~/.code-sensei/profile.json`
94+ 2. Create the target directory if needed:
95+ - Use the Bash tool to run:
96+ ` ` ` bash
97+ mkdir -p ~ /.code-sensei
98+ ` ` `
99+
100+ 3. Extract and write the profile data:
101+ - If the import file has a ` profile` field, write ` import_data.profile` to ` ~/.code-sensei/profile.json`
102+ - If it is a legacy/raw export, write the full file contents as-is to ` ~/.code-sensei/profile.json`
98103 - Use ` jq` if available for clean extraction:
99104 ` ` ` bash
100- jq ' .profile' [import file path] > ~ /.code-sensei/profile.json
105+ if jq -e ' .profile' [import file path] > /dev/null 2>&1 ; then
106+ jq ' .profile' [import file path] > ~ /.code-sensei/profile.json
107+ else
108+ cp [import file path] ~ /.code-sensei/profile.json
109+ fi
101110 ` ` `
102- - If jq is not available, instruct the user to manually copy the ` profile` object from the import file
111+ - If jq is not available, instruct the user to manually copy the ` profile` object from the import file, or the full file for legacy/raw exports
103112
104- 3 . Show the success message:
113+ 4 . Show the success message:
105114
106115` ` `
107116🥋 CodeSensei — Import Complete
@@ -132,6 +141,6 @@ Use /code-sensei:progress to view your full dashboard.
132141# # Important Notes
133142
134143- Always back up before overwriting — never skip the backup step
135- - The import file ' s `profile` field is the raw profile data — do not import the metadata wrapper itself
144+ - The preferred import path reads the ` profile` field from wrapped exports ; legacy/ raw exports can be copied directly
136145- If jq is unavailable, warn the user and provide manual instructions
137146- After a successful import, do NOT reset session_concepts — preserve it as-is from the imported profile
0 commit comments