@vishal2612200/agentpack 0.2.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 AgentPack Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # AgentPack npm wrapper
2
+
3
+ Task-aware context packing for AI coding agents.
4
+
5
+ This npm package is a thin wrapper around the Python package
6
+ [`agentpack-cli`](https://pypi.org/project/agentpack-cli/). On first run it:
7
+
8
+ 1. Finds Python 3.10+.
9
+ 2. Creates a per-version virtual environment under your user cache directory.
10
+ 3. Installs the matching PyPI package version.
11
+ 4. Proxies all arguments to the real `agentpack` CLI.
12
+
13
+ ```bash
14
+ npm install -g @vishal2612200/agentpack
15
+ agentpack quickstart --task "fix auth token expiry"
16
+ ```
17
+
18
+ ## Requirements
19
+
20
+ - Node.js 18+
21
+ - Python 3.10+
22
+ - macOS or Linux
23
+
24
+ Windows is not supported by AgentPack yet. Use WSL or install the Python package
25
+ directly inside a Linux environment.
26
+
27
+ ## Python selection
28
+
29
+ By default, the wrapper tries `python3` and then `python`. To force a specific
30
+ interpreter:
31
+
32
+ ```bash
33
+ AGENTPACK_PYTHON=/opt/homebrew/bin/python3 agentpack --version
34
+ ```
35
+
36
+ ## Cache location
37
+
38
+ The wrapper installs the Python CLI under:
39
+
40
+ ```text
41
+ $XDG_CACHE_HOME/agentpack-npm/<version>/
42
+ ```
43
+
44
+ or, if `XDG_CACHE_HOME` is unset:
45
+
46
+ ```text
47
+ ~/.cache/agentpack-npm/<version>/
48
+ ```
49
+
50
+ Override with:
51
+
52
+ ```bash
53
+ AGENTPACK_NPM_CACHE_DIR=/tmp/agentpack-cache agentpack --version
54
+ ```
55
+
56
+ ## Upstream
57
+
58
+ Full docs: <https://github.com/vishal2612200/agentpack>
@@ -0,0 +1,160 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawnSync } = require("node:child_process");
5
+ const fs = require("node:fs");
6
+ const os = require("node:os");
7
+ const path = require("node:path");
8
+
9
+ const PACKAGE_VERSION = "0.2.2";
10
+ const PYPI_PACKAGE = `agentpack-cli==${PACKAGE_VERSION}`;
11
+
12
+ function compareVersions(left, right) {
13
+ const a = String(left).split(".").map((part) => Number.parseInt(part, 10) || 0);
14
+ const b = String(right).split(".").map((part) => Number.parseInt(part, 10) || 0);
15
+ const length = Math.max(a.length, b.length);
16
+ for (let i = 0; i < length; i += 1) {
17
+ const delta = (a[i] || 0) - (b[i] || 0);
18
+ if (delta !== 0) {
19
+ return delta;
20
+ }
21
+ }
22
+ return 0;
23
+ }
24
+
25
+ function run(command, args, options = {}) {
26
+ return spawnSync(command, args, {
27
+ encoding: "utf8",
28
+ ...options,
29
+ });
30
+ }
31
+
32
+ function fail(message, code = 1) {
33
+ console.error(`agentpack npm wrapper: ${message}`);
34
+ process.exit(code);
35
+ }
36
+
37
+ function pythonVersion(python) {
38
+ const result = run(python, [
39
+ "-c",
40
+ "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')",
41
+ ]);
42
+ if (result.status !== 0) {
43
+ return null;
44
+ }
45
+ return result.stdout.trim();
46
+ }
47
+
48
+ function findPython() {
49
+ const candidates = [
50
+ process.env.AGENTPACK_PYTHON,
51
+ "python3",
52
+ "python",
53
+ ].filter(Boolean);
54
+
55
+ for (const candidate of candidates) {
56
+ const version = pythonVersion(candidate);
57
+ if (version && compareVersions(version, "3.10") >= 0) {
58
+ return { command: candidate, version };
59
+ }
60
+ }
61
+ return null;
62
+ }
63
+
64
+ function cacheRoot() {
65
+ if (process.env.AGENTPACK_NPM_CACHE_DIR) {
66
+ return process.env.AGENTPACK_NPM_CACHE_DIR;
67
+ }
68
+ const base = process.env.XDG_CACHE_HOME || path.join(os.homedir(), ".cache");
69
+ return path.join(base, "agentpack-npm", PACKAGE_VERSION);
70
+ }
71
+
72
+ function venvPaths(root) {
73
+ const venv = path.join(root, "venv");
74
+ const bin = process.platform === "win32" ? path.join(venv, "Scripts") : path.join(venv, "bin");
75
+ return {
76
+ venv,
77
+ python: process.platform === "win32" ? path.join(bin, "python.exe") : path.join(bin, "python"),
78
+ agentpack: process.platform === "win32" ? path.join(bin, "agentpack.exe") : path.join(bin, "agentpack"),
79
+ marker: path.join(root, "agentpack-cli-version.txt"),
80
+ };
81
+ }
82
+
83
+ function ensureSupportedPlatform() {
84
+ if (process.platform === "win32") {
85
+ fail("Windows is not supported yet. Please use macOS/Linux or install agentpack-cli directly in WSL.");
86
+ }
87
+ }
88
+
89
+ function installOrUpdateVenv(systemPython, paths) {
90
+ const marker = fs.existsSync(paths.marker) ? fs.readFileSync(paths.marker, "utf8").trim() : "";
91
+ if (marker === PACKAGE_VERSION && fs.existsSync(paths.agentpack)) {
92
+ return;
93
+ }
94
+
95
+ fs.mkdirSync(path.dirname(paths.marker), { recursive: true });
96
+
97
+ let result = run(systemPython, ["-m", "venv", paths.venv], { stdio: "inherit" });
98
+ if (result.status !== 0) {
99
+ fail(`failed to create Python virtual environment at ${paths.venv}`);
100
+ }
101
+
102
+ result = run(paths.python, ["-m", "pip", "install", "--upgrade", "pip"], { stdio: "inherit" });
103
+ if (result.status !== 0) {
104
+ fail("failed to upgrade pip in the AgentPack npm wrapper environment");
105
+ }
106
+
107
+ result = run(paths.python, ["-m", "pip", "install", "--upgrade", PYPI_PACKAGE], { stdio: "inherit" });
108
+ if (result.status !== 0) {
109
+ fail(`failed to install ${PYPI_PACKAGE}`);
110
+ }
111
+
112
+ fs.writeFileSync(paths.marker, `${PACKAGE_VERSION}\n`);
113
+ }
114
+
115
+ function main(argv = process.argv.slice(2)) {
116
+ const root = cacheRoot();
117
+ const paths = venvPaths(root);
118
+
119
+ if (process.env.AGENTPACK_NPM_DRY_RUN === "1") {
120
+ console.log(JSON.stringify({
121
+ packageVersion: PACKAGE_VERSION,
122
+ pypiPackage: PYPI_PACKAGE,
123
+ cacheRoot: root,
124
+ venv: paths.venv,
125
+ }));
126
+ return;
127
+ }
128
+
129
+ ensureSupportedPlatform();
130
+
131
+ const python = findPython();
132
+ if (!python) {
133
+ fail("Python >=3.10 is required. Install Python, or set AGENTPACK_PYTHON=/path/to/python.");
134
+ }
135
+
136
+ installOrUpdateVenv(python.command, paths);
137
+
138
+ const result = spawnSync(paths.agentpack, argv, {
139
+ stdio: "inherit",
140
+ env: process.env,
141
+ });
142
+ if (result.error) {
143
+ fail(`failed to run ${paths.agentpack}: ${result.error.message}`);
144
+ }
145
+ process.exit(typeof result.status === "number" ? result.status : 1);
146
+ }
147
+
148
+ if (require.main === module) {
149
+ main();
150
+ }
151
+
152
+ module.exports = {
153
+ PACKAGE_VERSION,
154
+ PYPI_PACKAGE,
155
+ cacheRoot,
156
+ compareVersions,
157
+ findPython,
158
+ pythonVersion,
159
+ venvPaths,
160
+ };
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@vishal2612200/agentpack",
3
+ "version": "0.2.2",
4
+ "description": "Task-aware context packing for AI coding agents. npm wrapper for the Python AgentPack CLI.",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/vishal2612200/agentpack#readme",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/vishal2612200/agentpack.git",
10
+ "directory": "npm"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/vishal2612200/agentpack/issues"
14
+ },
15
+ "bin": {
16
+ "agentpack": "bin/agentpack.js"
17
+ },
18
+ "files": [
19
+ "bin/",
20
+ "LICENSE",
21
+ "README.md"
22
+ ],
23
+ "scripts": {
24
+ "test": "node --test test/*.test.js",
25
+ "prepack": "node test/version-sync.test.js"
26
+ },
27
+ "engines": {
28
+ "node": ">=18"
29
+ },
30
+ "keywords": [
31
+ "ai",
32
+ "cli",
33
+ "claude",
34
+ "codex",
35
+ "context",
36
+ "cursor",
37
+ "antigravity",
38
+ "llm",
39
+ "packing",
40
+ "windsurf"
41
+ ]
42
+ }