psycgod-sage 1.0.26 → 2.5.5

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 CHANGED
@@ -1,69 +1,69 @@
1
- # SAGE npm launcher - Smart Agent Guidance Engine
2
- [![npm](https://img.shields.io/npm/v/psycgod-sage)](https://www.npmjs.com/package/psycgod-sage)
3
-
4
- This npm package is a Node-friendly launcher for the canonical Python package `psycgod-sage`.
5
- It installs/updates the PyPI SAGE core and forwards commands to `python -m sage`, so npm/npx
6
- and PyPI behavior stay identical. ML V1 is included. ML V2 remains optional.
7
-
8
- ## Installation
9
-
10
- ```bash
11
- npm install -g psycgod-sage
12
- npx -y psycgod-sage install
13
- ```
14
-
15
- `install` is the explicit one-command onboarding step before you expect Claude, Codex, Cursor, Windsurf, OpenCode, Cline, or other AI agents to use SAGE automatically. It connects this machine, writes/repairs local AI-agent memory files and supported shell-wrapper hooks, then prints a verification report. It does **not** auto-enable SAGE MCP. Restart open AI-agent sessions after install.
16
-
17
- One-shot npx usage:
18
-
19
- ```bash
20
- npx -y psycgod-sage install
21
- npx -y psycgod-sage run -- npm test
22
- ```
23
-
24
- Equivalent Python install:
25
-
26
- ```bash
27
- pip install psycgod-sage
28
- sage install
29
- sage run -- npm test
30
- ```
31
-
32
- ## Usage
33
-
34
- ```bash
35
- npx -y psycgod-sage install
36
- npx -y psycgod-sage run -- npm test
37
- npx -y psycgod-sage history
38
- npx -y psycgod-sage explain --failed
39
- npx -y psycgod-sage suggest --failed
40
- npx -y psycgod-sage predict rm -rf node_modules
41
- npx -y psycgod-sage ml setup
42
- ```
43
-
44
- If installed from PyPI, AI agents should use:
45
-
46
- ```bash
47
- sage run -- <command>
48
- ```
49
-
50
- If installed from npm/npx, AI agents should use:
51
-
52
- ```bash
53
- npx -y psycgod-sage run -- <command>
54
- ```
55
-
56
- ## Notes
57
-
58
- - npm/npx SAGE delegates to PyPI `psycgod-sage`.
59
- - There is no separate JS database, runner, compressor, or ML implementation in the active CLI path.
60
- - ML V1 is included through PyPI SAGE.
61
- - Optional ML V2 can be installed later with `npx -y psycgod-sage ml setup`.
62
- - Optional MCP tools are manual: use `npx -y psycgod-sage mcp install` only if you explicitly want an MCP server.
63
-
64
- Links:
65
-
66
- - Python: https://pypi.org/project/psycgod-sage/
67
- - Repo: https://github.com/PsYcGoD/sage
68
- - Dashboard: https://sage.api.marketingstudios.in/
69
- - License: MIT
1
+ # SAGE npm launcher - Smart Agent Guidance Engine
2
+ [![npm](https://img.shields.io/npm/v/psycgod-sage)](https://www.npmjs.com/package/psycgod-sage)
3
+
4
+ This npm package is a Node-friendly launcher for the canonical Python package `psycgod-sage`.
5
+ It installs/updates the PyPI SAGE core and forwards commands to `python -m sage`, so npm/npx
6
+ and PyPI behavior stay identical. ML V1 is included. ML V2 remains optional.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install -g psycgod-sage
12
+ npx -y psycgod-sage install
13
+ ```
14
+
15
+ `install` is the explicit one-command onboarding step before you expect Claude, Codex, Cursor, Windsurf, OpenCode, Cline, or other AI agents to use SAGE automatically. It connects this machine, writes/repairs local AI-agent memory files and supported shell-wrapper hooks, then prints a verification report. It does **not** auto-enable SAGE MCP. Restart open AI-agent sessions after install.
16
+
17
+ One-shot npx usage:
18
+
19
+ ```bash
20
+ npx -y psycgod-sage install
21
+ npx -y psycgod-sage run -- npm test
22
+ ```
23
+
24
+ Equivalent Python install:
25
+
26
+ ```bash
27
+ pip install psycgod-sage
28
+ sage install
29
+ sage run -- npm test
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ```bash
35
+ npx -y psycgod-sage install
36
+ npx -y psycgod-sage run -- npm test
37
+ npx -y psycgod-sage history
38
+ npx -y psycgod-sage explain --failed
39
+ npx -y psycgod-sage suggest --failed
40
+ npx -y psycgod-sage predict rm -rf node_modules
41
+ npx -y psycgod-sage ml setup
42
+ ```
43
+
44
+ If installed from PyPI, AI agents should use:
45
+
46
+ ```bash
47
+ sage run -- <command>
48
+ ```
49
+
50
+ If installed from npm/npx, AI agents should use:
51
+
52
+ ```bash
53
+ npx -y psycgod-sage run -- <command>
54
+ ```
55
+
56
+ ## Notes
57
+
58
+ - npm/npx SAGE delegates to PyPI `psycgod-sage`.
59
+ - There is no separate JS database, runner, compressor, or ML implementation in the active CLI path.
60
+ - ML V1 is included through PyPI SAGE.
61
+ - Optional ML V2 can be installed later with `npx -y psycgod-sage ml setup`.
62
+ - Optional MCP tools are manual: use `npx -y psycgod-sage mcp install` only if you explicitly want an MCP server.
63
+
64
+ Links:
65
+
66
+ - Python: https://pypi.org/project/psycgod-sage/
67
+ - Repo: https://github.com/PsYcGoD/sage
68
+ - Dashboard: https://sage.api.marketingstudios.in/
69
+ - License: MIT
@@ -8,7 +8,7 @@ const ENFORCE_SAGE_PY = `#!/usr/bin/env python3
8
8
  import json
9
9
  import sys
10
10
 
11
- SAGE_PREFIXES = (${JSON.stringify(SAGE_RUN_PREFIX)}, ${JSON.stringify(PYPI_RUN_PREFIX)})
11
+ SAGE_PREFIXES = (${JSON.stringify(SAGE_RUN_PREFIX)}, ${JSON.stringify(PYPI_RUN_PREFIX)})
12
12
 
13
13
  def main():
14
14
  try:
@@ -23,18 +23,18 @@ def main():
23
23
  return 0
24
24
 
25
25
  command = str(tool_input.get("command") or "").strip()
26
- if any(command.startswith(prefix) for prefix in SAGE_PREFIXES):
27
- return 0
28
-
29
- print("SAGE enforcement: shell commands must start with one of:", ", ".join(SAGE_PREFIXES), file=sys.stderr)
30
- print("The blocked command is intentionally not printed to avoid leaking secrets.", file=sys.stderr)
31
- return 2
26
+ if any(command.startswith(prefix) for prefix in SAGE_PREFIXES):
27
+ return 0
28
+
29
+ print("SAGE enforcement: shell commands must start with one of:", ", ".join(SAGE_PREFIXES), file=sys.stderr)
30
+ print("The blocked command is intentionally not printed to avoid leaking secrets.", file=sys.stderr)
31
+ return 2
32
32
 
33
33
  if __name__ == "__main__":
34
34
  raise SystemExit(main())
35
35
  `;
36
36
  const ENFORCE_SAGE_JS = `#!/usr/bin/env node
37
- const SAGE_PREFIXES = [${JSON.stringify(SAGE_RUN_PREFIX)}, ${JSON.stringify(PYPI_RUN_PREFIX)}];
37
+ const SAGE_PREFIXES = [${JSON.stringify(SAGE_RUN_PREFIX)}, ${JSON.stringify(PYPI_RUN_PREFIX)}];
38
38
 
39
39
  let input = '';
40
40
  process.stdin.setEncoding('utf8');
@@ -46,10 +46,10 @@ process.stdin.on('end', () => {
46
46
  const toolInput = data.tool_input || {};
47
47
  if (!['Bash', 'Shell', 'PowerShell', 'bash_tool'].includes(toolName)) process.exit(0);
48
48
  const command = String(toolInput.command || '').trim();
49
- if (SAGE_PREFIXES.some(prefix => command.startsWith(prefix))) process.exit(0);
50
- console.error('SAGE enforcement: shell commands must start with one of: ' + SAGE_PREFIXES.join(', '));
51
- console.error('The blocked command is intentionally not printed to avoid leaking secrets.');
52
- process.exit(2);
49
+ if (SAGE_PREFIXES.some(prefix => command.startsWith(prefix))) process.exit(0);
50
+ console.error('SAGE enforcement: shell commands must start with one of: ' + SAGE_PREFIXES.join(', '));
51
+ console.error('The blocked command is intentionally not printed to avoid leaking secrets.');
52
+ process.exit(2);
53
53
  } catch {
54
54
  process.exit(0);
55
55
  }
@@ -3,55 +3,55 @@ export const SAGE_RUN_PREFIX = 'npx -y psycgod-sage run --';
3
3
  export const PYPI_RUN_PREFIX = 'sage run --';
4
4
  export const SAGE_BLOCK_START = '# SAGE MANAGED BLOCK START';
5
5
  export const SAGE_BLOCK_END = '# SAGE MANAGED BLOCK END';
6
- export const SAGE_INSTRUCTION = `${SAGE_BLOCK_START}
7
- ## SAGE Integration - MANDATORY
8
-
9
- When a user asks for any coding, repo, file, debugging, documentation, or project task, start through SAGE automatically. The user should not need to type \`sage\`.
10
-
11
- First actions for normal repo work:
12
- - Use native file/search/edit tools normally.
13
- - Route every terminal command through the npm SAGE wrapper: \`${SAGE_RUN_PREFIX} <command>\`.
14
-
15
- Route every shell command through SAGE. Do not run bare terminal commands.
16
-
17
- Allowed wrappers:
18
- - \`${SAGE_RUN_PREFIX} <command>\`
19
- - Backup when npm/npx is unavailable: \`${PYPI_RUN_PREFIX} <command>\`
20
-
21
- Rules:
22
- - Python: \`${SAGE_RUN_PREFIX} python script.py\`
23
- - Packages: \`${SAGE_RUN_PREFIX} npm install\`
24
- - Tests: \`${SAGE_RUN_PREFIX} pytest\`
25
- - If the wrapper fails before the target command starts, stop and report the wrapper failure.
6
+ export const SAGE_INSTRUCTION = `${SAGE_BLOCK_START}
7
+ ## SAGE Integration - MANDATORY
8
+
9
+ When a user asks for any coding, repo, file, debugging, documentation, or project task, start through SAGE automatically. The user should not need to type \`sage\`.
10
+
11
+ First actions for normal repo work:
12
+ - Use native file/search/edit tools normally.
13
+ - Route every terminal command through the npm SAGE wrapper: \`${SAGE_RUN_PREFIX} <command>\`.
14
+
15
+ Route every shell command through SAGE. Do not run bare terminal commands.
16
+
17
+ Allowed wrappers:
18
+ - \`${SAGE_RUN_PREFIX} <command>\`
19
+ - Backup when npm/npx is unavailable: \`${PYPI_RUN_PREFIX} <command>\`
20
+
21
+ Rules:
22
+ - Python: \`${SAGE_RUN_PREFIX} python script.py\`
23
+ - Packages: \`${SAGE_RUN_PREFIX} npm install\`
24
+ - Tests: \`${SAGE_RUN_PREFIX} pytest\`
25
+ - If the wrapper fails before the target command starts, stop and report the wrapper failure.
26
26
 
27
27
  Why:
28
- - npm/npx SAGE delegates to the canonical SAGE core, so behavior matches \`psycgod-sage\`.
28
+ - npm/npx SAGE delegates to the canonical SAGE core, so behavior matches \`psycgod-sage\`.
29
29
  - Tracks local command history for the user.
30
30
  - Compresses noisy output before it reaches AI context.
31
31
  - Captures safe proof metrics for token savings and ML V1 prediction.
32
32
  - Keeps raw commands and output local unless the user enables higher telemetry.
33
33
 
34
- Examples:
35
- - Wrong: \`python test.py\`
36
- - Correct: \`${SAGE_RUN_PREFIX} python test.py\`
37
- - Backup: \`${PYPI_RUN_PREFIX} python test.py\`
38
- - Wrong: \`git status\`
39
- - Correct: \`${SAGE_RUN_PREFIX} git status\`
40
-
41
- Example user request:
42
- - User: "Please help me with my general book in this folder"
43
- - Correct agent start: inspect/read/edit files with available native tools, then use \`${SAGE_RUN_PREFIX} <command>\` only when a terminal command is needed.
44
- - Wrong agent start: bare \`python\`, \`git\`, \`npm\`, or \`ls\`.
45
-
46
- ML V1 is included. Optional ML V2 can be installed later by the user with:
47
- \`npx -y psycgod-sage ml setup\`
34
+ Examples:
35
+ - Wrong: \`python test.py\`
36
+ - Correct: \`${SAGE_RUN_PREFIX} python test.py\`
37
+ - Backup: \`${PYPI_RUN_PREFIX} python test.py\`
38
+ - Wrong: \`git status\`
39
+ - Correct: \`${SAGE_RUN_PREFIX} git status\`
40
+
41
+ Example user request:
42
+ - User: "Please help me with my general book in this folder"
43
+ - Correct agent start: inspect/read/edit files with available native tools, then use \`${SAGE_RUN_PREFIX} <command>\` only when a terminal command is needed.
44
+ - Wrong agent start: bare \`python\`, \`git\`, \`npm\`, or \`ls\`.
45
+
46
+ ML V1 is included. Optional ML V2 can be installed later by the user with:
47
+ \`npx -y psycgod-sage ml setup\`
48
48
  ${SAGE_BLOCK_END}
49
49
  `;
50
- export const SAGE_INSTRUCTION_SHORT = `${SAGE_BLOCK_START}
51
- # SAGE Integration - MANDATORY
52
- # Route all shell commands through: ${SAGE_RUN_PREFIX} <command>
53
- # Backup when npm/npx is unavailable: ${PYPI_RUN_PREFIX} <command>
54
- ${SAGE_BLOCK_END}
50
+ export const SAGE_INSTRUCTION_SHORT = `${SAGE_BLOCK_START}
51
+ # SAGE Integration - MANDATORY
52
+ # Route all shell commands through: ${SAGE_RUN_PREFIX} <command>
53
+ # Backup when npm/npx is unavailable: ${PYPI_RUN_PREFIX} <command>
54
+ ${SAGE_BLOCK_END}
55
55
  `;
56
56
  export const AGENT_TARGETS = [
57
57
  { name: 'Claude Code', path: '~/.claude/CLAUDE.md', instruction: SAGE_INSTRUCTION, createIfMissing: true, fileType: 'markdown' },
package/package.json CHANGED
@@ -1,50 +1,50 @@
1
- {
2
- "name": "psycgod-sage",
3
- "version": "1.0.26",
4
- "mcpName": "io.github.PsYcGoD/sage",
5
- "description": "npm/npx launcher for the canonical PyPI SAGE CLI wrapper for AI coding agents",
6
- "author": "PsYcGoD",
7
- "license": "MIT",
8
- "type": "module",
9
- "main": "./dist/index.js",
10
- "types": "./dist/index.d.ts",
11
- "bin": {
12
- "sage": "bin/sage.js"
13
- },
14
- "files": [
15
- "dist",
16
- "bin"
17
- ],
18
- "scripts": {
19
- "build": "tsc",
20
- "dev": "tsc --watch",
21
- "test": "vitest",
22
- "lint": "eslint src",
23
- "prepublishOnly": "npm run build"
24
- },
25
- "dependencies": {},
26
- "devDependencies": {
27
- "@types/better-sqlite3": "^7.6.11",
28
- "@types/node": "^22.0.0",
29
- "@types/uuid": "^10.0.0",
30
- "typescript": "^5.5.0",
31
- "vitest": "^2.0.0"
32
- },
33
- "engines": {
34
- "node": ">=18.0.0"
35
- },
36
- "repository": {
37
- "type": "git",
38
- "url": "git+https://github.com/PsYcGoD/sage.git"
39
- },
40
- "keywords": [
41
- "ai",
42
- "cli",
43
- "terminal",
44
- "compression",
45
- "mcp",
46
- "claude",
47
- "coding-agent",
48
- "developer-tools"
49
- ]
50
- }
1
+ {
2
+ "name": "psycgod-sage",
3
+ "version": "2.5.5",
4
+ "mcpName": "io.github.PsYcGoD/sage",
5
+ "description": "npm/npx launcher for the canonical PyPI SAGE CLI wrapper for AI coding agents",
6
+ "author": "PsYcGoD",
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "bin": {
12
+ "sage": "bin/sage.js"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "bin"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "dev": "tsc --watch",
21
+ "test": "vitest",
22
+ "lint": "eslint src",
23
+ "prepublishOnly": "npm run build"
24
+ },
25
+ "dependencies": {},
26
+ "devDependencies": {
27
+ "@types/better-sqlite3": "^7.6.11",
28
+ "@types/node": "^22.0.0",
29
+ "@types/uuid": "^10.0.0",
30
+ "typescript": "^5.5.0",
31
+ "vitest": "^2.0.0"
32
+ },
33
+ "engines": {
34
+ "node": ">=18.0.0"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/PsYcGoD/sage.git"
39
+ },
40
+ "keywords": [
41
+ "ai",
42
+ "cli",
43
+ "terminal",
44
+ "compression",
45
+ "mcp",
46
+ "claude",
47
+ "coding-agent",
48
+ "developer-tools"
49
+ ]
50
+ }