cartographer-ai 1.0.0 → 1.0.3

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.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # Cartographer CLI
2
+
3
+ Cartographer CLI is a tool that detects changes in your source code and securely sends them to the Cartographer server, where AI automatically creates or updates the corresponding documentation. Designed to run in your CI/CD pipeline, it ensures your documentation stays accurate, up to date, and perfectly aligned with your evolving codebase, without retaining or using your code for any other purpose.
4
+
5
+ ## Features
6
+
7
+ - **Automatic change detection**
8
+ Detects which files have changed in your pull request, ensuring only modified code is processed.
9
+
10
+ - **Server-driven documentation generation**
11
+ The CLI itself does not generate documentation locally. Instead, it securely sends only the changed code to the Cartographer server, where AI generates or updates the relevant documentation. The code sent is **not stored**, **not retained**, and **never used to train any models**.
12
+
13
+ - **Continuous updates**
14
+ As your code evolves, Cartographer continuously produces new or updated documentation—no manual maintenance required.
15
+
16
+ - **Language-agnostic**
17
+ Works with any programming language and almost any codebase structure.
18
+
19
+ - **Simple CI/CD integration**
20
+ Easily integrates with GitHub Actions, GitLab CI, or any custom automation workflow.
21
+
22
+ ## CI/CD Integration Examples
23
+
24
+ ### GitHub Actions
25
+
26
+ ```sh
27
+ name: Cartographer
28
+
29
+ on:
30
+ push:
31
+ branches:
32
+ - main
33
+
34
+ jobs:
35
+ cartographer:
36
+ runs-on: ubuntu-latest
37
+
38
+ steps:
39
+ - name: Checkout Repository
40
+ uses: actions/checkout@v4
41
+ with:
42
+ fetch-depth: 0
43
+
44
+ - name: Setup
45
+ uses: actions/setup-node@v4
46
+ with:
47
+ node-version: 24
48
+
49
+ - name: Install Cartographer
50
+ run: npm i cartographer-ai
51
+
52
+ - name: Run Cartographer
53
+ run: |
54
+ npx cartographer apiKey=${{ secrets.API_KEY }}
55
+ npx cartographer spaceId=${{ secrets.SPACE_ID }}
56
+ npx cartographer dispatch
57
+ ```
58
+
59
+ ### GitLab CI/CD
60
+
61
+ ```sh
62
+ stages:
63
+ - cartographer
64
+
65
+ cartographer:
66
+ stage: cartographer
67
+ image: node:24
68
+ only:
69
+ - main
70
+ before_script:
71
+ - npm i cartographer-ai
72
+ script:
73
+ - npx cartographer apiKey=${API_KEY}
74
+ - npx cartographer spaceId=${SPACE_ID}
75
+ - npx cartographer dispatch
76
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cartographer-ai",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "main": "src/commands.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,4 +9,4 @@
9
9
  "dependencies": {
10
10
  "axios": "^1.10.0"
11
11
  }
12
- }
12
+ }
@@ -73,7 +73,7 @@ export class Cartographer {
73
73
  }
74
74
 
75
75
  #getModifiedFiles() {
76
- const command = "git diff --name-only && git diff --name-only --cached";
76
+ const command = "git diff --name-only HEAD~1 HEAD";
77
77
  const output = execSync(command, { encoding: "utf8" });
78
78
  return output.split("\n")?.reduce((arr, path) => {
79
79
  const formattedPath = path.trim();
@@ -90,8 +90,7 @@ export class Cartographer {
90
90
  },
91
91
  });
92
92
  } catch (error) {
93
- console.error(
94
- "Error:",
93
+ throw new Error(
95
94
  error?.response?.data?.error ?? "Unexpected error occured"
96
95
  );
97
96
  }
@@ -192,7 +191,7 @@ export class Cartographer {
192
191
 
193
192
  files[resolvedId].push(file);
194
193
  } catch (error) {
195
- console.error(`Error reading file ${filePath}:`, error.message);
194
+ throw new Error(`Error reading file ${filePath}:`, error.message);
196
195
  }
197
196
  });
198
197
 
package/src/commands.js CHANGED
@@ -33,8 +33,7 @@ export const saveConfig = (configPath, newConfig) => {
33
33
 
34
34
  const handleCartographerCommand = (arg) => {
35
35
  if (!arg) {
36
- console.log("No command received");
37
- return;
36
+ throw new Error("No command received");
38
37
  }
39
38
 
40
39
  const config = loadConfig(configPath);
@@ -47,7 +46,7 @@ const handleCartographerCommand = (arg) => {
47
46
  }, []);
48
47
 
49
48
  if (missingFields.length > 0) {
50
- console.log(
49
+ throw new Error(
51
50
  `Error: Missing required fields: ${missingFields.join(", ")}`
52
51
  );
53
52
  } else {
@@ -60,6 +59,7 @@ const handleCartographerCommand = (arg) => {
60
59
  cartographer.dispatch();
61
60
  clearConfig(configPath);
62
61
  }
62
+
63
63
  return;
64
64
  }
65
65
 
@@ -70,9 +70,9 @@ const handleCartographerCommand = (arg) => {
70
70
  }
71
71
 
72
72
  const field = fields.find((field) => field === command);
73
+
73
74
  if (!field) {
74
- console.log(`Unknown command: ${command}`);
75
- return;
75
+ throw new Error(`Unknown command: ${command}`);
76
76
  }
77
77
 
78
78
  config[field] = value;