pi-local-agents-only 0.1.0 → 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/LICENSE +21 -0
- package/README.md +9 -1
- package/package.json +16 -2
- package/test/local-agents-only.test.mjs +0 -50
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mitch Fultz
|
|
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
CHANGED
|
@@ -4,8 +4,16 @@ Use repo-local `AGENTS.md` only for selected projects by stripping global `AGENT
|
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
+
Install it from npm with pi:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pi install npm:pi-local-agents-only
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or install it directly from GitHub with pi:
|
|
14
|
+
|
|
7
15
|
```bash
|
|
8
|
-
pi install
|
|
16
|
+
pi install https://github.com/fitchmultz/pi-local-agents-only
|
|
9
17
|
```
|
|
10
18
|
|
|
11
19
|
## Use
|
package/package.json
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-local-agents-only",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Pi extension that strips global AGENTS.md and CLAUDE.md from the effective prompt for selected projects.",
|
|
5
|
+
"author": "Mitch Fultz (https://github.com/fitchmultz)",
|
|
6
|
+
"license": "MIT",
|
|
5
7
|
"type": "module",
|
|
6
|
-
"keywords": ["pi-package"],
|
|
8
|
+
"keywords": ["pi-package", "pi", "pi-extension", "extension"],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/fitchmultz/pi-local-agents-only.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/fitchmultz/pi-local-agents-only/issues"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/fitchmultz/pi-local-agents-only#readme",
|
|
17
|
+
"files": ["extensions", "README.md"],
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@mariozechner/pi-coding-agent": "*"
|
|
20
|
+
},
|
|
7
21
|
"pi": {
|
|
8
22
|
"extensions": ["./extensions"]
|
|
9
23
|
},
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Verify the local-agents-only extension's repo detection, activation precedence, and prompt stripping.
|
|
3
|
-
* Responsibilities: Test git-root discovery, env and config precedence, and removal of global prompt blocks.
|
|
4
|
-
* Scope: Minimal unit tests for the extension's exported helpers.
|
|
5
|
-
* Usage: Run `npm test` from the package root.
|
|
6
|
-
* Invariants/Assumptions: Tests use temporary directories and do not touch the user's real pi config.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import test from "node:test";
|
|
10
|
-
import assert from "node:assert/strict";
|
|
11
|
-
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
12
|
-
import { tmpdir } from "node:os";
|
|
13
|
-
import { join } from "node:path";
|
|
14
|
-
|
|
15
|
-
import { findProjectRoot, getMode, stripGlobalBlocks } from "../extensions/local-agents-only.js";
|
|
16
|
-
|
|
17
|
-
test("findProjectRoot returns the nearest git root", () => {
|
|
18
|
-
const root = mkdtempSync(join(tmpdir(), "pi-local-agents-only-root-"));
|
|
19
|
-
const nested = join(root, "a", "b");
|
|
20
|
-
mkdirSync(join(root, ".git"), { recursive: true });
|
|
21
|
-
mkdirSync(nested, { recursive: true });
|
|
22
|
-
assert.equal(findProjectRoot(nested), root);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test("getMode prefers env override, then repo marker, then global config", () => {
|
|
26
|
-
const root = mkdtempSync(join(tmpdir(), "pi-local-agents-only-mode-"));
|
|
27
|
-
const configPath = join(root, "local-agents-only.json");
|
|
28
|
-
const markerPath = join(root, ".pi", "local-agents-only");
|
|
29
|
-
mkdirSync(join(root, ".pi"), { recursive: true });
|
|
30
|
-
writeFileSync(configPath, JSON.stringify({ projects: [root] }));
|
|
31
|
-
writeFileSync(markerPath, "\n");
|
|
32
|
-
assert.deepEqual(getMode(root, "1", configPath), { enabled: true, source: "env" });
|
|
33
|
-
assert.deepEqual(getMode(root, "0", configPath), { enabled: false, source: "env" });
|
|
34
|
-
assert.deepEqual(getMode(root, "", configPath), { enabled: true, source: "marker" });
|
|
35
|
-
assert.equal(rmSync(markerPath, { force: true }), undefined);
|
|
36
|
-
assert.deepEqual(getMode(root, "", configPath), { enabled: true, source: "global-config" });
|
|
37
|
-
assert.deepEqual(getMode(mkdtempSync(join(tmpdir(), "pi-local-agents-only-default-")), "", configPath), {
|
|
38
|
-
enabled: false,
|
|
39
|
-
source: "default",
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test("stripGlobalBlocks removes global blocks and keeps local AGENTS or CLAUDE context", () => {
|
|
44
|
-
const globalAgents = "## /home/me/.pi/agent/AGENTS.md\n\nA\n\n";
|
|
45
|
-
const globalClaude = "## /home/me/.pi/agent/CLAUDE.md\n\nB\n\n";
|
|
46
|
-
const localAgents = "## /repo/AGENTS.md\n\nLOCAL AGENTS\n\n";
|
|
47
|
-
const localClaude = "## /repo/subdir/CLAUDE.md\n\nLOCAL CLAUDE\n\n";
|
|
48
|
-
const prompt = `${globalAgents}${globalClaude}${localAgents}${localClaude}`;
|
|
49
|
-
assert.equal(stripGlobalBlocks(prompt, [globalAgents, globalClaude]), `${localAgents}${localClaude}`);
|
|
50
|
-
});
|