@nexrall/code-core 1.4.65 → 1.4.66

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.
@@ -37,16 +37,20 @@ export declare const FILE_MUTATE_TOOLS: Set<string>;
37
37
  /** Tools that run a shell command. */
38
38
  export declare const BASH_TOOLS: Set<string>;
39
39
  /**
40
- * Is this bash command read-only?
40
+ * Is this bash command read-only — i.e. safe to run WITHOUT asking?
41
41
  *
42
- * Deliberately delegates to `bashNeedsRepoLock`, the classifier written for the
43
- * concurrency work: it already distinguishes commands that mutate shared state
44
- * (`git`, `npm`, `cargo`, `make` …) from ones that only read (`grep`, `ls`, `cat`,
45
- * `rg`), scanning every shell segment so `cd x && npm publish` is caught.
42
+ * History: this used to be `!bashNeedsRepoLock(command)`. That classifier answers a
43
+ * different question — "does this need the repo-state LOCK?" — by listing the ~30
44
+ * build/VCS verbs that take one (git, npm, make …). Everything NOT on that list was
45
+ * therefore "read-only", so `rm file`, `mv`, `echo x > f`, `sed -i`, `kill` and
46
+ * `curl … | sh` all ran with no prompt in `ask` and `edit` mode. Measured through the
47
+ * real `requestPermission`: prompted=0 for each. A denylist of mutators can never be
48
+ * complete; the gate needs an ALLOWLIST of readers, which plan mode already had.
46
49
  *
47
- * Reusing it is the point. Writing a second classifier here would create two
48
- * definitions of "mutating" that must agree forever — the exact failure this whole
49
- * audit keeps finding. If the lock treats a command as mutating, so does the gate.
50
+ * It now delegates to `isReadOnlyPipeline` (agent/planMode.ts), the same "provably
51
+ * read-only" classifier the plan-mode lock uses, so "read-only" means one thing in
52
+ * both places. `bashNeedsRepoLock` is unchanged and still correct for what it is for:
53
+ * deciding which calls must not run concurrently.
50
54
  */
51
55
  export declare function isReadOnlyBash(command: string): boolean;
52
56
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"modePolicy.d.ts","sourceRoot":"","sources":["../../src/permissions/modePolicy.ts"],"names":[],"mappings":"AAsBA,yDAAyD;AACzD,MAAM,MAAM,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AAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,EAAE,cAAc,CAAC;IACrB,oFAAoF;IACpF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,eAAe,aAW1B,CAAC;AAEH,0CAA0C;AAC1C,eAAO,MAAM,gBAAgB,aAG3B,CAAC;AAEH,oEAAoE;AACpE,eAAO,MAAM,iBAAiB,aAE5B,CAAC;AAEH,sCAAsC;AACtC,eAAO,MAAM,UAAU,aAAsD,CAAC;AAE9E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,WAAW,GAAG,cAAc,CAwDvD;AAED,4DAA4D;AAC5D,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAOzD;AAED,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,CAGtD"}
@@ -5,7 +5,7 @@ exports.isReadOnlyBash = isReadOnlyBash;
5
5
  exports.decide = decide;
6
6
  exports.describeMode = describeMode;
7
7
  exports.parseMode = parseMode;
8
- const bashClassify_1 = require("./bashClassify");
8
+ const planMode_1 = require("../agent/planMode");
9
9
  /**
10
10
  * Tools that only ever READ. Always allowed, in every mode including plan.
11
11
  *
@@ -48,19 +48,23 @@ exports.FILE_MUTATE_TOOLS = new Set([
48
48
  /** Tools that run a shell command. */
49
49
  exports.BASH_TOOLS = new Set(['bash', 'run_command', 'execute_command']);
