@chamba/mcp 0.5.1 → 0.6.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 (2) hide show
  1. package/dist/main.js +39 -34
  2. package/package.json +3 -3
package/dist/main.js CHANGED
@@ -646,14 +646,17 @@ ${shown.map((n) => `- ${n}`).join("\n")}${more}` + (names.length === 0 ? "\n\n\u
646
646
  // src/tools/workspace-init.ts
647
647
  import {
648
648
  joinPath as joinPath4,
649
+ ObsidianDetector as ObsidianDetector4,
649
650
  renderWorkspaceMarkdown,
651
+ VAULT_OVERVIEW_FILE,
652
+ VaultInitializer,
650
653
  WORKSPACE_DIR as WORKSPACE_DIR4,
651
654
  WORKSPACE_RELATIVE_PATH,
652
655
  WorkspaceScanner as WorkspaceScanner4
653
656
  } from "@chamba/core";
654
657
  import { z as z12 } from "zod";
655
658
  var TOOL_NAME14 = "chamba_workspace_init";
656
- var DESCRIPTION14 = "Scan the workspace and generate `.chamba/workspace.md` (description, languages, framework, conventions, active projects, folder map). Respects .gitignore/.dockerignore and never reads node_modules or binaries. If the file already exists it is NOT overwritten \u2014 its current contents are returned so the model/user decides what to do.";
659
+ var DESCRIPTION14 = 'Scan the workspace and generate `.chamba/workspace.md` (description, languages, framework, conventions, active projects, folder map). Respects .gitignore/.dockerignore and never reads node_modules or binaries. If the file already exists it is NOT overwritten \u2014 its current contents are returned. When no Obsidian vault is available, it also bootstraps one at the workspace root and seeds a "Workspace overview" note (disable with createVault: false).';
657
660
  function registerWorkspaceInit(server, logger, services) {
658
661
  server.registerTool(
659
662
  TOOL_NAME14,
@@ -661,47 +664,49 @@ function registerWorkspaceInit(server, logger, services) {
661
664
  title: "Init workspace",
662
665
  description: DESCRIPTION14,
663
666
  inputSchema: {
664
- root: z12.string().optional().describe("Workspace root to scan. Defaults to the directory chamba runs in.")
667
+ root: z12.string().optional().describe("Workspace root to scan. Defaults to the directory chamba runs in."),
668
+ createVault: z12.boolean().optional().describe("Bootstrap an Obsidian vault at the root when none is found (default true).")
665
669
  }
666
670
  },
667
- async ({ root }) => {
671
+ async ({ root, createVault }) => {
668
672
  const workspaceRoot = root ?? services.cwd;
669
673
  const wsPath = joinPath4(workspaceRoot, WORKSPACE_RELATIVE_PATH);
670
- if (await services.fs.exists(wsPath)) {
671
- const currentContents = await services.fs.readFile(wsPath);
672
- logger.info({ tool: TOOL_NAME14, wsPath }, "workspace.md already exists, not overwriting");
673
- return {
674
- content: [
675
- {
676
- type: "text",
677
- text: `\`${WORKSPACE_RELATIVE_PATH}\` already exists at ${wsPath}; not overwriting.
678
-
679
- Current contents:
680
-
681
- ${currentContents}`
682
- }
683
- ]
684
- };
674
+ const workspace = await new WorkspaceScanner4(services.fs).scan(workspaceRoot);
675
+ const wsExisted = await services.fs.exists(wsPath);
676
+ let markdown;
677
+ if (wsExisted) {
678
+ markdown = await services.fs.readFile(wsPath);
679
+ } else {
680
+ markdown = renderWorkspaceMarkdown(workspace);
681
+ await services.fs.mkdir(joinPath4(workspaceRoot, WORKSPACE_DIR4));
682
+ await services.fs.writeFile(wsPath, markdown);
683
+ }
684
+ const wsLine = wsExisted ? `\`${WORKSPACE_RELATIVE_PATH}\` already exists at ${wsPath}; not overwriting.` : `Created \`${WORKSPACE_RELATIVE_PATH}\` at ${wsPath}.`;
685
+ let vaultLine = "Vault: skipped (createVault: false).";
686
+ if (createVault !== false) {
687
+ const detection = await new ObsidianDetector4(services.fs).detect({
688
+ explicitPath: services.obsidianVaultPath,
689
+ searchRoots: obsidianSearchRoots(services)
690
+ });
691
+ if (detection.found) {
692
+ vaultLine = `Vault: using the existing one at ${detection.path}; left it untouched.`;
693
+ } else {
694
+ const seeded = await new VaultInitializer(services.fs, services.clock).seed({
695
+ vaultPath: workspaceRoot,
696
+ workspace
697
+ });
698
+ vaultLine = `Vault: none found \u2014 created one at the workspace root and seeded \`${VAULT_OVERVIEW_FILE}\`. Add \`.obsidian/\` to .gitignore if you don't want it committed.`;
699
+ logger.info({ tool: TOOL_NAME14, vault: seeded.vaultPath }, "vault bootstrapped");
700
+ }
685
701
  }
686
- const scanner = new WorkspaceScanner4(services.fs);
687
- const workspace = await scanner.scan(workspaceRoot);
688
- const markdown = renderWorkspaceMarkdown(workspace);
689
- await services.fs.mkdir(joinPath4(workspaceRoot, WORKSPACE_DIR4));
690
- await services.fs.writeFile(wsPath, markdown);
691
702
  logger.info(
692
- { tool: TOOL_NAME14, wsPath, projects: workspace.projects.length },
693
- "workspace.md created"
703
+ { tool: TOOL_NAME14, wsPath, wsExisted, projects: workspace.projects.length },
704
+ "workspace init"
694
705
  );
695
- return {
696
- content: [
697
- {
698
- type: "text",
699
- text: `Created \`${WORKSPACE_RELATIVE_PATH}\` at ${wsPath}.
706
+ return { content: [{ type: "text", text: `${wsLine}
707
+ ${vaultLine}
700
708
 
701
- ${markdown}`
702
- }
703
- ]
704
- };
709
+ ${markdown}` }] };
705
710
  }
706
711
  );
707
712
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chamba/mcp",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "chamba MCP server — orchestration, workspace, worktree and Obsidian tools for any MCP-capable editor",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -36,8 +36,8 @@
36
36
  "@modelcontextprotocol/sdk": "^1.12.0",
37
37
  "pino": "^9.0.0",
38
38
  "zod": "^3.23.0",
39
- "@chamba/adapters": "0.5.1",
40
- "@chamba/core": "0.5.1"
39
+ "@chamba/adapters": "0.6.0",
40
+ "@chamba/core": "0.6.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^22.0.0",