trust-npm 0.1.1 → 0.1.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/README.md CHANGED
@@ -38,6 +38,7 @@ This will:
38
38
 
39
39
  - create/update `.trust-npm.json` from `package-lock.json`
40
40
  - persist alias `npm -> trust-npm` in your shell profile
41
+ - add/update `AGENTS.md` with trust-npm usage policy
41
42
 
42
43
  You can force shell target:
43
44
 
@@ -51,7 +52,7 @@ trust-npm init --shell zsh
51
52
 
52
53
  ### `trust-npm init`
53
54
 
54
- Initializes `.trust-npm.json` using lockfile dependencies and sets a persistent shell alias (`npm -> trust-npm`).
55
+ Initializes `.trust-npm.json`, sets shell alias, and writes agent guidance.
55
56
 
56
57
  ```bash
57
58
  trust-npm init
package/dist/cli.js CHANGED
@@ -1,7 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
3
6
  Object.defineProperty(exports, "__esModule", { value: true });
4
7
  const commander_1 = require("commander");
8
+ const package_json_1 = __importDefault(require("../package.json"));
5
9
  const init_1 = require("./commands/init");
6
10
  const install_1 = require("./commands/install");
7
11
  const approve_1 = require("./commands/approve");
@@ -10,7 +14,7 @@ const program = new commander_1.Command();
10
14
  program
11
15
  .name("trust-npm")
12
16
  .description("Secure wrapper around npm install with trust baseline checks")
13
- .version("0.1.0");
17
+ .version(package_json_1.default.version);
14
18
  program
15
19
  .command("init")
16
20
  .description("Create .trust-npm.json and auto-alias npm -> trust-npm")
@@ -24,6 +24,8 @@ async function runInit(options = {}) {
24
24
  const storePath = (0, trustStore_1.trustStorePath)(projectRoot);
25
25
  console.log(`Initialized trust store: ${storePath}`);
26
26
  console.log(`Trusted packages imported: ${trustedFromLockfile.size}`);
27
+ ensureAgentGuidance(projectRoot);
28
+ console.log("Agent guidance added: AGENTS.md updated with trust-npm policy.");
27
29
  if (!options.skipAlias) {
28
30
  const shell = detectShell(options.shell);
29
31
  const profilePath = ensureAliasInProfile(shell);
@@ -38,6 +40,27 @@ async function runInit(options = {}) {
38
40
  console.log(" Set-Alias npm trust-npm");
39
41
  }
40
42
  }
43
+ function ensureAgentGuidance(projectRoot) {
44
+ const agentsPath = path_1.default.join(projectRoot, "AGENTS.md");
45
+ const startMarker = "<!-- trust-npm policy start -->";
46
+ const endMarker = "<!-- trust-npm policy end -->";
47
+ const block = `${startMarker}
48
+ ## trust-npm Policy
49
+
50
+ Use \`trust-npm\` for dependency installs and approvals in this repo.
51
+
52
+ - Always run \`trust-npm install ...\`, never plain \`npm install ...\`.
53
+ - For blocked packages, use \`trust-npm approve <package>\` only after review.
54
+ - Use \`trust-npm status\` to inspect trust state.
55
+
56
+ ${endMarker}
57
+ `;
58
+ if (!fs_1.default.existsSync(agentsPath)) {
59
+ fs_1.default.writeFileSync(agentsPath, `${block}\n`, "utf8");
60
+ return;
61
+ }
62
+ appendBlockIfMissing(agentsPath, startMarker, block);
63
+ }
41
64
  function detectShell(requested) {
42
65
  if (requested) {
43
66
  return requested;
package/dist/core/npm.js CHANGED
@@ -7,7 +7,11 @@ async function runNpm(args) {
7
7
  return new Promise((resolve, reject) => {
8
8
  const child = (0, child_process_1.spawn)(npmCommand, args, {
9
9
  stdio: "inherit",
10
- shell: false
10
+ shell: false,
11
+ env: {
12
+ ...process.env,
13
+ TRUST_NPM_ACTIVE: "1"
14
+ }
11
15
  });
12
16
  child.on("error", (error) => reject(error));
13
17
  child.on("close", (code) => resolve(code ?? 1));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trust-npm",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "A safe npm wrapper that blocks untrusted dependencies by default.",
5
5
  "type": "commonjs",
6
6
  "main": "dist/cli.js",