get-lem-ai 1.0.0 → 1.0.1

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,108 @@
1
+ # get-lem-ai šŸš€
2
+
3
+ > **Lem AI Git-Jira Automation Hook**
4
+ > Automatically generate `Implementation.md` documentation from Jira tickets upon creating new local Git branches.
5
+
6
+ `get-lem-ai` is a lightweight, stack-agnostic Git hook CLI tool designed to link your local development environment directly to the **Lem AI** knowledge graph. By capturing branch creation transactions, it dynamically fetches issue details, outlines architectural expectations, and generates detailed implementation specifications without delaying your Git checkout flow.
7
+
8
+ ---
9
+
10
+ ## Key Features ⚔
11
+
12
+ * **Instantaneous Git Checkout:** Spawns a detached background node process so your terminal checkouts proceed instantly without waiting for API responses.
13
+ * **Smart Jira-Key Resolution:** Employs robust pattern-matching regex to extract Jira IDs directly from branch naming conventions (e.g. `feature/PROJ-123-auth`).
14
+ * **Automated Evidence Collection:** Communicates with the Lem AI platform to automatically generate `Implementation.md` files in the root of your project.
15
+ * **SOC 2 & SOP Compliance Guardrail:** Standardizes developmental structure by aligning your branch intent with administrative Jira tickets.
16
+ * **Easy Hook Management:** Single commands to install, configure, or cleanly uninstall hook integrations.
17
+
18
+ ---
19
+
20
+ ## Prerequisites šŸ“‹
21
+
22
+ * **Node.js** (v14.0.0 or higher)
23
+ * **Git** installed and initialized in your workspace (`git init`)
24
+ * **Lem SDK API Key** (obtainable from your Lem workspace developer settings page)
25
+
26
+ ---
27
+
28
+ ## Quick Start Setup Guide šŸ”§
29
+
30
+ Follow these three simple steps to integrate `get-lem-ai` into your local development repository:
31
+
32
+ ### Step 1: Install the Package Globally
33
+ Install the package globally via `npm` to expose the global `get-lem-ai` executable commands:
34
+ ```bash
35
+ npm install -g get-lem-ai
36
+ ```
37
+
38
+ ### Step 2: Configure Your API Profile
39
+ Initialize your configuration by running the wizard. You will be prompted to enter your preferred documentation filename and your secure API key:
40
+ ```bash
41
+ get-lem-ai setup
42
+ ```
43
+ * **Output filename [Implementation.md]:** Press enter to accept the default or specify a custom documentation path.
44
+ * **SDK API Key:** Paste your secure Lem developer token.
45
+
46
+ This creates a global configuration saved inside your environment as a local `.lem-ai.json` profile.
47
+
48
+ ### Step 3: Install Hook in Your Git Repository
49
+ Navigate to the root directory of your active local Git project and initialize the hook:
50
+ ```bash
51
+ cd /path/to/your/git/repository
52
+ get-lem-ai install
53
+ ```
54
+ *This command injects a reference-transaction shell script into `.git/hooks/reference-transaction` designed to capture branch shifts.*
55
+
56
+ ---
57
+
58
+ ## How It Works Under the Hood šŸ› ļø
59
+
60
+ ```
61
+ ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
62
+ │ git checkout │ ────> │ reference-transaction │ ────> │ get-lem-ai │
63
+ │ -b PROJ-123 │ │ hook intercepts event │ │ background │
64
+ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
65
+ │
66
+ ā–¼
67
+ ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
68
+ │ Write completed │ <──── │ Lem platform returns │ <──── │ Request API │
69
+ │ Document file │ │ context & architecture │ │ with Jira key │
70
+ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
71
+ ```
72
+
73
+ 1. **Transaction Capture:** The reference-transaction hook triggers whenever local branches are created (using `git branch`, `git checkout -b`, or `git switch -c`).
74
+ 2. **Jira Key Extraction:** The tool parses the branch string searching for active Jira keys (e.g. `SOP-42`, `PROJ-999`).
75
+ 3. **Decoupled Request:** A detached background worker is spawned with `LEMAI_BG=true` redirecting outputs to `.lem-ai.log`. The parent process exits immediately to prevent terminal blocking.
76
+ 4. **Document Generation:** The worker sends the context payload to the Lem AI engine which analyzes the corresponding ticket parameters, synthesizes architectural directions, and compiles a comprehensive `Implementation.md` locally.
77
+
78
+ ---
79
+
80
+ ## Commands Reference šŸ“–
81
+
82
+ ### `get-lem-ai setup`
83
+ Launches the setup prompt wizard to configure your output target file and credentials.
84
+
85
+ ### `get-lem-ai install`
86
+ Safely registers the `reference-transaction` hook inside the current repository's `.git/hooks` folder. If a hook already exists, it intelligently appends or keeps legacy hooks safe.
87
+
88
+ ### `get-lem-ai uninstall`
89
+ Cleans up the workspace by deleting the active git hook and removing the project-level `.lem-ai.json` config profile.
90
+
91
+ ### `get-lem-ai checkout <branchName>`
92
+ The internal entrypoint callback fired by the Git transaction hook. Can also be called manually to dry-run or force generation:
93
+ ```bash
94
+ get-lem-ai checkout feature/PROJ-123-api-limits
95
+ ```
96
+
97
+ ---
98
+
99
+ ## Troubleshooting & Files šŸ”
100
+
101
+ * **`.lem-ai.json`**: Located in the root of your project or home directory. Contains your secure authorization keys and output targets. **Keep this ignored from public git repositories!**
102
+ * **`.lem-ai.log`**: Standard output log compiled during background runs. If your `Implementation.md` file did not generate, inspect this file to diagnose connection or API authorization issues.
103
+
104
+ ---
105
+
106
+ ## License šŸ“„
107
+
108
+ This project is licensed under the **MIT License**.
package/bin/cli.js CHANGED
@@ -7,8 +7,8 @@ const { install, uninstall } = require('../src/install');
7
7
  const { checkout } = require('../src/checkout');