50
50
  /**
51
- * Is this bash command read-only?
51
+ * Is this bash command read-only — i.e. safe to run WITHOUT asking?
52
52
  *
53
- * Deliberately delegates to `bashNeedsRepoLock`, the classifier written for the
54
- * concurrency work: it already distinguishes commands that mutate shared state
55
- * (`git`, `npm`, `cargo`, `make` …) from ones that only read (`grep`, `ls`, `cat`,
56
- * `rg`), scanning every shell segment so `cd x && npm publish` is caught.
53
+ * History: this used to be `!bashNeedsRepoLock(command)`. That classifier answers a
54
+ * different question — "does this need the repo-state LOCK?" — by listing the ~30
55
+ * build/VCS verbs that take one (git, npm, make …). Everything NOT on that list was
56
+ * therefore "read-only", so `rm file`, `mv`, `echo x > f`, `sed -i`, `kill` and
57
+ * `curl … | sh` all ran with no prompt in `ask` and `edit` mode. Measured through the
58
+ * real `requestPermission`: prompted=0 for each. A denylist of mutators can never be
59
+ * complete; the gate needs an ALLOWLIST of readers, which plan mode already had.
57
60
  *
58
- * Reusing it is the point. Writing a second classifier here would create two
59
- * definitions of "mutating" that must agree forever — the exact failure this whole
60
- * audit keeps finding. If the lock treats a command as mutating, so does the gate.
61
+ * It now delegates to `isReadOnlyPipeline` (agent/planMode.ts), the same "provably
62
+ * read-only" classifier the plan-mode lock uses, so "read-only" means one thing in
63
+ * both places. `bashNeedsRepoLock` is unchanged and still correct for what it is for:
64
+ * deciding which calls must not run concurrently.
61
65
  */
62
66
  function isReadOnlyBash(command) {
63
- return !(0, bashClassify_1.bashNeedsRepoLock)(command);
67
+ return (0, planMode_1.isReadOnlyPipeline)(command);
64
68
  }
65
69
  /**
66
70
  * The single source of truth for "should we prompt?".
package/dist/types.d.ts CHANGED
@@ -566,7 +566,7 @@ export interface AgentLoopOptions {
566
566
  *
567
567
  * Separate from _allowedTools because it restricts WHICH PATHS a granted write tool may
568
568
  * touch, not which tools exist — intersecting tool names cannot express it. It must be
569
- * inherited, or nesting defeats it: `test-writer` may only write tests, but delegating to
569
+ * inherited, or nesting defeats it: a test-only agent may only write tests, but delegating to
570
570
  * any agent without that flag would write production source on its behalf.
571
571
  */
572
572
  _testFilesOnly?: boolean;
@@ -584,7 +584,7 @@ export interface AgentLoopOptions {
584
584
  /** As `_extraAgentTypes`, for `@nexrall/agent`'s `registerSkills()`. */
585
585
  _extraSkills?: import('./agent/skills').Skill[];
586
586
  /**
587
- * Internal: the sub-agent TYPE name this run is executing as (e.g. 'reviewer'),
587
+ * Internal: the sub-agent TYPE name this run is executing as (e.g. 'explorer'),
588
588
  * or undefined for the main agent.
589
589
  *
590
590
  * Carried for the audit trail: `_agentScope` identifies the run instance
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexrall/code-core",
3
- "version": "1.4.65",
3
+ "version": "1.4.66",
4
4
  "description": "Core agent loop, tools, and extension primitives for Nexrall Code — embed an AI coding agent in any Node.js application.",
5
5
  "license": "MIT",
6
6
  "author": "Nexrall <support@nexrall.com> (https://nexrall.com)",
@@ -79,6 +79,12 @@
79
79
  "engines": {
80
80
  "node": ">=18.0.0"
81
81
  },
82
+ "scripts": {
83
+ "build": "tsc",
84
+ "dev": "tsc --watch",
85
+ "test": "npm run build && node --test test/*.test.mjs",
86
+ "prepublishOnly": "npm run build && npm test"
87
+ },
82
88
  "dependencies": {
83
89
  "eventsource-parser": "^1.1.2",
84
90
  "node-fetch": "^3.3.2",
@@ -89,10 +95,5 @@
89
95
  "devDependencies": {
90
96
  "@types/node": "^26.0.1",
91
97
  "typescript": "^6.0.3"
92
- },
93
- "scripts": {
94
- "build": "tsc",
95
- "dev": "tsc --watch",
96
- "test": "npm run build && node --test test/*.test.mjs"
97
98
  }
98
- }
99
+ }