@feedpia/olp 0.0.0-stage → 0.1.1
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 +15 -2
- package/bin/olp.js +64 -0
- package/package.json +27 -4
package/README.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @feedpia/olp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Outcome Lookahead Protocol (OLP): before an AI agent's command runs, see what it would remove and how many.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npx @feedpia/olp install
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Run it in the project folder where you use Claude Code (Node.js 18 or later). It copies `olp-hook` to `olp` in your home folder and adds one `olp-hook` entry each to `PreToolUse` and `PostToolUse` in `.claude/settings.json`. Other entries stay as they are; the old file is backed up to `olp/backup` in your home folder. `--dry-run` shows the change without making it.
|
|
10
|
+
|
|
11
|
+
- Undo: `npx @feedpia/olp uninstall` removes only the `olp-hook` lines.
|
|
12
|
+
- The hook runs on your device. The hook itself makes no network calls.
|
|
13
|
+
|
|
14
|
+
Builds: Windows x64, macOS (Apple silicon, Intel), Linux x64, Linux arm64. Full guide: the `olp-hook` README in the repository.
|
|
15
|
+
|
|
16
|
+
License: MIT.
|
package/bin/olp.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @feedpia/olp — a small JS that picks the binary inside the per-OS package (@feedpia/olp-<os>-<cpu>).
|
|
3
|
+
// What it does: passes the arguments to olp-hook as is and exits with its exit code (`gui` = not in this version). No dependencies, no network.
|
|
4
|
+
// The hook itself does not go through Node: `install` copies the binary to a fixed place and writes that path into settings.json.
|
|
5
|
+
'use strict';
|
|
6
|
+
const path = require('node:path');
|
|
7
|
+
|
|
8
|
+
/** `<process.platform>-<process.arch>` → package name. A combination not listed here = no build yet. */
|
|
9
|
+
const PLATFORMS = {
|
|
10
|
+
'win32-x64': '@feedpia/olp-win32-x64',
|
|
11
|
+
'darwin-arm64': '@feedpia/olp-darwin-arm64',
|
|
12
|
+
'darwin-x64': '@feedpia/olp-darwin-x64',
|
|
13
|
+
'linux-x64': '@feedpia/olp-linux-x64',
|
|
14
|
+
'linux-arm64': '@feedpia/olp-linux-arm64',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Decides what to run (does not run it). resolve(spec) = path to that package's package.json, or null.
|
|
19
|
+
* @returns {{file?: string, args?: string[], error?: string}}
|
|
20
|
+
*/
|
|
21
|
+
function plan(platform, arch, args, resolve) {
|
|
22
|
+
const key = `${platform}-${arch}`;
|
|
23
|
+
const name = PLATFORMS[key];
|
|
24
|
+
if (!name) {
|
|
25
|
+
return { error: `olp: there is no build for ${key} yet (available: ${Object.keys(PLATFORMS).join(', ')}).` };
|
|
26
|
+
}
|
|
27
|
+
const manifest = resolve(`${name}/package.json`);
|
|
28
|
+
if (!manifest) {
|
|
29
|
+
return { error: `olp: the package for your system (${name}) was not installed. Install again without --omit=optional or --no-optional.` };
|
|
30
|
+
}
|
|
31
|
+
// olp-gui is not packaged → do not look for a binary, give one line of reason
|
|
32
|
+
if (args[0] === 'gui') {
|
|
33
|
+
return { error: 'olp: the file picker is not in this release. Read the card, then tell the agent what to change.' };
|
|
34
|
+
}
|
|
35
|
+
const exe = 'olp-hook' + (platform === 'win32' ? '.exe' : '');
|
|
36
|
+
// called with no arguments, olp-hook would wait on stdin in hook mode, so show help instead
|
|
37
|
+
const rest = args.length === 0 ? ['--help'] : args;
|
|
38
|
+
return { file: path.join(path.dirname(manifest), 'bin', exe), args: rest };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function main() {
|
|
42
|
+
const resolve = (spec) => {
|
|
43
|
+
try {
|
|
44
|
+
return require.resolve(spec);
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const p = plan(process.platform, process.arch, process.argv.slice(2), resolve);
|
|
50
|
+
if (p.error) {
|
|
51
|
+
process.stderr.write(`${p.error}\n`);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
const r = require('node:child_process').spawnSync(p.file, p.args, { stdio: 'inherit' });
|
|
55
|
+
if (r.error) {
|
|
56
|
+
process.stderr.write(`olp: could not run ${p.file}\n`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
process.exit(r.status === null ? 1 : r.status);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (require.main === module) main();
|
|
63
|
+
|
|
64
|
+
module.exports = { plan, PLATFORMS };
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feedpia/olp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Outcome Lookahead Protocol (OLP): see what an AI agent's command would remove before it runs. Installs the olp-hook device hook for Claude Code.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/feedpia/outcome-lookahead-protocol.git"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"olp": "bin/olp.js"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"bin/"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18"
|
|
21
|
+
},
|
|
22
|
+
"optionalDependencies": {
|
|
23
|
+
"@feedpia/olp-darwin-arm64": "=0.1.1",
|
|
24
|
+
"@feedpia/olp-darwin-x64": "=0.1.1",
|
|
25
|
+
"@feedpia/olp-linux-arm64": "=0.1.1",
|
|
26
|
+
"@feedpia/olp-linux-x64": "=0.1.1",
|
|
27
|
+
"@feedpia/olp-win32-x64": "=0.1.1"
|
|
28
|
+
}
|
|
29
|
+
}
|