8
8
 
9
9
  program
10
- .name('lem-ai')
11
- .description('lem-ai — generate Implementation.md on branch creation')
10
+ .name('get-lem-ai')
11
+ .description('get-lem-ai — generate Implementation.md on branch creation')
12
12
  .version('1.0.0');
13
13
 
14
14
  program.command('setup').description('Configure webhook URL').action(setup);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "get-lem-ai",
3
- "version": "1.0.0",
4
- "description": "lem-ai — Automate Implementation.md generation from Jira tickets on branch creation",
3
+ "version": "1.0.1",
4
+ "description": "get-lem-ai — Automate Implementation.md generation from Jira tickets on branch creation",
5
5
  "main": "src/index.js",
6
6
  "bin": {
7
7
  "get-lem-ai": "bin/cli.js"
@@ -14,10 +14,10 @@
14
14
  "git",
15
15
  "hook",
16
16
  "jira",
17
- "lem-ai",
17
+ "get-lem-ai",
18
18
  "automation"
19
19
  ],
20
- "author": "lem-ai",
20
+ "author": "get-lem-ai",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "axios": "^1.15.1",
package/src/checkout.js CHANGED
@@ -15,7 +15,7 @@ async function checkout(branchName) {
15
15
  const config = loadConfig();
16
16
 
17
17
  if (!config) {
18
- console.log(chalk.yellow('\nāš ļø Not configured. Run: lem-ai setup\n'));
18
+ console.log(chalk.yellow('\nāš ļø Not configured. Run: get-lem-ai setup\n'));
19
19
  return;
20
20
  }
21
21
 
@@ -23,9 +23,9 @@ async function checkout(branchName) {
23
23
  // PHASE 1: Main Process — Spawn Background Worker & Exit
24
24
  // ────────────────────────────────────────────────────────────
25
25
  if (!process.env.LEMAI_BG) {
26
- console.log(chalk.cyan(`\n[lem-ai] šŸš€ Branch detected: ${chalk.bold(branchName)}`));
27
- console.log(chalk.gray(`[lem-ai] ⚔ Generating Implementation.md in background...`));
28
- console.log(chalk.gray(`[lem-ai] šŸ Git checkout will proceed instantly.\n`));
26
+ console.log(chalk.cyan(`\n[get-lem-ai] šŸš€ Branch detected: ${chalk.bold(branchName)}`));
27
+ console.log(chalk.gray(`[get-lem-ai] ⚔ Generating Implementation.md in background...`));
28
+ console.log(chalk.gray(`[get-lem-ai] šŸ Git checkout will proceed instantly.\n`));
29
29
 
30
30
  const gitRoot = findGitRoot(process.cwd()) || process.cwd();
31
31
  const logPath = path.join(gitRoot, '.lem-ai.log');
package/src/install.js CHANGED
@@ -5,7 +5,7 @@ const chalk = require('chalk');
5
5
  const { findGitRoot, getConfigPath } = require('./config');
6
6
 
7
7
  const HOOK_SCRIPT = `#!/bin/sh
8
- # Injected by lem-ai
8
+ # Injected by get-lem-ai
9
9
  # This hook captures all branch creation events (git branch, git checkout -b, git switch -c)
10
10
  if [ "$1" = "committed" ]; then
11
11
  while read -r old_rev new_rev ref_name; do
@@ -13,7 +13,7 @@ if [ "$1" = "committed" ]; then
13
13
  if [ "$old_rev" = "0000000000000000000000000000000000000000" ] && [ "\${ref_name#refs/heads/}" != "$ref_name" ] && [ "$new_rev" != "0000000000000000000000000000000000000000" ]; then
14
14
  BRANCH_NAME=\${ref_name#refs/heads/}
15
15
  # Run synchronously since we fixed the Node hang issue
16
- lem-ai checkout "$BRANCH_NAME"
16
+ get-lem-ai checkout "$BRANCH_NAME"
17
17
  fi
18
18
  done
19
19
  fi
@@ -46,7 +46,7 @@ async function install() {
46
46
  if (fs.existsSync(p)) {
47
47
  const content = fs.readFileSync(p, 'utf-8');
48
48
  if (content.includes('git-jira-hook') || content.includes('getlem') || content.includes('lem')) {
49
- if (h === 'reference-transaction' && content.includes('Injected by lem-ai')) {
49
+ if (h === 'reference-transaction' && (content.includes('Injected by lem-ai') || content.includes('Injected by get-lem-ai'))) {
50
50
  // This is current, skip
51
51
  continue;
52
52
  }
@@ -84,12 +84,12 @@ function uninstall() {
84
84
  const content = fs.readFileSync(hookPath, 'utf-8');
85
85
  if (content.includes('lem-ai') || content.includes('getlem') || content.includes('lem') || content.includes('git-jira-hook')) {
86
86
  fs.unlinkSync(hookPath);
87
- console.log(chalk.green('\nāœ… lem-ai Git Hook uninstalled successfully.\n'));
87
+ console.log(chalk.green('\nāœ… get-lem-ai Git Hook uninstalled successfully.\n'));
88
88
  } else {
89
- console.log(chalk.yellow('\nāš ļø Hook at this path was not created by lem-ai. Skipping.\n'));
89
+ console.log(chalk.yellow('\nāš ļø Hook at this path was not created by get-lem-ai. Skipping.\n'));
90
90
  }
91
91
  } else {
92
- console.log(chalk.gray('\nā„¹ļø No lem-ai hook found to uninstall.\n'));
92
+ console.log(chalk.gray('\nā„¹ļø No get-lem-ai hook found to uninstall.\n'));
93
93
  }
94
94
 
95
95
  // Also remove the project-level config file if it exists
package/src/setup.js CHANGED
@@ -9,7 +9,7 @@ function ask(rl, question) {
9
9
 
10
10
  async function setup() {
11
11
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
12
- console.log(chalk.cyan('\nšŸ”§ lem-ai Setup\n'));
12
+ console.log(chalk.cyan('\nšŸ”§ get-lem-ai Setup\n'));
13
13
 
14
14
  const outputFile = await ask(rl, 'Output filename [Implementation.md]: ') || 'Implementation.md';
15
15
  const apiKey = await ask(rl, 'SDK API Key (from Lem settings): ');
@@ -21,7 +21,7 @@ async function setup() {
21
21
  });
22
22
 
23
23
  console.log(chalk.green('\nāœ… Config saved to .lem-ai.json'));
24
- console.log(chalk.yellow('šŸ‘‰ Now cd into a git repo and run: lem-ai install\n'));
24
+ console.log(chalk.yellow('šŸ‘‰ Now cd into a git repo and run: get-lem-ai install\n'));
25
25
  }
26
26
 
27
27
  module.exports = { setup };