aienvmp 0.1.13 → 0.1.14
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/CHANGELOG.md +6 -0
- package/README.md +2 -0
- package/package.json +1 -1
- package/src/cli.js +5 -1
- package/src/commands/plan.js +77 -0
- package/src/paths.js +8 -0
- package/src/render.js +25 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.14
|
|
4
|
+
|
|
5
|
+
- Added `aienvmp plan` for read-only AI environment action plans.
|
|
6
|
+
- Added optional `aienvmp plan --write` artifacts at `.aienvmp/plan.json` and `.aienvmp/plan.md`.
|
|
7
|
+
- Kept plan output advisory-only with review gates instead of automatic fixes.
|
|
8
|
+
|
|
3
9
|
## 0.1.13
|
|
4
10
|
|
|
5
11
|
- Added `recommendedActions` to AI handoff output.
|
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ Core loop: scan the env, give AI a preflight context, and hand off safe next ste
|
|
|
17
17
|
```bash
|
|
18
18
|
npx aienvmp sync
|
|
19
19
|
npx aienvmp context
|
|
20
|
+
npx aienvmp plan
|
|
20
21
|
npx aienvmp handoff
|
|
21
22
|
npx aienvmp handoff --record --actor agent:codex
|
|
22
23
|
```
|
|
@@ -56,6 +57,7 @@ npx aienvmp snippet agents
|
|
|
56
57
|
aienvmp sync # update env map, light SBOM, ledger, dashboard
|
|
57
58
|
aienvmp context # AI preflight brief
|
|
58
59
|
aienvmp context --json # machine-readable AI decision context + recommended actions
|
|
60
|
+
aienvmp plan # read-only AI action plan, no automatic fixes
|
|
59
61
|
aienvmp handoff # next-agent handoff summary + recommended actions
|
|
60
62
|
aienvmp intent # record a planned env change
|
|
61
63
|
aienvmp record # record what changed
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -11,6 +11,7 @@ import { resolveWorkspace } from "./commands/resolve.js";
|
|
|
11
11
|
import { syncWorkspace } from "./commands/sync.js";
|
|
12
12
|
import { snippetWorkspace } from "./commands/snippet.js";
|
|
13
13
|
import { handoffWorkspace } from "./commands/handoff.js";
|
|
14
|
+
import { planWorkspace } from "./commands/plan.js";
|
|
14
15
|
import { readFileSync } from "node:fs";
|
|
15
16
|
|
|
16
17
|
const commands = new Map([
|
|
@@ -26,7 +27,8 @@ const commands = new Map([
|
|
|
26
27
|
["resolve", resolveWorkspace],
|
|
27
28
|
["sync", syncWorkspace],
|
|
28
29
|
["snippet", snippetWorkspace],
|
|
29
|
-
["handoff", handoffWorkspace]
|
|
30
|
+
["handoff", handoffWorkspace],
|
|
31
|
+
["plan", planWorkspace]
|
|
30
32
|
]);
|
|
31
33
|
|
|
32
34
|
const version = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
@@ -77,11 +79,13 @@ Usage:
|
|
|
77
79
|
aienvmp sync [--dir .] [--json] [--quiet] [--deep] [--security]
|
|
78
80
|
aienvmp context [--dir .] [--json]
|
|
79
81
|
aienvmp handoff [--dir .] [--json] [--record --actor agent:id]
|
|
82
|
+
aienvmp plan [--dir .] [--json] [--write]
|
|
80
83
|
|
|
81
84
|
Common:
|
|
82
85
|
aienvmp sync update AIENV.md, manifest, ledger, intents, and dashboard
|
|
83
86
|
aienvmp context print the AI preflight brief
|
|
84
87
|
aienvmp handoff print the next-agent handoff summary
|
|
88
|
+
aienvmp plan print a read-only AI environment action plan
|
|
85
89
|
aienvmp snippet print an AGENTS.md pointer snippet
|
|
86
90
|
aienvmp dash regenerate/open the lightweight dashboard
|
|
87
91
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import { diagnose } from "../doctor.js";
|
|
3
|
+
import { readJson, writeJson } from "../fsutil.js";
|
|
4
|
+
import { loadPolicy, policyWarnings } from "../policy.js";
|
|
5
|
+
import { intentsPath, manifestPath, planJsonPath, planMdPath, timelinePath, workspaceDir } from "../paths.js";
|
|
6
|
+
import { renderPlan } from "../render.js";
|
|
7
|
+
import { recommendedActions } from "../actions.js";
|
|
8
|
+
import { openIntents, readJsonl, readTimeline } from "../timeline.js";
|
|
9
|
+
|
|
10
|
+
export async function planWorkspace(args) {
|
|
11
|
+
const dir = workspaceDir(args);
|
|
12
|
+
const manifest = await readJson(manifestPath(dir));
|
|
13
|
+
if (!manifest) throw new Error("missing manifest; run `aienvmp sync` first");
|
|
14
|
+
const timeline = await readTimeline(timelinePath(dir));
|
|
15
|
+
const intents = openIntents(await readJsonl(intentsPath(dir)));
|
|
16
|
+
const policy = await loadPolicy(dir);
|
|
17
|
+
const warnings = [...diagnose(manifest, { timeline, intents }), ...policyWarnings(manifest, policy)];
|
|
18
|
+
const plan = buildPlan(manifest, warnings, intents, policy);
|
|
19
|
+
|
|
20
|
+
if (args.write) {
|
|
21
|
+
await writeJson(planJsonPath(dir), plan);
|
|
22
|
+
await fs.writeFile(planMdPath(dir), renderPlan(plan), "utf8");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (args.json) {
|
|
26
|
+
console.log(JSON.stringify(plan, null, 2));
|
|
27
|
+
} else {
|
|
28
|
+
console.log(renderPlan(plan));
|
|
29
|
+
}
|
|
30
|
+
return plan;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function buildPlan(manifest, warnings = [], intents = [], policy = {}) {
|
|
34
|
+
const actions = recommendedActions(manifest, { warnings, intents });
|
|
35
|
+
const status = warnings.length || intents.length ? "review-required" : "clear";
|
|
36
|
+
return {
|
|
37
|
+
schemaVersion: 1,
|
|
38
|
+
generatedAt: new Date().toISOString(),
|
|
39
|
+
status,
|
|
40
|
+
workspace: manifest.workspace || {},
|
|
41
|
+
trust: manifest.trust || {},
|
|
42
|
+
policy: {
|
|
43
|
+
node: policy.node || "not set",
|
|
44
|
+
python: policy.python || "not set",
|
|
45
|
+
packageManager: policy.packageManager || "not set",
|
|
46
|
+
runtimeChanges: policy.runtimeChanges || "ask-first",
|
|
47
|
+
globalInstalls: policy.globalInstalls || "ask-first"
|
|
48
|
+
},
|
|
49
|
+
recommendedActions: actions,
|
|
50
|
+
reviewGates: reviewGates(warnings, intents, manifest.security),
|
|
51
|
+
warnings,
|
|
52
|
+
openIntents: intents.slice(-5).reverse(),
|
|
53
|
+
security: {
|
|
54
|
+
mode: manifest.security?.mode || "basic",
|
|
55
|
+
enabled: manifest.security?.enabled === true,
|
|
56
|
+
summary: manifest.security?.summary || { total: 0, critical: 0, high: 0, moderate: 0, low: 0, info: 0 },
|
|
57
|
+
topPackages: manifest.security?.topPackages || []
|
|
58
|
+
},
|
|
59
|
+
notes: [
|
|
60
|
+
"This plan is read-only.",
|
|
61
|
+
"Ask the user before global runtime, package manager, Docker, or global package changes.",
|
|
62
|
+
"Prefer project-local version files and local environments."
|
|
63
|
+
]
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function reviewGates(warnings, intents, security = {}) {
|
|
68
|
+
const gates = [];
|
|
69
|
+
if (warnings.length) gates.push("Review warnings before changing the environment.");
|
|
70
|
+
if (intents.length) gates.push("Resolve or coordinate open intents before overlapping environment changes.");
|
|
71
|
+
const summary = security.summary || {};
|
|
72
|
+
if (security.enabled && (Number(summary.critical || 0) > 0 || Number(summary.high || 0) > 0)) {
|
|
73
|
+
gates.push("Review high or critical vulnerability remediation before dependency or deployment changes.");
|
|
74
|
+
}
|
|
75
|
+
if (!gates.length) gates.push("No blocking gates detected; continue project-local work and record intent before environment changes.");
|
|
76
|
+
return gates;
|
|
77
|
+
}
|
package/src/paths.js
CHANGED
|
@@ -28,6 +28,14 @@ export function dashboardPath(dir) {
|
|
|
28
28
|
return path.join(stateDir(dir), "dashboard.html");
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
export function planJsonPath(dir) {
|
|
32
|
+
return path.join(stateDir(dir), "plan.json");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function planMdPath(dir) {
|
|
36
|
+
return path.join(stateDir(dir), "plan.md");
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
export function aiEnvPath(dir) {
|
|
32
40
|
return path.join(dir, "AIENV.md");
|
|
33
41
|
}
|
package/src/render.js
CHANGED
|
@@ -164,6 +164,31 @@ export function renderHandoff(handoff) {
|
|
|
164
164
|
return lines.join("\n");
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
export function renderPlan(plan) {
|
|
168
|
+
const lines = [
|
|
169
|
+
"# AI Environment Plan",
|
|
170
|
+
"",
|
|
171
|
+
`Status: ${plan.status}`,
|
|
172
|
+
`Generated: ${plan.generatedAt}`,
|
|
173
|
+
`Workspace: ${plan.workspace?.path || "unknown"}`,
|
|
174
|
+
"",
|
|
175
|
+
"Purpose: read-only review plan for AI agents and humans. It does not install, remove, upgrade, downgrade, or lock anything.",
|
|
176
|
+
"",
|
|
177
|
+
"Recommended actions:",
|
|
178
|
+
...(plan.recommendedActions.length
|
|
179
|
+
? plan.recommendedActions.map((item) => `- [${item.priority}] ${item.category}: ${item.summary}${item.command ? ` (${item.command})` : ""}`)
|
|
180
|
+
: ["- none"]),
|
|
181
|
+
"",
|
|
182
|
+
"Review gates:",
|
|
183
|
+
...plan.reviewGates.map((item) => `- ${item}`),
|
|
184
|
+
"",
|
|
185
|
+
"Warnings:",
|
|
186
|
+
...(plan.warnings.length ? plan.warnings.map((warning) => `- [${warning.code}] ${warning.message}`) : ["- none"]),
|
|
187
|
+
""
|
|
188
|
+
];
|
|
189
|
+
return lines.join("\n");
|
|
190
|
+
}
|
|
191
|
+
|
|
167
192
|
export function renderDashboard(manifest, timeline = [], warnings = [], intents = [], policy = {}) {
|
|
168
193
|
const data = JSON.stringify({ manifest, timeline, warnings, intents, policy });
|
|
169
194
|
return `<!doctype html>
|