superpowers-manager 0.6.0 → 0.7.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.
- package/README.md +42 -26
- package/dist/adapter-result.js +5 -9
- package/dist/atomic.js +4 -14
- package/dist/cli-arguments.js +1 -27
- package/dist/cli.js +25 -40
- package/dist/commands/adapter-call.js +28 -0
- package/dist/commands/install.js +25 -105
- package/dist/commands/pin.js +1 -1
- package/dist/commands/prepare.js +37 -81
- package/dist/commands/probe.js +35 -262
- package/dist/commands/track-latest.js +1 -1
- package/dist/commands/uninstall.js +15 -91
- package/dist/commands/update.js +5 -25
- package/dist/effective-selection.js +4 -6
- package/dist/git-tree.js +85 -0
- package/dist/harness-command-result.js +47 -0
- package/dist/harnesses/codex/adapter.js +12 -41
- package/dist/harnesses/codex/conflicts.js +2 -3
- package/dist/harnesses/codex/hooks.js +1 -1
- package/dist/harnesses/codex/json.js +1 -11
- package/dist/harnesses/codex/lifecycle.js +0 -48
- package/dist/harnesses/codex/manifest-overlay.js +1 -1
- package/dist/harnesses/codex/paths.js +14 -29
- package/dist/harnesses/codex/presentation.js +2 -23
- package/dist/harnesses/codex/publication.js +0 -6
- package/dist/harnesses/codex/recovery.js +5 -5
- package/dist/harnesses/codex/stored-state.js +1 -1
- package/dist/harnesses/opencode/config.js +256 -0
- package/dist/harnesses/opencode/discovery.js +587 -0
- package/dist/harnesses/opencode/harness.js +37 -0
- package/dist/harnesses/opencode/install.js +601 -0
- package/dist/harnesses/opencode/native.js +57 -0
- package/dist/harnesses/opencode/package.js +89 -0
- package/dist/harnesses/opencode/paths.js +38 -0
- package/dist/harnesses/opencode/prepare.js +30 -0
- package/dist/harnesses/opencode/presentation.js +28 -0
- package/dist/harnesses/opencode/state.js +174 -0
- package/dist/harnesses/pi/compatibility.js +5 -37
- package/dist/harnesses/pi/install.js +7 -5
- package/dist/harnesses/pi/native.js +3 -47
- package/dist/harnesses/pi/package.js +5 -107
- package/dist/harnesses/pi/prepare.js +13 -104
- package/dist/harnesses/pi/presentation.js +23 -66
- package/dist/harnesses/pi/shared-skills.js +28 -39
- package/dist/harnesses/pi/state.js +7 -27
- package/dist/provenance.js +2 -2
- package/dist/safe-path.js +2 -2
- package/dist/selection-store.js +2 -22
- package/dist/snapshot-package.js +78 -0
- package/dist/snapshot-prepare.js +99 -0
- package/dist/snapshot-presentation.js +44 -0
- package/dist/validator.js +4 -1
- package/node_modules/jsonc-parser/CHANGELOG.md +76 -0
- package/node_modules/jsonc-parser/LICENSE.md +21 -0
- package/node_modules/jsonc-parser/README.md +364 -0
- package/node_modules/jsonc-parser/SECURITY.md +41 -0
- package/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
- package/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
- package/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
- package/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
- package/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
- package/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
- package/node_modules/jsonc-parser/lib/esm/main.js +178 -0
- package/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
- package/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
- package/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
- package/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
- package/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
- package/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
- package/node_modules/jsonc-parser/lib/umd/main.js +194 -0
- package/node_modules/jsonc-parser/package.json +37 -0
- package/package.json +8 -4
- package/dist/domain/fingerprint.js +0 -4
- package/dist/status.js +0 -24
- package/dist/validate-generated-plugin-cli.js +0 -118
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { lstat } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { addArtifactHashField, digestArtifactTree, readArtifactFile, } from "./artifact-tree.js";
|
|
5
|
+
import { classifyPathNoFollow } from "./safe-path.js";
|
|
6
|
+
import { validateSource } from "./selection.js";
|
|
7
|
+
const OFFICIAL_SOURCES = new Set([
|
|
8
|
+
"https://github.com/obra/superpowers",
|
|
9
|
+
"https://github.com/obra/superpowers.git",
|
|
10
|
+
"ssh://git@github.com/obra/superpowers.git",
|
|
11
|
+
"git@github.com:obra/superpowers.git",
|
|
12
|
+
]);
|
|
13
|
+
export async function observeSnapshot(root, readReceipt) {
|
|
14
|
+
const kind = await classifyPathNoFollow(root);
|
|
15
|
+
if (kind === "missing")
|
|
16
|
+
return { kind: "absent" };
|
|
17
|
+
if (kind !== "directory")
|
|
18
|
+
return { kind: "unverified" };
|
|
19
|
+
try {
|
|
20
|
+
const receipt = await readReceipt(root);
|
|
21
|
+
const digest = await digestArtifactTree(root);
|
|
22
|
+
return receipt.digest === digest
|
|
23
|
+
? { kind: "owned", receipt, digest }
|
|
24
|
+
: { kind: "unverified" };
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return { kind: "unverified" };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function isOfficialSnapshotSource(source) {
|
|
31
|
+
return OFFICIAL_SOURCES.has(source);
|
|
32
|
+
}
|
|
33
|
+
export function sameSnapshotSource(left, right) {
|
|
34
|
+
validateSource(left);
|
|
35
|
+
validateSource(right);
|
|
36
|
+
return (left === right ||
|
|
37
|
+
(isOfficialSnapshotSource(left) && isOfficialSnapshotSource(right)));
|
|
38
|
+
}
|
|
39
|
+
// A consistency checksum, not authentication. A coherent manual rewrite of
|
|
40
|
+
// both receipt and bytes remains possible; installed comparison must still use
|
|
41
|
+
// an independently validated candidate.
|
|
42
|
+
export function snapshotReceiptBinding(receipt) {
|
|
43
|
+
const hash = createHash("sha256");
|
|
44
|
+
for (const field of [
|
|
45
|
+
String(receipt.schema),
|
|
46
|
+
receipt.manager,
|
|
47
|
+
receipt.harness,
|
|
48
|
+
receipt.source,
|
|
49
|
+
receipt.commit,
|
|
50
|
+
receipt.digest,
|
|
51
|
+
])
|
|
52
|
+
addArtifactHashField(hash, Buffer.from(field));
|
|
53
|
+
return hash.digest("hex");
|
|
54
|
+
}
|
|
55
|
+
export function requireNoSnapshotDependencies(pkg) {
|
|
56
|
+
for (const key of [
|
|
57
|
+
"dependencies",
|
|
58
|
+
"optionalDependencies",
|
|
59
|
+
"peerDependencies",
|
|
60
|
+
"bundleDependencies",
|
|
61
|
+
"bundledDependencies",
|
|
62
|
+
]) {
|
|
63
|
+
const value = pkg[key];
|
|
64
|
+
if (value !== undefined &&
|
|
65
|
+
(value === null ||
|
|
66
|
+
typeof value !== "object" ||
|
|
67
|
+
Object.keys(value).length !== 0))
|
|
68
|
+
throw new Error("runtime dependencies");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export async function requireSnapshotBootstrap(root, relativePath, expectedSize, expectedDigest) {
|
|
72
|
+
const bootstrap = join(root, relativePath);
|
|
73
|
+
const bytes = await readArtifactFile(root, bootstrap, expectedSize);
|
|
74
|
+
if ((await lstat(bootstrap)).mode & 0o111 ||
|
|
75
|
+
bytes.length !== expectedSize ||
|
|
76
|
+
createHash("sha256").update(bytes).digest("hex") !== expectedDigest)
|
|
77
|
+
throw new Error("bootstrap implementation");
|
|
78
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { failureResult, successResult, } from "./adapter-result.js";
|
|
4
|
+
import { ARTIFACT_RECEIPT, digestArtifactTree } from "./artifact-tree.js";
|
|
5
|
+
import { materializeGitTree } from "./git-tree.js";
|
|
6
|
+
import { classifyPathNoFollow } from "./safe-path.js";
|
|
7
|
+
import { sameSnapshotSource, snapshotReceiptBinding, } from "./snapshot-package.js";
|
|
8
|
+
export function createSnapshotPreparation(b) {
|
|
9
|
+
const artifactFrom = (root, a) => ({
|
|
10
|
+
root,
|
|
11
|
+
commit: a.receipt.commit,
|
|
12
|
+
identity: a.receipt.digest,
|
|
13
|
+
compatibility: a.compatibility,
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
async prepareCandidate(input) {
|
|
17
|
+
try {
|
|
18
|
+
await materializeGitTree(input.upstreamRoot, input.selection.desiredCommit, input.candidateRoot);
|
|
19
|
+
const compatibility = await b.assessCompatibility(input.candidateRoot, input.selection);
|
|
20
|
+
if (compatibility.kind === "unsupported" ||
|
|
21
|
+
compatibility.kind === "unknown")
|
|
22
|
+
return failureResult("prepare", "unsupported", compatibility.reason, [], []);
|
|
23
|
+
const digest = await digestArtifactTree(input.candidateRoot);
|
|
24
|
+
const identity = {
|
|
25
|
+
schema: 1,
|
|
26
|
+
manager: "superpowers-manager",
|
|
27
|
+
harness: b.harness,
|
|
28
|
+
source: input.selection.effectiveSource,
|
|
29
|
+
commit: input.selection.desiredCommit,
|
|
30
|
+
digest,
|
|
31
|
+
};
|
|
32
|
+
const receipt = {
|
|
33
|
+
...identity,
|
|
34
|
+
binding: snapshotReceiptBinding(identity),
|
|
35
|
+
compatibility,
|
|
36
|
+
};
|
|
37
|
+
await writeFile(join(input.candidateRoot, ARTIFACT_RECEIPT), JSON.stringify(receipt) + "\n", { flag: "wx" });
|
|
38
|
+
return successResult("prepare", artifactFrom(input.candidateRoot, { receipt, compatibility }), []);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return failureResult("prepare", "invalid-package", `cannot prepare ${b.label} artifact: ${input.candidateRoot}`, [], []);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
async inspectPrepared(selection, ctx) {
|
|
45
|
+
const root = b.preparationLocation(ctx).destinationRoot;
|
|
46
|
+
const unknown = {
|
|
47
|
+
kind: "unknown",
|
|
48
|
+
reason: `${b.label} prepared compatibility evidence is missing`,
|
|
49
|
+
};
|
|
50
|
+
try {
|
|
51
|
+
if ((await classifyPathNoFollow(join(root, ARTIFACT_RECEIPT))) ===
|
|
52
|
+
"missing")
|
|
53
|
+
return successResult("inspect-prepared", {
|
|
54
|
+
kind: "needs-prepare",
|
|
55
|
+
observedIdentity: "",
|
|
56
|
+
compatibility: unknown,
|
|
57
|
+
}, []);
|
|
58
|
+
const assessment = await b.readAssessment(root);
|
|
59
|
+
const { receipt, compatibility } = assessment;
|
|
60
|
+
if (receipt.commit !== selection.desiredCommit ||
|
|
61
|
+
!sameSnapshotSource(receipt.source, selection.effectiveSource))
|
|
62
|
+
return successResult("inspect-prepared", {
|
|
63
|
+
kind: "needs-prepare",
|
|
64
|
+
observedIdentity: receipt.digest,
|
|
65
|
+
compatibility: unknown,
|
|
66
|
+
}, []);
|
|
67
|
+
if (compatibility.kind !== "supported" &&
|
|
68
|
+
compatibility.kind !== "experimental")
|
|
69
|
+
return successResult("inspect-prepared", {
|
|
70
|
+
kind: "needs-prepare",
|
|
71
|
+
observedIdentity: receipt.digest,
|
|
72
|
+
compatibility,
|
|
73
|
+
}, []);
|
|
74
|
+
return successResult("inspect-prepared", {
|
|
75
|
+
kind: "current",
|
|
76
|
+
artifact: artifactFrom(root, assessment),
|
|
77
|
+
observedIdentity: receipt.digest,
|
|
78
|
+
compatibility,
|
|
79
|
+
}, []);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return failureResult("inspect-prepared", "invalid-package", `cannot inspect ${b.label} prepared artifact: ${root}`, [], []);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
async readPrepared(ctx) {
|
|
86
|
+
const root = b.preparationLocation(ctx).destinationRoot;
|
|
87
|
+
try {
|
|
88
|
+
const assessment = await b.readAssessment(root);
|
|
89
|
+
if (assessment.compatibility.kind !== "supported" &&
|
|
90
|
+
assessment.compatibility.kind !== "experimental")
|
|
91
|
+
throw new Error("unsupported profile");
|
|
92
|
+
return successResult("read-prepared", artifactFrom(root, assessment), []);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return failureResult("read-prepared", "invalid-package", `cannot read ${b.label} prepared artifact: ${root}`, [], []);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function createSnapshotPresentation(label, renderProbe, wasAbsent) {
|
|
2
|
+
return {
|
|
3
|
+
installNotice: "",
|
|
4
|
+
currentNotice: `The Superpowers ${label} snapshot is current.`,
|
|
5
|
+
renderProbe,
|
|
6
|
+
renderInstallVerification(_desired, receipt, inspection) {
|
|
7
|
+
if (receipt.status !== 0 || !receipt.outcome.ok)
|
|
8
|
+
return {
|
|
9
|
+
stdout: [],
|
|
10
|
+
stderr: [
|
|
11
|
+
`error: ${label} activation did not return a verified installation receipt`,
|
|
12
|
+
],
|
|
13
|
+
};
|
|
14
|
+
if (inspection.status !== 0 || !inspection.outcome.ok)
|
|
15
|
+
return receipt.outcome.result.missingVerificationOutput;
|
|
16
|
+
if (inspection.outcome.result.kind === "current")
|
|
17
|
+
return {
|
|
18
|
+
stdout: [
|
|
19
|
+
`Installed the frozen Superpowers ${label} snapshot. Restart ${label} to load it.`,
|
|
20
|
+
],
|
|
21
|
+
stderr: [],
|
|
22
|
+
};
|
|
23
|
+
return inspection.outcome.result.kind === "absent"
|
|
24
|
+
? receipt.outcome.result.missingVerificationOutput
|
|
25
|
+
: receipt.outcome.result.mismatchVerificationOutput;
|
|
26
|
+
},
|
|
27
|
+
renderRemovalCompletion(_ownership, input) {
|
|
28
|
+
return {
|
|
29
|
+
stdout: [
|
|
30
|
+
wasAbsent(input)
|
|
31
|
+
? `No managed Superpowers ${label} installation is present.`
|
|
32
|
+
: `Removed the managed Superpowers ${label} installation. Restart ${label} to load the resulting state.`,
|
|
33
|
+
],
|
|
34
|
+
stderr: [],
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
callFailure(site) {
|
|
38
|
+
return {
|
|
39
|
+
unexpected: `${label} ${site} did not complete`,
|
|
40
|
+
invalidStatus: `${label} ${site} returned an invalid status`,
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
package/dist/validator.js
CHANGED
|
@@ -93,8 +93,11 @@ export function runValidator(argv, policy, env, workspace, cwd) {
|
|
|
93
93
|
// not an unhandled rejection -- which is what this try/catch prevents.
|
|
94
94
|
let child;
|
|
95
95
|
try {
|
|
96
|
+
const childEnvironment = policy.inheritEnvironment === false
|
|
97
|
+
? { ...env, TMPDIR: workspace }
|
|
98
|
+
: { ...process.env, ...env, TMPDIR: workspace };
|
|
96
99
|
child = spawn(command, args, {
|
|
97
|
-
env:
|
|
100
|
+
env: childEnvironment,
|
|
98
101
|
cwd,
|
|
99
102
|
stdio: ["ignore", "pipe", "pipe"],
|
|
100
103
|
// The child leads its own process group so a timeout can signal the GROUP --
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
3.3.0 2022-06-24
|
|
2
|
+
=================
|
|
3
|
+
- `JSONVisitor.onObjectBegin` and `JSONVisitor.onArrayBegin` can now return `false` to instruct the visitor that no children should be visited.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
3.2.0 2022-08-30
|
|
7
|
+
=================
|
|
8
|
+
- update the version of the bundled Javascript files to `es2020`.
|
|
9
|
+
- include all `const enum` values in the bundled JavaScript files (`ScanError`, `SyntaxKind`, `ParseErrorCode`).
|
|
10
|
+
|
|
11
|
+
3.1.0 2022-07-07
|
|
12
|
+
==================
|
|
13
|
+
* added new API `FormattingOptions.keepLines` : It leaves the initial line positions in the formatting.
|
|
14
|
+
|
|
15
|
+
3.0.0 2020-11-13
|
|
16
|
+
==================
|
|
17
|
+
* fixed API spec for `parseTree`. Can return `undefine` for empty input.
|
|
18
|
+
* added new API `FormattingOptions.insertFinalNewline`.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
2.3.0 2020-07-03
|
|
22
|
+
==================
|
|
23
|
+
* new API `ModificationOptions.isArrayInsertion`: If `JSONPath` refers to an index of an array and `isArrayInsertion` is `true`, then `modify` will insert a new item at that location instead of overwriting its contents.
|
|
24
|
+
* `ModificationOptions.formattingOptions` is now optional. If not set, newly inserted content will not be formatted.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
2.2.0 2019-10-25
|
|
28
|
+
==================
|
|
29
|
+
* added `ParseOptions.allowEmptyContent`. Default is `false`.
|
|
30
|
+
* new API `getNodeType`: Returns the type of a value returned by parse.
|
|
31
|
+
* `parse`: Fix issue with empty property name
|
|
32
|
+
|
|
33
|
+
2.1.0 2019-03-29
|
|
34
|
+
==================
|
|
35
|
+
* `JSONScanner` and `JSONVisitor` return lineNumber / character.
|
|
36
|
+
|
|
37
|
+
2.0.0 2018-04-12
|
|
38
|
+
==================
|
|
39
|
+
* renamed `Node.columnOffset` to `Node.colonOffset`
|
|
40
|
+
* new API `getNodePath`: Gets the JSON path of the given JSON DOM node
|
|
41
|
+
* new API `findNodeAtOffset`: Finds the most inner node at the given offset. If `includeRightBound` is set, also finds nodes that end at the given offset.
|
|
42
|
+
|
|
43
|
+
1.0.3 2018-03-07
|
|
44
|
+
==================
|
|
45
|
+
* provide ems modules
|
|
46
|
+
|
|
47
|
+
1.0.2 2018-03-05
|
|
48
|
+
==================
|
|
49
|
+
* added the `visit.onComment` API, reported when comments are allowed.
|
|
50
|
+
* added the `ParseErrorCode.InvalidCommentToken` enum value, reported when comments are disallowed.
|
|
51
|
+
|
|
52
|
+
1.0.1
|
|
53
|
+
==================
|
|
54
|
+
* added the `format` API: computes edits to format a JSON document.
|
|
55
|
+
* added the `modify` API: computes edits to insert, remove or replace a property or value in a JSON document.
|
|
56
|
+
* added the `allyEdits` API: applies edits to a document
|
|
57
|
+
|
|
58
|
+
1.0.0
|
|
59
|
+
==================
|
|
60
|
+
* remove nls dependency (remove `getParseErrorMessage`)
|
|
61
|
+
|
|
62
|
+
0.4.2 / 2017-05-05
|
|
63
|
+
==================
|
|
64
|
+
* added `ParseError.offset` & `ParseError.length`
|
|
65
|
+
|
|
66
|
+
0.4.1 / 2017-04-02
|
|
67
|
+
==================
|
|
68
|
+
* added `ParseOptions.allowTrailingComma`
|
|
69
|
+
|
|
70
|
+
0.4.0 / 2017-02-23
|
|
71
|
+
==================
|
|
72
|
+
* fix for `getLocation`. Now `getLocation` inside an object will always return a property from inside that property. Can be empty string if the object has no properties or if the offset is before a actual property `{ "a": { | }} will return location ['a', ' ']`
|
|
73
|
+
|
|
74
|
+
0.3.0 / 2017-01-17
|
|
75
|
+
==================
|
|
76
|
+
* Updating to typescript 2.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft
|
|
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.
|