@dgxo/mashadevcli 1.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 (140) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +393 -0
  3. package/bundle/builtin/skill-creator/SKILL.md +382 -0
  4. package/bundle/builtin/skill-creator/scripts/init_skill.cjs +239 -0
  5. package/bundle/builtin/skill-creator/scripts/package_skill.cjs +131 -0
  6. package/bundle/builtin/skill-creator/scripts/validate_skill.cjs +131 -0
  7. package/bundle/docs/CONTRIBUTING.md +1 -0
  8. package/bundle/docs/admin/enterprise-controls.md +115 -0
  9. package/bundle/docs/assets/connected_devtools.png +0 -0
  10. package/bundle/docs/assets/gemini-screenshot.png +0 -0
  11. package/bundle/docs/assets/monitoring-dashboard-logs.png +0 -0
  12. package/bundle/docs/assets/monitoring-dashboard-metrics.png +0 -0
  13. package/bundle/docs/assets/monitoring-dashboard-overview.png +0 -0
  14. package/bundle/docs/assets/release_patch.png +0 -0
  15. package/bundle/docs/assets/theme-ansi-light.png +0 -0
  16. package/bundle/docs/assets/theme-ansi.png +0 -0
  17. package/bundle/docs/assets/theme-atom-one.png +0 -0
  18. package/bundle/docs/assets/theme-ayu-light.png +0 -0
  19. package/bundle/docs/assets/theme-ayu.png +0 -0
  20. package/bundle/docs/assets/theme-custom.png +0 -0
  21. package/bundle/docs/assets/theme-default-light.png +0 -0
  22. package/bundle/docs/assets/theme-default.png +0 -0
  23. package/bundle/docs/assets/theme-dracula.png +0 -0
  24. package/bundle/docs/assets/theme-github-light.png +0 -0
  25. package/bundle/docs/assets/theme-github.png +0 -0
  26. package/bundle/docs/assets/theme-google-light.png +0 -0
  27. package/bundle/docs/assets/theme-xcode-light.png +0 -0
  28. package/bundle/docs/changelogs/index.md +867 -0
  29. package/bundle/docs/changelogs/latest.md +208 -0
  30. package/bundle/docs/changelogs/preview.md +187 -0
  31. package/bundle/docs/cli/checkpointing.md +93 -0
  32. package/bundle/docs/cli/cli-reference.md +115 -0
  33. package/bundle/docs/cli/creating-skills.md +80 -0
  34. package/bundle/docs/cli/custom-commands.md +327 -0
  35. package/bundle/docs/cli/enterprise.md +604 -0
  36. package/bundle/docs/cli/gemini-ignore.md +71 -0
  37. package/bundle/docs/cli/gemini-md.md +116 -0
  38. package/bundle/docs/cli/generation-settings.md +210 -0
  39. package/bundle/docs/cli/headless.md +50 -0
  40. package/bundle/docs/cli/model-routing.md +42 -0
  41. package/bundle/docs/cli/model.md +53 -0
  42. package/bundle/docs/cli/plan-mode.md +375 -0
  43. package/bundle/docs/cli/rewind.md +51 -0
  44. package/bundle/docs/cli/sandbox.md +257 -0
  45. package/bundle/docs/cli/session-management.md +184 -0
  46. package/bundle/docs/cli/settings.md +165 -0
  47. package/bundle/docs/cli/skills.md +134 -0
  48. package/bundle/docs/cli/system-prompt.md +125 -0
  49. package/bundle/docs/cli/telemetry.md +922 -0
  50. package/bundle/docs/cli/themes.md +269 -0
  51. package/bundle/docs/cli/token-caching.md +20 -0
  52. package/bundle/docs/cli/trusted-folders.md +126 -0
  53. package/bundle/docs/cli/tutorials/automation.md +283 -0
  54. package/bundle/docs/cli/tutorials/file-management.md +142 -0
  55. package/bundle/docs/cli/tutorials/mcp-setup.md +113 -0
  56. package/bundle/docs/cli/tutorials/memory-management.md +126 -0
  57. package/bundle/docs/cli/tutorials/session-management.md +105 -0
  58. package/bundle/docs/cli/tutorials/shell-commands.md +107 -0
  59. package/bundle/docs/cli/tutorials/skills-getting-started.md +110 -0
  60. package/bundle/docs/cli/tutorials/task-planning.md +93 -0
  61. package/bundle/docs/cli/tutorials/web-tools.md +78 -0
  62. package/bundle/docs/core/index.md +107 -0
  63. package/bundle/docs/core/remote-agents.md +84 -0
  64. package/bundle/docs/core/subagents.md +307 -0
  65. package/bundle/docs/examples/proxy-script.md +83 -0
  66. package/bundle/docs/extensions/best-practices.md +188 -0
  67. package/bundle/docs/extensions/index.md +61 -0
  68. package/bundle/docs/extensions/reference.md +333 -0
  69. package/bundle/docs/extensions/releasing.md +154 -0
  70. package/bundle/docs/extensions/writing-extensions.md +308 -0
  71. package/bundle/docs/get-started/authentication.md +402 -0
  72. package/bundle/docs/get-started/examples.md +139 -0
  73. package/bundle/docs/get-started/gemini-3.md +115 -0
  74. package/bundle/docs/get-started/index.md +82 -0
  75. package/bundle/docs/get-started/installation.md +174 -0
  76. package/bundle/docs/hooks/best-practices.md +709 -0
  77. package/bundle/docs/hooks/index.md +164 -0
  78. package/bundle/docs/hooks/reference.md +330 -0
  79. package/bundle/docs/hooks/writing-hooks.md +474 -0
  80. package/bundle/docs/ide-integration/ide-companion-spec.md +267 -0
  81. package/bundle/docs/ide-integration/index.md +224 -0
  82. package/bundle/docs/index.md +141 -0
  83. package/bundle/docs/integration-tests.md +211 -0
  84. package/bundle/docs/issue-and-pr-automation.md +172 -0
  85. package/bundle/docs/local-development.md +134 -0
  86. package/bundle/docs/mermaid/context.mmd +103 -0
  87. package/bundle/docs/mermaid/render-path.mmd +64 -0
  88. package/bundle/docs/npm.md +62 -0
  89. package/bundle/docs/redirects.json +20 -0
  90. package/bundle/docs/reference/commands.md +526 -0
  91. package/bundle/docs/reference/configuration.md +1786 -0
  92. package/bundle/docs/reference/keyboard-shortcuts.md +164 -0
  93. package/bundle/docs/reference/memport.md +246 -0
  94. package/bundle/docs/reference/policy-engine.md +364 -0
  95. package/bundle/docs/reference/tools.md +106 -0
  96. package/bundle/docs/release-confidence.md +164 -0
  97. package/bundle/docs/releases.md +540 -0
  98. package/bundle/docs/resources/faq.md +175 -0
  99. package/bundle/docs/resources/quota-and-pricing.md +165 -0
  100. package/bundle/docs/resources/tos-privacy.md +102 -0
  101. package/bundle/docs/resources/troubleshooting.md +176 -0
  102. package/bundle/docs/resources/uninstall.md +56 -0
  103. package/bundle/docs/sidebar.json +233 -0
  104. package/bundle/docs/tools/activate-skill.md +43 -0
  105. package/bundle/docs/tools/ask-user.md +95 -0
  106. package/bundle/docs/tools/file-system.md +129 -0
  107. package/bundle/docs/tools/internal-docs.md +46 -0
  108. package/bundle/docs/tools/mcp-server.md +1150 -0
  109. package/bundle/docs/tools/memory.md +35 -0
  110. package/bundle/docs/tools/planning.md +58 -0
  111. package/bundle/docs/tools/shell.md +216 -0
  112. package/bundle/docs/tools/todos.md +35 -0
  113. package/bundle/docs/tools/web-fetch.md +35 -0
  114. package/bundle/docs/tools/web-search.md +32 -0
  115. package/bundle/docs/update/update-guide.md +111 -0
  116. package/bundle/masha.js +563471 -0
  117. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/client/main.js +89 -0
  118. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/_client-assets.d.ts +7 -0
  119. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/_client-assets.js +9 -0
  120. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/_client-assets.js.map +1 -0
  121. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/index.d.ts +48 -0
  122. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/index.js +299 -0
  123. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/index.js.map +1 -0
  124. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/types.d.ts +36 -0
  125. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/types.js +7 -0
  126. package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/types.js.map +1 -0
  127. package/bundle/node_modules/@dgxo/mashadevcli-devtools/package.json +32 -0
  128. package/bundle/policies/conseca.toml +6 -0
  129. package/bundle/policies/discovered.toml +8 -0
  130. package/bundle/policies/plan.toml +109 -0
  131. package/bundle/policies/read-only.toml +53 -0
  132. package/bundle/policies/write.toml +80 -0
  133. package/bundle/policies/yolo.toml +54 -0
  134. package/bundle/sandbox-macos-permissive-open.sb +27 -0
  135. package/bundle/sandbox-macos-permissive-proxied.sb +37 -0
  136. package/bundle/sandbox-macos-restrictive-open.sb +96 -0
  137. package/bundle/sandbox-macos-restrictive-proxied.sb +98 -0
  138. package/bundle/sandbox-macos-strict-open.sb +131 -0
  139. package/bundle/sandbox-macos-strict-proxied.sb +133 -0
  140. package/package.json +169 -0
