@idevelopers/agentlock 0.1.0

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.
@@ -0,0 +1,35 @@
1
+ import os from "node:os";
2
+ import path from "node:path";
3
+ export function agentlockHome() {
4
+ return path.join(os.homedir(), ".agentlock");
5
+ }
6
+ export function auditLogPath() {
7
+ return path.join(agentlockHome(), "audit.jsonl");
8
+ }
9
+ export function licenseCachePath() {
10
+ return path.join(agentlockHome(), "license.json");
11
+ }
12
+ export function expandHome(inputPath) {
13
+ if (inputPath === "~") {
14
+ return os.homedir();
15
+ }
16
+ if (inputPath.startsWith("~/")) {
17
+ return path.join(os.homedir(), inputPath.slice(2));
18
+ }
19
+ return inputPath;
20
+ }
21
+ export function normalizeForPolicy(inputPath, cwd = process.cwd()) {
22
+ const resolved = path.resolve(cwd, expandHome(inputPath));
23
+ const home = os.homedir();
24
+ if (resolved === home) {
25
+ return "~";
26
+ }
27
+ if (resolved.startsWith(`${home}${path.sep}`)) {
28
+ return `~/${path.relative(home, resolved).split(path.sep).join("/")}`;
29
+ }
30
+ const relative = path.relative(cwd, resolved);
31
+ if (!relative.startsWith("..") && !path.isAbsolute(relative)) {
32
+ return relative.split(path.sep).join("/") || ".";
33
+ }
34
+ return resolved.split(path.sep).join("/");
35
+ }
@@ -0,0 +1,28 @@
1
+ const SECRET_KEY_RE = /(key|token|secret|password|credential|authorization|cookie|license)/i;
2
+ const SECRET_VALUE_RE = /(sk-[A-Za-z0-9_-]{16,}|github_pat_[A-Za-z0-9_]{20,}|gh[pousr]_[A-Za-z0-9_]{20,}|npm_[A-Za-z0-9]{20,}|AKIA[0-9A-Z]{16}|[A-Za-z0-9_./+=-]{40,})/g;
3
+ export function redactText(value) {
4
+ return value.replace(SECRET_VALUE_RE, "[REDACTED]");
5
+ }
6
+ export function redactValue(value) {
7
+ return redactUnknown(value);
8
+ }
9
+ function redactUnknown(value) {
10
+ if (typeof value === "string") {
11
+ return redactText(value);
12
+ }
13
+ if (Array.isArray(value)) {
14
+ return value.map(redactUnknown);
15
+ }
16
+ if (typeof value === "object" && value !== null) {
17
+ const redacted = {};
18
+ for (const [key, child] of Object.entries(value)) {
19
+ redacted[key] = SECRET_KEY_RE.test(key) ? "[REDACTED]" : redactUnknown(child);
20
+ }
21
+ return redacted;
22
+ }
23
+ return value;
24
+ }
25
+ export function tailRedacted(value, maxChars = 4096) {
26
+ const tail = value.length > maxChars ? value.slice(value.length - maxChars) : value;
27
+ return redactText(tail);
28
+ }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@idevelopers/agentlock",
3
+ "version": "0.1.0",
4
+ "description": "Local permission firewall for AI coding agents and MCP tools.",
5
+ "type": "module",
6
+ "bin": {
7
+ "agentlock": "dist/index.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "prepare": "npm run build",
12
+ "test": "vitest run"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "agentlock.policy.example.json",
18
+ ".mcp.json",
19
+ ".claude-plugin",
20
+ "codex-plugin",
21
+ "skills",
22
+ "commands"
23
+ ],
24
+ "keywords": [
25
+ "mcp",
26
+ "codex",
27
+ "claude-code",
28
+ "agents",
29
+ "security",
30
+ "firewall"
31
+ ],
32
+ "license": "MIT",
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "dependencies": {
37
+ "@modelcontextprotocol/sdk": "^1.13.0",
38
+ "@polar-sh/sdk": "^0.48.1",
39
+ "zod": "^3.25.67"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^20.19.1",
43
+ "typescript": "^5.8.3",
44
+ "vitest": "^3.2.4"
45
+ },
46
+ "engines": {
47
+ "node": ">=20"
48
+ }
49
+ }
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: agentlock-workflow
3
+ description: Use when running AI coding work under AgentLock permission capsules, secret-safe scans, command checks, or guarded command execution.
4
+ version: 0.1.0
5
+ ---
6
+
7
+ # AgentLock Workflow
8
+
9
+ Use this skill when an agent task should stay inside explicit local permissions.
10
+
11
+ 1. Call `agentlock_scan_environment` before starting work in a new repo.
12
+ 2. Call `agentlock_generate_policy` and create or update `agentlock.policy.json` from the returned policy.
13
+ 3. Before reading secret-adjacent files, running shell commands, contacting external domains, or calling broad MCP tools, call `agentlock_check_action`.
14
+ 4. Treat `block` as final unless the user changes policy. Treat `needs_approval` as requiring explicit user approval before continuing.
15
+ 5. Prefer `agentlock_run_guarded_command` for shell commands so policy evaluation, redacted output, and audit logging happen in one path.
16
+ 6. Review `agentlock_audit_log` after sensitive work to confirm what actions were allowed, blocked, or approved.
17
+ 7. Never print full secret values, license keys, tokens, cookies, or credential file contents.