stackmem 1.0.8 → 1.0.9

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 (3) hide show
  1. package/dist/cli.js +49 -2
  2. package/package.json +1 -1
  3. package/src/cli.ts +60 -2
package/dist/cli.js CHANGED
@@ -51,6 +51,9 @@ function usage() {
51
51
  function cmdHelp() {
52
52
  console.log(`cm — coding memory CLI
53
53
 
54
+ Works with Claude Code, Cursor, and Windsurf — 'cm init' writes the
55
+ CLAUDE.md, .cursorrules, and .windsurfrules files each tool reads.
56
+
54
57
  [project] is optional everywhere below if a .stackmem file exists in
55
58
  the current directory (written by 'cm init'). Otherwise pass it explicitly.
56
59
 
@@ -91,8 +94,11 @@ function cmdHelp() {
91
94
 
92
95
  cm init <project> <path>
93
96
  Install a git post-commit hook in the repo at <path>, register
94
- the stackmem MCP server with Claude Code, write a CLAUDE.md and
95
- .stackmem file, and seed initial memories from the project scan.
97
+ the stackmem MCP server with Claude Code, write a CLAUDE.md,
98
+ .cursorrules, .windsurfrules, and .stackmem file, and seed
99
+ initial memories from the project scan. .cursorrules and
100
+ .windsurfrules (for Cursor and Windsurf) are skipped if they
101
+ already exist.
96
102
 
97
103
  cm context [--project <name>] <task>
98
104
  Return only the top 5 memories most relevant to a specific
@@ -787,6 +793,43 @@ cm save ${project} <type> "<content>"
787
793
  nodeFs.writeFileSync(claudeMdPath, content, "utf-8");
788
794
  console.log("CLAUDE.md written.");
789
795
  }
796
+ const EDITOR_RULES_CONTENT = `# stackmem
797
+
798
+ At the start of every session, run:
799
+ cm start
800
+
801
+ and paste the output here before starting work.
802
+
803
+ When you make a decision, discover a constraint,
804
+ reject an approach, or make a discovery, save it:
805
+ cm save <type> "<content>"
806
+
807
+ Types: decision, rejection, constraint, discovery
808
+ `;
809
+ // Returns true if the file was written, false if it already existed
810
+ // (and was skipped).
811
+ function writeCursorRules(resolvedPath) {
812
+ const cursorRulesPath = nodePath.join(resolvedPath, ".cursorrules");
813
+ if (nodeFs.existsSync(cursorRulesPath)) {
814
+ console.log(".cursorrules already exists — skipping.");
815
+ return false;
816
+ }
817
+ nodeFs.writeFileSync(cursorRulesPath, EDITOR_RULES_CONTENT, "utf-8");
818
+ console.log(".cursorrules written.");
819
+ return true;
820
+ }
821
+ // Returns true if the file was written, false if it already existed
822
+ // (and was skipped).
823
+ function writeWindsurfRules(resolvedPath) {
824
+ const windsurfRulesPath = nodePath.join(resolvedPath, ".windsurfrules");
825
+ if (nodeFs.existsSync(windsurfRulesPath)) {
826
+ console.log(".windsurfrules already exists — skipping.");
827
+ return false;
828
+ }
829
+ nodeFs.writeFileSync(windsurfRulesPath, EDITOR_RULES_CONTENT, "utf-8");
830
+ console.log(".windsurfrules written.");
831
+ return true;
832
+ }
790
833
  function writeProjectFile(project, resolvedPath) {
791
834
  const stackmemPath = nodePath.join(resolvedPath, STACKMEM_FILE);
792
835
  nodeFs.writeFileSync(stackmemPath, `${project}\n`, "utf-8");
@@ -869,6 +912,8 @@ async function cmdInit(project, targetPath) {
869
912
  console.log(`coding-memory hook installed for project ${project} at ${targetPath}`);
870
913
  registerMcpServer(DIST_INDEX_PATH);
871
914
  writeClaudeMd(project, resolvedPath);
915
+ const cursorRulesWritten = writeCursorRules(resolvedPath);
916
+ const windsurfRulesWritten = writeWindsurfRules(resolvedPath);
872
917
  const seededCount = await seedMemories(project, resolvedPath);
873
918
  console.log(`Seeded ${seededCount} initial memories from project scan.`);
874
919
  const backendOk = await verifyBackendConnection(project);
@@ -876,6 +921,8 @@ async function cmdInit(project, targetPath) {
876
921
  console.log("✓ Git hook installed");
877
922
  console.log("✓ MCP server registered");
878
923
  console.log("✓ CLAUDE.md written");
924
+ console.log(`✓ .cursorrules ${cursorRulesWritten ? "written" : "already exists"}`);
925
+ console.log(`✓ .windsurfrules ${windsurfRulesWritten ? "written" : "already exists"}`);
879
926
  console.log(`✓ Seeded ${seededCount} memories from project scan`);
880
927
  if (backendOk) {
881
928
  console.log("✓ Backend connection verified");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stackmem",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/cli.ts CHANGED
@@ -70,6 +70,9 @@ function usage(): never {
70
70
  function cmdHelp() {
71
71
  console.log(`cm — coding memory CLI
72
72
 
73
+ Works with Claude Code, Cursor, and Windsurf — 'cm init' writes the
74
+ CLAUDE.md, .cursorrules, and .windsurfrules files each tool reads.
75
+
73
76
  [project] is optional everywhere below if a .stackmem file exists in
74
77
  the current directory (written by 'cm init'). Otherwise pass it explicitly.
75
78
 
@@ -110,8 +113,11 @@ function cmdHelp() {
110
113
 
111
114
  cm init <project> <path>
112
115
  Install a git post-commit hook in the repo at <path>, register
113
- the stackmem MCP server with Claude Code, write a CLAUDE.md and
114
- .stackmem file, and seed initial memories from the project scan.
116
+ the stackmem MCP server with Claude Code, write a CLAUDE.md,
117
+ .cursorrules, .windsurfrules, and .stackmem file, and seed
118
+ initial memories from the project scan. .cursorrules and
119
+ .windsurfrules (for Cursor and Windsurf) are skipped if they
120
+ already exist.
115
121
 
116
122
  cm context [--project <name>] <task>
117
123
  Return only the top 5 memories most relevant to a specific
@@ -895,6 +901,50 @@ cm save ${project} <type> "<content>"
895
901
  console.log("CLAUDE.md written.");
896
902
  }
897
903
 
904
+ const EDITOR_RULES_CONTENT = `# stackmem
905
+
906
+ At the start of every session, run:
907
+ cm start
908
+
909
+ and paste the output here before starting work.
910
+
911
+ When you make a decision, discover a constraint,
912
+ reject an approach, or make a discovery, save it:
913
+ cm save <type> "<content>"
914
+
915
+ Types: decision, rejection, constraint, discovery
916
+ `;
917
+
918
+ // Returns true if the file was written, false if it already existed
919
+ // (and was skipped).
920
+ function writeCursorRules(resolvedPath: string): boolean {
921
+ const cursorRulesPath = nodePath.join(resolvedPath, ".cursorrules");
922
+
923
+ if (nodeFs.existsSync(cursorRulesPath)) {
924
+ console.log(".cursorrules already exists — skipping.");
925
+ return false;
926
+ }
927
+
928
+ nodeFs.writeFileSync(cursorRulesPath, EDITOR_RULES_CONTENT, "utf-8");
929
+ console.log(".cursorrules written.");
930
+ return true;
931
+ }
932
+
933
+ // Returns true if the file was written, false if it already existed
934
+ // (and was skipped).
935
+ function writeWindsurfRules(resolvedPath: string): boolean {
936
+ const windsurfRulesPath = nodePath.join(resolvedPath, ".windsurfrules");
937
+
938
+ if (nodeFs.existsSync(windsurfRulesPath)) {
939
+ console.log(".windsurfrules already exists — skipping.");
940
+ return false;
941
+ }
942
+
943
+ nodeFs.writeFileSync(windsurfRulesPath, EDITOR_RULES_CONTENT, "utf-8");
944
+ console.log(".windsurfrules written.");
945
+ return true;
946
+ }
947
+
898
948
  function writeProjectFile(project: string, resolvedPath: string): void {
899
949
  const stackmemPath = nodePath.join(resolvedPath, STACKMEM_FILE);
900
950
  nodeFs.writeFileSync(stackmemPath, `${project}\n`, "utf-8");
@@ -990,6 +1040,8 @@ async function cmdInit(project: string, targetPath: string) {
990
1040
 
991
1041
  registerMcpServer(DIST_INDEX_PATH);
992
1042
  writeClaudeMd(project, resolvedPath);
1043
+ const cursorRulesWritten = writeCursorRules(resolvedPath);
1044
+ const windsurfRulesWritten = writeWindsurfRules(resolvedPath);
993
1045
 
994
1046
  const seededCount = await seedMemories(project, resolvedPath);
995
1047
  console.log(`Seeded ${seededCount} initial memories from project scan.`);
@@ -1000,6 +1052,12 @@ async function cmdInit(project: string, targetPath: string) {
1000
1052
  console.log("✓ Git hook installed");
1001
1053
  console.log("✓ MCP server registered");
1002
1054
  console.log("✓ CLAUDE.md written");
1055
+ console.log(
1056
+ `✓ .cursorrules ${cursorRulesWritten ? "written" : "already exists"}`
1057
+ );
1058
+ console.log(
1059
+ `✓ .windsurfrules ${windsurfRulesWritten ? "written" : "already exists"}`
1060
+ );
1003
1061
  console.log(`✓ Seeded ${seededCount} memories from project scan`);
1004
1062
  if (backendOk) {
1005
1063
  console.log("✓ Backend connection verified");