@latentforce/shift 1.0.13 → 1.0.15

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.
@@ -27,84 +27,84 @@ function getMcpConfig(projectId) {
27
27
  };
28
28
  }
29
29
  const CLAUDE_MD_SECTION_MARKER = '<!-- shift-mcp-instructions -->';
30
- const CLAUDE_MD_CONTENT = `${CLAUDE_MD_SECTION_MARKER}
31
- ## Shift MCP Tools — MANDATORY USAGE RULES
32
-
33
- This project has the **Shift MCP server** (\`shift\`) configured with a pre-built knowledge graph of the entire codebase. You MUST use its tools as the primary way to understand code. Do NOT rely solely on reading raw files.
34
-
35
- ### Tools
36
-
37
- | Tool | Purpose |
38
- |------|---------|
39
- | \`file_summary\` | Get an summary of any file |
40
- | \`dependencies\` | List every file that a given file imports/depends on |
41
- | \`blast_radius\` | List every file that would be affected if a given file changed |
42
-
43
- ### Supported file types
44
-
45
- The knowledge graph is built **only** from source files. The tools will return an error for any other file type.
46
-
47
- **Indexed (use MCP tools):**
48
- \`.js\` \`.jsx\` \`.ts\` \`.tsx\` \`.py\` \`.java\` \`.cpp\` \`.cs\` \`.go\` \`.c\` \`.h\` \`.css\` \`.scss\` \`.html\`
49
-
50
- **NOT indexed (read directly with normal file tools):**
51
- \`.json\` \`.yaml\` \`.yml\` \`.toml\` \`.env\` \`.md\` \`.txt\` \`.pdf\` \`.png\` \`.lock\` \`.xml\` \`.csv\` and any other non-source format.
52
-
53
- Do NOT call \`file_summary\`, \`dependencies\`, or \`blast_radius\` on non-indexed files — it will fail. Read those files directly instead.
54
-
55
- ---
56
-
57
- ### RULE 1 — Codebase exploration (e.g. "explain the codebase", "how does this project work")
58
-
59
- You MUST call \`file_summary\` on **multiple key files** to build a complete picture. Do not stop after one call.
60
-
61
- Follow this protocol:
62
- 1. Identify the likely entry points (e.g. \`main.ts\`, \`index.ts\`, \`app.py\`, \`server.ts\`, \`main.py\`, route files, CLI entry files).
63
- 2. Call \`file_summary\` on each entry point (run calls in parallel where possible).
64
- 3. Call \`dependencies\` on the most central files to discover the module graph.
65
- 4. Call \`file_summary\` on the key modules discovered in step 3.
66
- 5. Synthesise all results into a coherent explanation.
67
-
68
- Never answer a "explain the whole project" question from a single \`file_summary\` call.
69
-
70
- ---
71
-
72
- ### RULE 2 — Before reading any file
73
-
74
- ALWAYS call \`file_summary\` first. Only open the raw file if you need implementation details that the summary does not cover.
75
-
76
- ---
77
-
78
- ### RULE 3 — Before editing any file
79
-
80
- ALWAYS call \`blast_radius\` on that file first. List the affected files in your plan before making any changes.
81
-
82
- ---
83
-
84
- ### RULE 4 — When tracing a bug or data flow
85
-
86
- Use \`dependencies\` to follow the chain rather than grepping manually. Start from the file where the symptom appears and walk the dependency graph.
87
-
88
- ---
89
-
90
- ### Usage reference
91
-
92
- \`\`\`
93
- # Understand a file
94
- file_summary(file_path="src/server.ts")
95
-
96
- # Understand with folder context (level = number of parent dirs to include)
97
- file_summary(file_path="src/server.ts", level=1)
98
-
99
- # See what a file imports
100
- dependencies(file_path="src/server.ts")
101
-
102
- # See what breaks if this file changes
103
- blast_radius(file_path="src/server.ts")
104
- \`\`\`
105
-
106
- > Run \`shift-cli update-drg\` after significant code changes to keep the knowledge graph current.
107
- <!-- end-shift-mcp-instructions -->
30
+ const CLAUDE_MD_CONTENT = `${CLAUDE_MD_SECTION_MARKER}
31
+ ## Shift MCP Tools — MANDATORY USAGE RULES
32
+
33
+ This project has the **Shift MCP server** (\`shift\`) configured with a pre-built knowledge graph of the entire codebase. You MUST use its tools as the primary way to understand code. Do NOT rely solely on reading raw files.
34
+
35
+ ### Tools
36
+
37
+ | Tool | Purpose |
38
+ |------|---------|
39
+ | \`file_summary\` | Get an summary of any file |
40
+ | \`dependencies\` | List every file that a given file imports/depends on |
41
+ | \`blast_radius\` | List every file that would be affected if a given file changed |
42
+
43
+ ### Supported file types
44
+
45
+ The knowledge graph is built **only** from source files. The tools will return an error for any other file type.
46
+
47
+ **Indexed (use MCP tools):**
48
+ \`.js\` \`.jsx\` \`.ts\` \`.tsx\` \`.py\` \`.java\` \`.cpp\` \`.cs\` \`.go\` \`.c\` \`.h\` \`.css\` \`.scss\` \`.html\`
49
+
50
+ **NOT indexed (read directly with normal file tools):**
51
+ \`.json\` \`.yaml\` \`.yml\` \`.toml\` \`.env\` \`.md\` \`.txt\` \`.pdf\` \`.png\` \`.lock\` \`.xml\` \`.csv\` and any other non-source format.
52
+
53
+ Do NOT call \`file_summary\`, \`dependencies\`, or \`blast_radius\` on non-indexed files — it will fail. Read those files directly instead.
54
+
55
+ ---
56
+
57
+ ### RULE 1 — Codebase exploration (e.g. "explain the codebase", "how does this project work")
58
+
59
+ You MUST call \`file_summary\` on **multiple key files** to build a complete picture. Do not stop after one call.
60
+
61
+ Follow this protocol:
62
+ 1. Identify the likely entry points (e.g. \`main.ts\`, \`index.ts\`, \`app.py\`, \`server.ts\`, \`main.py\`, route files, CLI entry files).
63
+ 2. Call \`file_summary\` on each entry point (run calls in parallel where possible).
64
+ 3. Call \`dependencies\` on the most central files to discover the module graph.
65
+ 4. Call \`file_summary\` on the key modules discovered in step 3.
66
+ 5. Synthesise all results into a coherent explanation.
67
+
68
+ Never answer a "explain the whole project" question from a single \`file_summary\` call.
69
+
70
+ ---
71
+
72
+ ### RULE 2 — Before reading any file
73
+
74
+ ALWAYS call \`file_summary\` first. Only open the raw file if you need implementation details that the summary does not cover.
75
+
76
+ ---
77
+
78
+ ### RULE 3 — Before editing any file
79
+
80
+ ALWAYS call \`blast_radius\` on that file first. List the affected files in your plan before making any changes.
81
+
82
+ ---
83
+
84
+ ### RULE 4 — When tracing a bug or data flow
85
+
86
+ Use \`dependencies\` to follow the chain rather than grepping manually. Start from the file where the symptom appears and walk the dependency graph.
87
+
88
+ ---
89
+
90
+ ### Usage reference
91
+
92
+ \`\`\`
93
+ # Understand a file
94
+ file_summary(file_path="src/server.ts")
95
+
96
+ # Understand with folder context (level = number of parent dirs to include)
97
+ file_summary(file_path="src/server.ts", level=1)
98
+
99
+ # See what a file imports
100
+ dependencies(file_path="src/server.ts")
101
+
102
+ # See what breaks if this file changes
103
+ blast_radius(file_path="src/server.ts")
104
+ \`\`\`
105
+
106
+ > Run \`shift-cli update-drg\` after significant code changes to keep the knowledge graph current.
107
+ <!-- end-shift-mcp-instructions -->
108
108
  `;
109
109
  const CLAUDE_MD_END_MARKER = '<!-- end-shift-mcp-instructions -->';
110
110
  function createClaudeMd(projectRoot) {
@@ -207,6 +207,28 @@ export async function initCommand(options = {}) {
207
207
  else {
208
208
  console.log('[Init] No .shift/scan_target.json found — server will auto-detect scan targets');
209
209
  }
210
+ // Read source file contents so orchestrator can run pipeline inline (e.g. LOCAL mode) and index via init-scan
211
+ const MAX_FILES_TO_SEND = 800;
212
+ const MAX_FILE_SIZE_CHARS = 150000;
213
+ const filesToRead = categorized.source_files.slice(0, MAX_FILES_TO_SEND);
214
+ const filesWithContent = [];
215
+ let filesSkipped = 0;
216
+ for (const filePath of filesToRead) {
217
+ try {
218
+ const absolutePath = path.join(projectRoot, filePath);
219
+ const content = readFileSync(absolutePath, 'utf-8');
220
+ const truncated = content.length > MAX_FILE_SIZE_CHARS
221
+ ? content.slice(0, MAX_FILE_SIZE_CHARS) + '\n/* ... truncated */'
222
+ : content;
223
+ filesWithContent.push({ file_path: filePath, content: truncated });
224
+ }
225
+ catch {
226
+ filesSkipped++;
227
+ }
228
+ }
229
+ if (filesWithContent.length > 0) {
230
+ console.log(`[Init] Read ${filesWithContent.length} source file(s) for inline indexing${filesSkipped > 0 ? ` (${filesSkipped} skipped)` : ''}`);
231
+ }
210
232
  const payload = {
211
233
  project_id: project.projectId,
212
234
  project_tree: treeData,
@@ -222,11 +244,12 @@ export async function initCommand(options = {}) {
222
244
  },
223
245
  scan_targets: scanTargets,
224
246
  total_loc: totalLOC,
247
+ files: filesWithContent.length > 0 ? filesWithContent : undefined,
225
248
  };
226
249
  try {
227
250
  const response = await sendInitScan(apiKey, project.projectId, payload);
228
251
  console.log('[Init] ✓ Backend initialization completed');
229
- console.log(`[Init] Source files queued: ${response.source_files_count ?? response.files_read}`);
252
+ console.log(`[Init] Source files queued: ${response.source_files_count}`);
230
253
  // Update local config with agent info (matching extension)
231
254
  if (response.agents_created?.theme_planner) {
232
255
  const agentInfo = {
@@ -240,9 +263,6 @@ export async function initCommand(options = {}) {
240
263
  writeProjectConfig(projectConfig, projectRoot);
241
264
  console.log(`[Init] ✓ Agent info saved: ${agentInfo.agent_id}`);
242
265
  }
243
- if (response.files_read === 0 && response.files_failed > 0) {
244
- console.log(`\n[Init] ⚠️ No files were read (${response.files_failed} failed).`);
245
- }
246
266
  console.log('\n╔═══════════════════════════════════════════════╗');
247
267
  console.log('║ ✓ Project Initialization Complete ║');
248
268
  console.log('╚═══════════════════════════════════════════════╝');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latentforce/shift",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Shift CLI - AI-powered code intelligence with MCP support",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",