@@ -0,0 +1,164 @@
1
+ # Gemini CLI keyboard shortcuts
2
+
3
+ Gemini CLI ships with a set of default keyboard shortcuts for editing input,
4
+ navigating history, and controlling the UI. Use this reference to learn the
5
+ available combinations.
6
+
7
+ <!-- KEYBINDINGS-AUTOGEN:START -->
8
+
9
+ #### Basic Controls
10
+
11
+ | Action | Keys |
12
+ | --------------------------------------------------------------- | --------------------- |
13
+ | Confirm the current selection or choice. | `Enter` |
14
+ | Dismiss dialogs or cancel the current focus. | `Esc`<br />`Ctrl + [` |
15
+ | Cancel the current request or quit the CLI when input is empty. | `Ctrl + C` |
16
+ | Exit the CLI when the input buffer is empty. | `Ctrl + D` |
17
+
18
+ #### Cursor Movement
19
+
20
+ | Action | Keys |
21
+ | ------------------------------------------- | ------------------------------------------------------------ |
22
+ | Move the cursor to the start of the line. | `Ctrl + A`<br />`Home (no Shift, Ctrl)` |
23
+ | Move the cursor to the end of the line. | `Ctrl + E`<br />`End (no Shift, Ctrl)` |
24
+ | Move the cursor up one line. | `Up Arrow (no Shift, Alt, Ctrl, Cmd)` |
25
+ | Move the cursor down one line. | `Down Arrow (no Shift, Alt, Ctrl, Cmd)` |
26
+ | Move the cursor one character to the left. | `Left Arrow (no Shift, Alt, Ctrl, Cmd)` |
27
+ | Move the cursor one character to the right. | `Right Arrow (no Shift, Alt, Ctrl, Cmd)`<br />`Ctrl + F` |
28
+ | Move the cursor one word to the left. | `Ctrl + Left Arrow`<br />`Alt + Left Arrow`<br />`Alt + B` |
29
+ | Move the cursor one word to the right. | `Ctrl + Right Arrow`<br />`Alt + Right Arrow`<br />`Alt + F` |
30
+
31
+ #### Editing
32
+
33
+ | Action | Keys |
34
+ | ------------------------------------------------ | ---------------------------------------------------------------- |
35
+ | Delete from the cursor to the end of the line. | `Ctrl + K` |
36
+ | Delete from the cursor to the start of the line. | `Ctrl + U` |
37
+ | Clear all text in the input field. | `Ctrl + C` |
38
+ | Delete the previous word. | `Ctrl + Backspace`<br />`Alt + Backspace`<br />`Ctrl + W` |
39
+ | Delete the next word. | `Ctrl + Delete`<br />`Alt + Delete`<br />`Alt + D` |
40
+ | Delete the character to the left. | `Backspace`<br />`Ctrl + H` |
41
+ | Delete the character to the right. | `Delete`<br />`Ctrl + D` |
42
+ | Undo the most recent text edit. | `Cmd + Z (no Shift)`<br />`Alt + Z (no Shift)` |
43
+ | Redo the most recent undone text edit. | `Shift + Ctrl + Z`<br />`Shift + Cmd + Z`<br />`Shift + Alt + Z` |
44
+
45
+ #### Scrolling
46
+
47
+ | Action | Keys |
48
+ | ------------------------ | --------------------------------- |
49
+ | Scroll content up. | `Shift + Up Arrow` |
50
+ | Scroll content down. | `Shift + Down Arrow` |
51
+ | Scroll to the top. | `Ctrl + Home`<br />`Shift + Home` |
52
+ | Scroll to the bottom. | `Ctrl + End`<br />`Shift + End` |
53
+ | Scroll up by one page. | `Page Up` |
54
+ | Scroll down by one page. | `Page Down` |
55
+
56
+ #### History & Search
57
+
58
+ | Action | Keys |
59
+ | -------------------------------------------- | --------------------- |
60
+ | Show the previous entry in history. | `Ctrl + P (no Shift)` |
61
+ | Show the next entry in history. | `Ctrl + N (no Shift)` |
62
+ | Start reverse search through history. | `Ctrl + R` |
63
+ | Submit the selected reverse-search match. | `Enter (no Ctrl)` |
64
+ | Accept a suggestion while reverse searching. | `Tab (no Shift)` |
65
+ | Browse and rewind previous interactions. | `Double Esc` |
66
+
67
+ #### Navigation
68
+
69
+ | Action | Keys |
70
+ | -------------------------------------------------- | ------------------------------------------- |
71
+ | Move selection up in lists. | `Up Arrow (no Shift)` |
72
+ | Move selection down in lists. | `Down Arrow (no Shift)` |
73
+ | Move up within dialog options. | `Up Arrow (no Shift)`<br />`K (no Shift)` |
74
+ | Move down within dialog options. | `Down Arrow (no Shift)`<br />`J (no Shift)` |
75
+ | Move to the next item or question in a dialog. | `Tab (no Shift)` |
76
+ | Move to the previous item or question in a dialog. | `Shift + Tab` |
77
+
78
+ #### Suggestions & Completions
79
+
80
+ | Action | Keys |
81
+ | --------------------------------------- | -------------------------------------------------- |
82
+ | Accept the inline suggestion. | `Tab (no Shift)`<br />`Enter (no Ctrl)` |
83
+ | Move to the previous completion option. | `Up Arrow (no Shift)`<br />`Ctrl + P (no Shift)` |
84
+ | Move to the next completion option. | `Down Arrow (no Shift)`<br />`Ctrl + N (no Shift)` |
85
+ | Expand an inline suggestion. | `Right Arrow` |
86
+ | Collapse an inline suggestion. | `Left Arrow` |
87
+
88
+ #### Text Input
89
+
90
+ | Action | Keys |
91
+ | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
92
+ | Submit the current prompt. | `Enter (no Shift, Alt, Ctrl, Cmd)` |
93
+ | Insert a newline without submitting. | `Ctrl + Enter`<br />`Cmd + Enter`<br />`Alt + Enter`<br />`Shift + Enter`<br />`Ctrl + J` |
94
+ | Open the current prompt or the plan in an external editor. | `Ctrl + X` |
95
+ | Paste from the clipboard. | `Ctrl + V`<br />`Cmd + V`<br />`Alt + V` |
96
+
97
+ #### App Controls
98
+
99
+ | Action | Keys |
100
+ | -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
101
+ | Toggle detailed error information. | `F12` |
102
+ | Toggle the full TODO list. | `Ctrl + T` |
103
+ | Show IDE context details. | `Ctrl + G` |
104
+ | Toggle Markdown rendering. | `Alt + M` |
105
+ | Toggle copy mode when in alternate buffer mode. | `Ctrl + S` |
106
+ | Toggle YOLO (auto-approval) mode for tool calls. | `Ctrl + Y` |
107
+ | Cycle through approval modes: default (prompt), auto_edit (auto-approve edits), and plan (read-only). Plan mode is skipped when the agent is busy. | `Shift + Tab` |
108
+ | Expand and collapse blocks of content when not in alternate buffer mode. | `Ctrl + O` |
109
+ | Expand or collapse a paste placeholder when cursor is over placeholder. | `Ctrl + O` |
110
+ | Toggle current background shell visibility. | `Ctrl + B` |
111
+ | Toggle background shell list. | `Ctrl + L` |
112
+ | Kill the active background shell. | `Ctrl + K` |
113
+ | Confirm selection in background shell list. | `Enter` |
114
+ | Dismiss background shell list. | `Esc` |
115
+ | Move focus from background shell to Gemini. | `Shift + Tab` |
116
+ | Move focus from background shell list to Gemini. | `Tab (no Shift)` |
117
+ | Show warning when trying to move focus away from background shell. | `Tab (no Shift)` |
118
+ | Show warning when trying to move focus away from shell input. | `Tab (no Shift)` |
119
+ | Move focus from Gemini to the active shell. | `Tab (no Shift)` |
120
+ | Move focus from the shell back to Gemini. | `Shift + Tab` |
121
+ | Clear the terminal screen and redraw the UI. | `Ctrl + L` |
122
+ | Restart the application. | `R` |
123
+ | Suspend the CLI and move it to the background. | `Ctrl + Z` |
124
+
125
+ <!-- KEYBINDINGS-AUTOGEN:END -->
126
+
127
+ ## Additional context-specific shortcuts
128
+
129
+ - `Option+B/F/M` (macOS only): Are interpreted as `Cmd+B/F/M` even if your
130
+ terminal isn't configured to send Meta with Option.
131
+ - `!` on an empty prompt: Enter or exit shell mode.
132
+ - `?` on an empty prompt: Toggle the shortcuts panel above the input. Press
133
+ `Esc`, `Backspace`, any printable key, or a registered app hotkey to close it.
134
+ The panel also auto-hides while the agent is running/streaming or when
135
+ action-required dialogs are shown. Press `?` again to close the panel and
136
+ insert a `?` into the prompt.
137
+ - `Tab` + `Tab` (while typing in the prompt): Toggle between minimal and full UI
138
+ details when no completion/search interaction is active. The selected mode is
139
+ remembered for future sessions. Full UI remains the default on first run, and
140
+ single `Tab` keeps its existing completion/focus behavior.
141
+ - `Shift + Tab` (while typing in the prompt): Cycle approval modes: default,
142
+ auto-edit, and plan (skipped when agent is busy).
143
+ - `\` (at end of a line) + `Enter`: Insert a newline without leaving single-line
144
+ mode.
145
+ - `Esc` pressed twice quickly: Clear the input prompt if it is not empty,
146
+ otherwise browse and rewind previous interactions.
147
+ - `Up Arrow` / `Down Arrow`: When the cursor is at the top or bottom of a
148
+ single-line input, navigate backward or forward through prompt history.
149
+ - `Number keys (1-9, multi-digit)` inside selection dialogs: Jump directly to
150
+ the numbered radio option and confirm when the full number is entered.
151
+ - `Ctrl + O`: Expand or collapse paste placeholders (`[Pasted Text: X lines]`)
152
+ inline when the cursor is over the placeholder.
153
+ - `Double-click` on a paste placeholder (alternate buffer mode only): Expand to
154
+ view full content inline. Double-click again to collapse.
155
+
156
+ ## Limitations
157
+
158
+ - On [Windows Terminal](https://en.wikipedia.org/wiki/Windows_Terminal):
159
+ - `shift+enter` is not supported.
160
+ - `shift+tab`
161
+ [is not supported](https://github.com/DGameGT/mashadev-cli/issues/20314)
162
+ on Node 20 and earlier versions of Node 22.
163
+ - On macOS's [Terminal](<https://en.wikipedia.org/wiki/Terminal_(macOS)>):
164
+ - `shift+enter` is not supported.
@@ -0,0 +1,246 @@
1
+ # Memory Import Processor
2
+
3
+ The Memory Import Processor is a feature that allows you to modularize your
4
+ GEMINI.md files by importing content from other files using the `@file.md`
5
+ syntax.
6
+
7
+ ## Overview
8
+
9
+ This feature enables you to break down large GEMINI.md files into smaller, more
10
+ manageable components that can be reused across different contexts. The import
11
+ processor supports both relative and absolute paths, with built-in safety
12
+ features to prevent circular imports and ensure file access security.
13
+
14
+ ## Syntax
15
+
16
+ Use the `@` symbol followed by the path to the file you want to import:
17
+
18
+ ```markdown
19
+ # Main GEMINI.md file
20
+
21
+ This is the main content.
22
+
23
+ @./components/instructions.md
24
+
25
+ More content here.
26
+
27
+ @./shared/configuration.md
28
+ ```
29
+
30
+ ## Supported path formats
31
+
32
+ ### Relative paths
33
+
34
+ - `@./file.md` - Import from the same directory
35
+ - `@../file.md` - Import from parent directory
36
+ - `@./components/file.md` - Import from subdirectory
37
+
38
+ ### Absolute paths
39
+
40
+ - `@/absolute/path/to/file.md` - Import using absolute path
41
+
42
+ ## Examples
43
+
44
+ ### Basic import
45
+
46
+ ```markdown
47
+ # My GEMINI.md
48
+
49
+ Welcome to my project!
50
+
51
+ @./get-started.md
52
+
53
+ ## Features
54
+
55
+ @./features/overview.md
56
+ ```
57
+
58
+ ### Nested imports
59
+
60
+ The imported files can themselves contain imports, creating a nested structure:
61
+
62
+ ```markdown
63
+ # main.md
64
+
65
+ @./header.md @./content.md @./footer.md
66
+ ```
67
+
68
+ ```markdown
69
+ # header.md
70
+
71
+ # Project Header
72
+
73
+ @./shared/title.md
74
+ ```
75
+
76
+ ## Safety features
77
+
78
+ ### Circular import detection
79
+
80
+ The processor automatically detects and prevents circular imports:
81
+
82
+ ```markdown
83
+ # file-a.md
84
+
85
+ @./file-b.md
86
+ ```
87
+
88
+ ```markdown
89
+ # file-b.md
90
+
91
+ @./file-a.md <!-- This will be detected and prevented -->
92
+ ```
93
+
94
+ ### File access security
95
+
96
+ The `validateImportPath` function ensures that imports are only allowed from
97
+ specified directories, preventing access to sensitive files outside the allowed
98
+ scope.
99
+
100
+ ### Maximum import depth
101
+
102
+ To prevent infinite recursion, there's a configurable maximum import depth
103
+ (default: 5 levels).
104
+
105
+ ## Error handling
106
+
107
+ ### Missing files
108
+
109
+ If a referenced file doesn't exist, the import will fail gracefully with an
110
+ error comment in the output.
111
+
112
+ ### File access errors
113
+
114
+ Permission issues or other file system errors are handled gracefully with
115
+ appropriate error messages.
116
+
117
+ ## Code region detection
118
+
119
+ The import processor uses the `marked` library to detect code blocks and inline
120
+ code spans, ensuring that `@` imports inside these regions are properly ignored.
121
+ This provides robust handling of nested code blocks and complex Markdown
122
+ structures.
123
+
124
+ ## Import tree structure
125
+
126
+ The processor returns an import tree that shows the hierarchy of imported files,
127
+ similar to Claude's `/memory` feature. This helps users debug problems with
128
+ their GEMINI.md files by showing which files were read and their import
129
+ relationships.
130
+
131
+ Example tree structure:
132
+
133
+ ```
134
+ Memory Files
135
+ L project: GEMINI.md
136
+ L a.md
137
+ L b.md
138
+ L c.md
139
+ L d.md
140
+ L e.md
141
+ L f.md
142
+ L included.md
143
+ ```
144
+
145
+ The tree preserves the order that files were imported and shows the complete
146
+ import chain for debugging purposes.
147
+
148
+ ## Comparison to Claude Code's `/memory` (`claude.md`) approach
149
+
150
+ Claude Code's `/memory` feature (as seen in `claude.md`) produces a flat, linear
151
+ document by concatenating all included files, always marking file boundaries
152
+ with clear comments and path names. It does not explicitly present the import
153
+ hierarchy, but the LLM receives all file contents and paths, which is sufficient
154
+ for reconstructing the hierarchy if needed.
155
+
156
+ > [!NOTE] The import tree is mainly for clarity during development and has
157
+ > limited relevance to LLM consumption.
158
+
159
+ ## API reference
160
+
161
+ ### `processImports(content, basePath, debugMode?, importState?)`
162
+
163
+ Processes import statements in GEMINI.md content.
164
+
165
+ **Parameters:**
166
+
167
+ - `content` (string): The content to process for imports
168
+ - `basePath` (string): The directory path where the current file is located
169
+ - `debugMode` (boolean, optional): Whether to enable debug logging (default:
170
+ false)
171
+ - `importState` (ImportState, optional): State tracking for circular import
172
+ prevention
173
+
174
+ **Returns:** Promise&lt;ProcessImportsResult&gt; - Object containing processed
175
+ content and import tree
176
+
177
+ ### `ProcessImportsResult`
178
+
179
+ ```typescript
180
+ interface ProcessImportsResult {
181
+ content: string; // The processed content with imports resolved
182
+ importTree: MemoryFile; // Tree structure showing the import hierarchy
183
+ }
184
+ ```
185
+
186
+ ### `MemoryFile`
187
+
188
+ ```typescript
189
+ interface MemoryFile {
190
+ path: string; // The file path
191
+ imports?: MemoryFile[]; // Direct imports, in the order they were imported
192
+ }
193
+ ```
194
+
195
+ ### `validateImportPath(importPath, basePath, allowedDirectories)`
196
+
197
+ Validates import paths to ensure they are safe and within allowed directories.
198
+
199
+ **Parameters:**
200
+
201
+ - `importPath` (string): The import path to validate
202
+ - `basePath` (string): The base directory for resolving relative paths
203
+ - `allowedDirectories` (string[]): Array of allowed directory paths
204
+
205
+ **Returns:** boolean - Whether the import path is valid
206
+
207
+ ### `findProjectRoot(startDir)`
208
+
209
+ Finds the project root by searching for a `.git` directory upwards from the
210
+ given start directory. Implemented as an **async** function using non-blocking
211
+ file system APIs to avoid blocking the Node.js event loop.
212
+
213
+ **Parameters:**
214
+
215
+ - `startDir` (string): The directory to start searching from
216
+
217
+ **Returns:** Promise&lt;string&gt; - The project root directory (or the start
218
+ directory if no `.git` is found)
219
+
220
+ ## Best Practices
221
+
222
+ 1. **Use descriptive file names** for imported components
223
+ 2. **Keep imports shallow** - avoid deeply nested import chains
224
+ 3. **Document your structure** - maintain a clear hierarchy of imported files
225
+ 4. **Test your imports** - ensure all referenced files exist and are accessible
226
+ 5. **Use relative paths** when possible for better portability
227
+
228
+ ## Troubleshooting
229
+
230
+ ### Common issues
231
+
232
+ 1. **Import not working**: Check that the file exists and the path is correct
233
+ 2. **Circular import warnings**: Review your import structure for circular
234
+ references
235
+ 3. **Permission errors**: Ensure the files are readable and within allowed
236
+ directories
237
+ 4. **Path resolution issues**: Use absolute paths if relative paths aren't
238
+ resolving correctly
239
+
240
+ ### Debug mode
241
+
242
+ Enable debug mode to see detailed logging of the import process:
243
+
244
+ ```typescript
245
+ const result = await processImports(content, basePath, true);
246
+ ```