psyclaw 0.25.2 → 0.26.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 +111 -60
- package/{apps → dist/apps}/panel/index.html +50 -28
- package/dist/src/adapters/pi/extension.d.ts +19 -0
- package/dist/src/adapters/pi/extension.js +735 -0
- package/dist/src/adapters/pi/extension.js.map +1 -0
- package/dist/src/adapters/pi/model.d.ts +72 -0
- package/dist/src/adapters/pi/model.js +152 -0
- package/dist/src/adapters/pi/model.js.map +1 -0
- package/dist/src/adapters/pi/resources.d.ts +23 -0
- package/dist/src/adapters/pi/resources.js +54 -0
- package/dist/src/adapters/pi/resources.js.map +1 -0
- package/dist/src/adapters/pi/rpc.d.ts +58 -0
- package/dist/src/adapters/pi/rpc.js +253 -0
- package/dist/src/adapters/pi/rpc.js.map +1 -0
- package/dist/src/adapters/pi/session.d.ts +30 -0
- package/dist/src/adapters/pi/session.js +64 -0
- package/dist/src/adapters/pi/session.js.map +1 -0
- package/dist/src/agents/catalog.d.ts +30 -0
- package/dist/src/agents/catalog.js +118 -0
- package/dist/src/agents/catalog.js.map +1 -0
- package/dist/src/agents/discover.d.ts +28 -0
- package/dist/src/agents/discover.js +127 -0
- package/dist/src/agents/discover.js.map +1 -0
- package/dist/src/agents/import.d.ts +67 -0
- package/dist/src/agents/import.js +789 -0
- package/dist/src/agents/import.js.map +1 -0
- package/dist/src/analysis/hooks.d.ts +81 -0
- package/dist/src/analysis/hooks.js +139 -0
- package/dist/src/analysis/hooks.js.map +1 -0
- package/dist/src/analysis/pre-registration.d.ts +18 -0
- package/dist/src/analysis/pre-registration.js +86 -0
- package/dist/src/analysis/pre-registration.js.map +1 -0
- package/dist/src/branding.d.ts +44 -0
- package/dist/src/branding.js +128 -0
- package/dist/src/branding.js.map +1 -0
- package/dist/src/chat.d.ts +16 -0
- package/dist/src/chat.js +95 -0
- package/dist/src/chat.js.map +1 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +316 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/core/citations.d.ts +44 -0
- package/dist/src/core/citations.js +48 -0
- package/dist/src/core/citations.js.map +1 -0
- package/dist/src/core/contracts.d.ts +119 -0
- package/dist/src/core/contracts.js +2 -0
- package/dist/src/core/contracts.js.map +1 -0
- package/dist/src/core/docx.d.ts +11 -0
- package/dist/src/core/docx.js +46 -0
- package/dist/src/core/docx.js.map +1 -0
- package/dist/src/core/doi.d.ts +41 -0
- package/dist/src/core/doi.js +82 -0
- package/dist/src/core/doi.js.map +1 -0
- package/dist/src/core/evidence-policy.d.ts +24 -0
- package/dist/src/core/evidence-policy.js +308 -0
- package/dist/src/core/evidence-policy.js.map +1 -0
- package/dist/src/core/filekind.d.ts +15 -0
- package/dist/src/core/filekind.js +82 -0
- package/dist/src/core/filekind.js.map +1 -0
- package/dist/src/core/hash.d.ts +2 -0
- package/dist/src/core/hash.js +17 -0
- package/dist/src/core/hash.js.map +1 -0
- package/dist/src/core/pricing.d.ts +38 -0
- package/dist/src/core/pricing.js +110 -0
- package/dist/src/core/pricing.js.map +1 -0
- package/dist/src/core/redact.d.ts +12 -0
- package/dist/src/core/redact.js +48 -0
- package/dist/src/core/redact.js.map +1 -0
- package/dist/src/core/references.d.ts +55 -0
- package/dist/src/core/references.js +102 -0
- package/dist/src/core/references.js.map +1 -0
- package/dist/src/core/schemas.d.ts +162 -0
- package/dist/src/core/schemas.js +160 -0
- package/dist/src/core/schemas.js.map +1 -0
- package/dist/src/extension.d.ts +1 -0
- package/dist/src/extension.js +2 -0
- package/dist/src/extension.js.map +1 -0
- package/dist/src/index.d.ts +72 -0
- package/dist/src/index.js +73 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/install/installer.d.ts +147 -0
- package/dist/src/install/installer.js +721 -0
- package/dist/src/install/installer.js.map +1 -0
- package/dist/src/integrations/contracts.d.ts +35 -0
- package/dist/src/integrations/contracts.js +27 -0
- package/dist/src/integrations/contracts.js.map +1 -0
- package/dist/src/integrations/mcp.d.ts +155 -0
- package/dist/src/integrations/mcp.js +826 -0
- package/dist/src/integrations/mcp.js.map +1 -0
- package/dist/src/knowledge-map/contracts.d.ts +20 -0
- package/dist/src/knowledge-map/contracts.js +2 -0
- package/dist/src/knowledge-map/contracts.js.map +1 -0
- package/dist/src/knowledge-map/index.d.ts +4 -0
- package/dist/src/knowledge-map/index.js +39 -0
- package/dist/src/knowledge-map/index.js.map +1 -0
- package/dist/src/literature/contracts.d.ts +106 -0
- package/dist/src/literature/contracts.js +2 -0
- package/dist/src/literature/contracts.js.map +1 -0
- package/dist/src/literature/fulltext.d.ts +7 -0
- package/dist/src/literature/fulltext.js +24 -0
- package/dist/src/literature/fulltext.js.map +1 -0
- package/dist/src/literature/knowledge-map.d.ts +2 -0
- package/dist/src/literature/knowledge-map.js +20 -0
- package/dist/src/literature/knowledge-map.js.map +1 -0
- package/dist/src/literature/ledger.d.ts +3 -0
- package/dist/src/literature/ledger.js +17 -0
- package/dist/src/literature/ledger.js.map +1 -0
- package/dist/src/literature/metadata.d.ts +6 -0
- package/dist/src/literature/metadata.js +32 -0
- package/dist/src/literature/metadata.js.map +1 -0
- package/dist/src/memory/store.d.ts +22 -0
- package/dist/src/memory/store.js +73 -0
- package/dist/src/memory/store.js.map +1 -0
- package/dist/src/orchestration/contracts.d.ts +61 -0
- package/dist/src/orchestration/contracts.js +2 -0
- package/dist/src/orchestration/contracts.js.map +1 -0
- package/dist/src/orchestration/pi-executor.d.ts +28 -0
- package/dist/src/orchestration/pi-executor.js +169 -0
- package/dist/src/orchestration/pi-executor.js.map +1 -0
- package/dist/src/orchestration/runner.d.ts +196 -0
- package/dist/src/orchestration/runner.js +991 -0
- package/dist/src/orchestration/runner.js.map +1 -0
- package/dist/src/orchestration/scheduler.d.ts +8 -0
- package/dist/src/orchestration/scheduler.js +335 -0
- package/dist/src/orchestration/scheduler.js.map +1 -0
- package/dist/src/panel/events.d.ts +20 -0
- package/dist/src/panel/events.js +93 -0
- package/dist/src/panel/events.js.map +1 -0
- package/dist/src/panel/extension.d.ts +8 -0
- package/dist/src/panel/extension.js +115 -0
- package/dist/src/panel/extension.js.map +1 -0
- package/dist/src/panel/literature-map.d.ts +26 -0
- package/dist/src/panel/literature-map.js +34 -0
- package/dist/src/panel/literature-map.js.map +1 -0
- package/dist/src/panel/projection.d.ts +51 -0
- package/dist/src/panel/projection.js +288 -0
- package/dist/src/panel/projection.js.map +1 -0
- package/dist/src/panel/server.d.ts +46 -0
- package/dist/src/panel/server.js +1610 -0
- package/dist/src/panel/server.js.map +1 -0
- package/dist/src/panel/usage.d.ts +53 -0
- package/dist/src/panel/usage.js +150 -0
- package/dist/src/panel/usage.js.map +1 -0
- package/dist/src/project/bootstrap.d.ts +10 -0
- package/dist/src/project/bootstrap.js +83 -0
- package/dist/src/project/bootstrap.js.map +1 -0
- package/dist/src/project/hitl.d.ts +12 -0
- package/dist/src/project/hitl.js +43 -0
- package/dist/src/project/hitl.js.map +1 -0
- package/dist/src/project/jsonl.d.ts +16 -0
- package/dist/src/project/jsonl.js +93 -0
- package/dist/src/project/jsonl.js.map +1 -0
- package/dist/src/project/manuscript.d.ts +21 -0
- package/dist/src/project/manuscript.js +74 -0
- package/dist/src/project/manuscript.js.map +1 -0
- package/dist/src/project/paths.d.ts +38 -0
- package/dist/src/project/paths.js +166 -0
- package/dist/src/project/paths.js.map +1 -0
- package/dist/src/project/versions.d.ts +10 -0
- package/dist/src/project/versions.js +14 -0
- package/dist/src/project/versions.js.map +1 -0
- package/dist/src/psyclaw-theme.d.ts +88 -0
- package/dist/src/psyclaw-theme.js +89 -0
- package/dist/src/psyclaw-theme.js.map +1 -0
- package/dist/src/research/brief.d.ts +11 -0
- package/dist/src/research/brief.js +81 -0
- package/dist/src/research/brief.js.map +1 -0
- package/dist/src/research/ledger.d.ts +12 -0
- package/dist/src/research/ledger.js +43 -0
- package/dist/src/research/ledger.js.map +1 -0
- package/dist/src/run.d.ts +20 -0
- package/dist/src/run.js +34 -0
- package/dist/src/run.js.map +1 -0
- package/dist/src/setup.d.ts +54 -0
- package/dist/src/setup.js +221 -0
- package/dist/src/setup.js.map +1 -0
- package/dist/src/skills/contracts.d.ts +105 -0
- package/dist/src/skills/contracts.js +3 -0
- package/dist/src/skills/contracts.js.map +1 -0
- package/dist/src/skills/preflight.d.ts +10 -0
- package/dist/src/skills/preflight.js +39 -0
- package/dist/src/skills/preflight.js.map +1 -0
- package/dist/src/skills/registry.d.ts +28 -0
- package/dist/src/skills/registry.js +540 -0
- package/dist/src/skills/registry.js.map +1 -0
- package/dist/src/style/artifact.d.ts +6 -0
- package/dist/src/style/artifact.js +61 -0
- package/dist/src/style/artifact.js.map +1 -0
- package/dist/src/style/cli-ui.d.ts +41 -0
- package/dist/src/style/cli-ui.js +119 -0
- package/dist/src/style/cli-ui.js.map +1 -0
- package/dist/src/style/contracts.d.ts +34 -0
- package/dist/src/style/contracts.js +2 -0
- package/dist/src/style/contracts.js.map +1 -0
- package/dist/src/style/registry.d.ts +16 -0
- package/dist/src/style/registry.js +50 -0
- package/dist/src/style/registry.js.map +1 -0
- package/dist/src/trust/manifest.d.ts +42 -0
- package/dist/src/trust/manifest.js +53 -0
- package/dist/src/trust/manifest.js.map +1 -0
- package/dist/src/trust/sbom.d.ts +54 -0
- package/dist/src/trust/sbom.js +77 -0
- package/dist/src/trust/sbom.js.map +1 -0
- package/dist/src/tui/app.d.ts +3 -0
- package/dist/src/tui/app.js +103 -0
- package/dist/src/tui/app.js.map +1 -0
- package/dist/src/tui/model.d.ts +13 -0
- package/dist/src/tui/model.js +25 -0
- package/dist/src/tui/model.js.map +1 -0
- package/dist/src/updates/check.d.ts +43 -0
- package/dist/src/updates/check.js +68 -0
- package/dist/src/updates/check.js.map +1 -0
- package/dist/src/updates/manifest.d.ts +19 -0
- package/dist/src/updates/manifest.js +58 -0
- package/dist/src/updates/manifest.js.map +1 -0
- package/dist/src/updates/registry.d.ts +21 -0
- package/dist/src/updates/registry.js +82 -0
- package/dist/src/updates/registry.js.map +1 -0
- package/dist/src/updates/skills.d.ts +15 -0
- package/dist/src/updates/skills.js +39 -0
- package/dist/src/updates/skills.js.map +1 -0
- package/dist/src/updates/status.d.ts +7 -0
- package/dist/src/updates/status.js +37 -0
- package/dist/src/updates/status.js.map +1 -0
- package/dist/src/updates/update.d.ts +43 -0
- package/dist/src/updates/update.js +128 -0
- package/dist/src/updates/update.js.map +1 -0
- package/dist/src/wizard.d.ts +7 -0
- package/dist/src/wizard.js +90 -0
- package/dist/src/wizard.js.map +1 -0
- package/dist/src/workflows/analysis-delegation.d.ts +3 -0
- package/dist/src/workflows/analysis-delegation.js +96 -0
- package/dist/src/workflows/analysis-delegation.js.map +1 -0
- package/dist/src/workflows/expert-review-runner.d.ts +29 -0
- package/dist/src/workflows/expert-review-runner.js +35 -0
- package/dist/src/workflows/expert-review-runner.js.map +1 -0
- package/dist/src/workflows/expert-review.d.ts +140 -0
- package/dist/src/workflows/expert-review.js +111 -0
- package/dist/src/workflows/expert-review.js.map +1 -0
- package/dist/src/workflows/institutional-fulltext.d.ts +16 -0
- package/dist/src/workflows/institutional-fulltext.js +110 -0
- package/dist/src/workflows/institutional-fulltext.js.map +1 -0
- package/dist/src/workflows/literature-review.d.ts +3 -0
- package/dist/src/workflows/literature-review.js +76 -0
- package/dist/src/workflows/literature-review.js.map +1 -0
- package/dist/src/workflows/meta-analysis.d.ts +38 -0
- package/dist/src/workflows/meta-analysis.js +185 -0
- package/dist/src/workflows/meta-analysis.js.map +1 -0
- package/dist/src/workflows/publish.d.ts +51 -0
- package/dist/src/workflows/publish.js +153 -0
- package/dist/src/workflows/publish.js.map +1 -0
- package/dist/src/workflows/spec.d.ts +51 -0
- package/dist/src/workflows/spec.js +157 -0
- package/dist/src/workflows/spec.js.map +1 -0
- package/dist/src/workflows/style-contract.d.ts +24 -0
- package/dist/src/workflows/style-contract.js +23 -0
- package/dist/src/workflows/style-contract.js.map +1 -0
- package/dist/src/workflows/writing-review.d.ts +15 -0
- package/dist/src/workflows/writing-review.js +82 -0
- package/dist/src/workflows/writing-review.js.map +1 -0
- package/package.json +20 -8
- package/scripts/rebrand-pi.mjs +3 -3
- package/scripts/__pycache__/build_dist.cpython-314.pyc +0 -0
- package/scripts/__pycache__/build_whitepaper_docx.cpython-314.pyc +0 -0
- package/scripts/build_preprint_docx.py +0 -729
- package/scripts/build_preprint_figures.py +0 -238
- package/scripts/build_three_line_table_fixture.py +0 -56
- package/scripts/build_whitepaper_docx.py +0 -768
- package/scripts/check-branding.mjs +0 -159
- package/scripts/copy-panel.mjs +0 -11
- package/scripts/verify_docx.py +0 -41
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ArtifactIdentity, ReproducibilityCheck, StyleCheckResult } from "./contracts.js";
|
|
2
|
+
export declare function artifactFilename(identity: ArtifactIdentity): string;
|
|
3
|
+
export declare function parseArtifactFilename(path: string): ArtifactIdentity | undefined;
|
|
4
|
+
export declare function verifyReproducibility(check: ReproducibilityCheck): Promise<StyleCheckResult>;
|
|
5
|
+
export declare function checkDefaultStyle(identity: ArtifactIdentity, profileId?: string): StyleCheckResult;
|
|
6
|
+
export declare function artifactExtension(path: string): string;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { basename, extname } from "node:path";
|
|
2
|
+
import { sha256File } from "../core/hash.js";
|
|
3
|
+
import { STYLE_CONTRACT_VERSION } from "./contracts.js";
|
|
4
|
+
const SHA = /^[a-f0-9]{64}$/i;
|
|
5
|
+
const SLUG = /^[a-z0-9][a-z0-9-]*$/;
|
|
6
|
+
export function artifactFilename(identity) {
|
|
7
|
+
if (!SLUG.test(identity.slug))
|
|
8
|
+
throw new Error("artifact slug must use lowercase letters, numbers, and hyphens");
|
|
9
|
+
if (!/^v[1-9][0-9]*$/.test(identity.version))
|
|
10
|
+
throw new Error("artifact version must be like v1");
|
|
11
|
+
const extension = identity.extension.replace(/^\./, "").toLowerCase();
|
|
12
|
+
if (!/^[a-z0-9]+$/.test(extension))
|
|
13
|
+
throw new Error("artifact extension is invalid");
|
|
14
|
+
return `${identity.kind}-${identity.slug}-${identity.version}.${extension}`;
|
|
15
|
+
}
|
|
16
|
+
export function parseArtifactFilename(path) {
|
|
17
|
+
const match = /^(figure|table|manuscript)-([a-z0-9][a-z0-9-]*)-(v[1-9][0-9]*)\.([a-z0-9]+)$/i.exec(basename(path));
|
|
18
|
+
return match ? { kind: match[1].toLowerCase(), slug: match[2].toLowerCase(), version: match[3].toLowerCase(), extension: match[4].toLowerCase() } : undefined;
|
|
19
|
+
}
|
|
20
|
+
export async function verifyReproducibility(check) {
|
|
21
|
+
const findings = [];
|
|
22
|
+
if (!check.scriptPath?.trim() || !check.scriptSha256 || !SHA.test(check.scriptSha256))
|
|
23
|
+
findings.push({ rule: "script-hash-required", severity: "block", message: "script path and SHA-256 are required" });
|
|
24
|
+
if (check.scriptPath && check.scriptSha256 && SHA.test(check.scriptSha256)) {
|
|
25
|
+
try {
|
|
26
|
+
if ((await sha256File(check.scriptPath)).toLowerCase() !== check.scriptSha256.toLowerCase())
|
|
27
|
+
findings.push({ rule: "script-hash-mismatch", severity: "block", message: "script hash does not match the file" });
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
findings.push({ rule: "script-unavailable", severity: "block", message: "reproducibility script is unavailable" });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
for (const [path, hash] of Object.entries(check.inputHashes ?? {})) {
|
|
34
|
+
if (!SHA.test(hash)) {
|
|
35
|
+
findings.push({ rule: "input-hash-invalid", severity: "block", message: `invalid input hash: ${path}` });
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
if ((await sha256File(path)).toLowerCase() !== hash.toLowerCase())
|
|
40
|
+
findings.push({ rule: "input-hash-mismatch", severity: "block", message: `input hash does not match: ${path}` });
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
findings.push({ rule: "input-unavailable", severity: "block", message: `input is unavailable: ${path}` });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return { schemaVersion: STYLE_CONTRACT_VERSION, ok: !findings.some((f) => f.severity === "block"), findings };
|
|
47
|
+
}
|
|
48
|
+
export function checkDefaultStyle(identity, profileId = "generic") {
|
|
49
|
+
const findings = [];
|
|
50
|
+
try {
|
|
51
|
+
artifactFilename(identity);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
findings.push({ rule: "artifact-name-invalid", severity: "block", message: String(error instanceof Error ? error.message : error) });
|
|
55
|
+
}
|
|
56
|
+
if (!profileId.trim())
|
|
57
|
+
findings.push({ rule: "profile-required", severity: "block", message: "style profile id is required" });
|
|
58
|
+
return { schemaVersion: STYLE_CONTRACT_VERSION, ok: !findings.some((f) => f.severity === "block"), findings };
|
|
59
|
+
}
|
|
60
|
+
export function artifactExtension(path) { return extname(path).replace(/^\./, "").toLowerCase(); }
|
|
61
|
+
//# sourceMappingURL=artifact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.js","sourceRoot":"","sources":["../../../src/style/artifact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,MAAM,GAAG,GAAG,iBAAiB,CAAC;AAC9B,MAAM,IAAI,GAAG,sBAAsB,CAAC;AAEpC,MAAM,UAAU,gBAAgB,CAAC,QAA0B;IACzD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACjH,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAClG,MAAM,SAAS,GAA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**
|
|
2
|
+
* High-end, lightweight CLI UI styling and ANSI utilities for psyclaw.
|
|
3
|
+
* Zero external runtime dependencies, fast and cross-platform.
|
|
4
|
+
*/
|
|
5
|
+
export declare const c: {
|
|
6
|
+
reset: string;
|
|
7
|
+
bold: (t: string) => string;
|
|
8
|
+
dim: (t: string) => string;
|
|
9
|
+
italic: (t: string) => string;
|
|
10
|
+
underline: (t: string) => string;
|
|
11
|
+
teal: (t: string) => string;
|
|
12
|
+
cyan: (t: string) => string;
|
|
13
|
+
blue: (t: string) => string;
|
|
14
|
+
green: (t: string) => string;
|
|
15
|
+
yellow: (t: string) => string;
|
|
16
|
+
red: (t: string) => string;
|
|
17
|
+
gray: (t: string) => string;
|
|
18
|
+
darkGray: (t: string) => string;
|
|
19
|
+
white: (t: string) => string;
|
|
20
|
+
bgTeal: (t: string) => string;
|
|
21
|
+
badge: (label: string, tone?: "teal" | "green" | "yellow" | "blue") => string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Render the branded psyclaw CLI header banner.
|
|
25
|
+
*/
|
|
26
|
+
export declare function renderCliBanner(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Render structured, color-coded CLI usage documentation.
|
|
29
|
+
*/
|
|
30
|
+
export declare function formatCliUsage(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Render a styled info card box.
|
|
33
|
+
*/
|
|
34
|
+
export declare function renderCard(title: string, fields: Array<{
|
|
35
|
+
label: string;
|
|
36
|
+
value: string;
|
|
37
|
+
}>): string;
|
|
38
|
+
/**
|
|
39
|
+
* Render a styled success card for command results.
|
|
40
|
+
*/
|
|
41
|
+
export declare function renderSuccessCard(title: string, details?: Record<string, string>): string;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-end, lightweight CLI UI styling and ANSI utilities for psyclaw.
|
|
3
|
+
* Zero external runtime dependencies, fast and cross-platform.
|
|
4
|
+
*/
|
|
5
|
+
import { PSYCLAW_VERSION } from "../branding.js";
|
|
6
|
+
const isColorSupported = !process.env.NO_COLOR && (process.stdout.isTTY || process.env.FORCE_COLOR === "1");
|
|
7
|
+
function wrap(code, text) {
|
|
8
|
+
return isColorSupported ? `${code}${text}\x1b[0m` : text;
|
|
9
|
+
}
|
|
10
|
+
export const c = {
|
|
11
|
+
reset: isColorSupported ? "\x1b[0m" : "",
|
|
12
|
+
bold: (t) => wrap("\x1b[1m", t),
|
|
13
|
+
dim: (t) => wrap("\x1b[2m", t),
|
|
14
|
+
italic: (t) => wrap("\x1b[3m", t),
|
|
15
|
+
underline: (t) => wrap("\x1b[4m", t),
|
|
16
|
+
// 24-bit Truecolor & ANSI colors
|
|
17
|
+
teal: (t) => wrap("\x1b[38;2;46;196;182m", t),
|
|
18
|
+
cyan: (t) => wrap("\x1b[38;2;56;189;248m", t),
|
|
19
|
+
blue: (t) => wrap("\x1b[38;2;99;102;241m", t),
|
|
20
|
+
green: (t) => wrap("\x1b[38;2;34;197;94m", t),
|
|
21
|
+
yellow: (t) => wrap("\x1b[38;2;245;158;11m", t),
|
|
22
|
+
red: (t) => wrap("\x1b[38;2;244;63;94m", t),
|
|
23
|
+
gray: (t) => wrap("\x1b[38;2;142;155;178m", t),
|
|
24
|
+
darkGray: (t) => wrap("\x1b[38;2;86;99;122m", t),
|
|
25
|
+
white: (t) => wrap("\x1b[38;2;240;244;252m", t),
|
|
26
|
+
bgTeal: (t) => wrap("\x1b[48;2;46;196;182;30m", t),
|
|
27
|
+
badge: (label, tone = "teal") => {
|
|
28
|
+
const tones = {
|
|
29
|
+
teal: "\x1b[38;2;5;20;27;48;2;46;196;182m",
|
|
30
|
+
green: "\x1b[38;2;5;20;10;48;2;34;197;94m",
|
|
31
|
+
yellow: "\x1b[38;2;30;20;5;48;2;245;158;11m",
|
|
32
|
+
blue: "\x1b[38;2;10;15;35;48;2;99;102;241m",
|
|
33
|
+
};
|
|
34
|
+
return isColorSupported ? `${tones[tone]} ${label} \x1b[0m` : `[${label}]`;
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Render the branded psyclaw CLI header banner.
|
|
39
|
+
*/
|
|
40
|
+
export function renderCliBanner() {
|
|
41
|
+
const line = c.darkGray("─".repeat(58));
|
|
42
|
+
return [
|
|
43
|
+
"",
|
|
44
|
+
` ${c.teal(c.bold("ψ PsyClaw"))} ${c.badge(`v${PSYCLAW_VERSION}`, "teal")} ${c.gray("· 社会科学科研智能体工作台")}`,
|
|
45
|
+
` ${c.darkGray("Evidence-Grounded Social Science Research Agent")}`,
|
|
46
|
+
` ${line}`,
|
|
47
|
+
].join("\n");
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Render structured, color-coded CLI usage documentation.
|
|
51
|
+
*/
|
|
52
|
+
export function formatCliUsage() {
|
|
53
|
+
const banner = renderCliBanner();
|
|
54
|
+
const sep = c.darkGray("│");
|
|
55
|
+
const cmd = (name, args, desc) => ` ${c.teal(name.padEnd(14))} ${c.gray(args.padEnd(30))} ${desc}`;
|
|
56
|
+
return [
|
|
57
|
+
banner,
|
|
58
|
+
"",
|
|
59
|
+
` ${c.bold(c.white("使用方式 (Usage):"))}`,
|
|
60
|
+
` ${c.cyan("$")} psyclaw ${c.gray("<command> [options...]")}`,
|
|
61
|
+
"",
|
|
62
|
+
` ${c.bold(c.cyan("🚀 核心交互 (Interactive & Chat)"))}`,
|
|
63
|
+
cmd("psyclaw [chat]", "[pi args...]", c.white("启动交互研究智能体 (默认入口)")),
|
|
64
|
+
cmd("psyclaw wizard", "", c.white("首次使用提供商配置向导")),
|
|
65
|
+
cmd("psyclaw setup", "[--provider deepseek|...]", c.white("配置模型提供商与 API Key")),
|
|
66
|
+
"",
|
|
67
|
+
` ${c.bold(c.cyan("🎯 课题生命周期 (Project Lifecycle)"))}`,
|
|
68
|
+
cmd("psyclaw init", "<goal> [--paradigm <id>]", c.white("创建社科研究课题项目")),
|
|
69
|
+
cmd("psyclaw hitl init", "", c.white("初始化人工裁决 (HITL) 检查点模板")),
|
|
70
|
+
cmd("psyclaw handoff", "", c.white("生成 HANDOFF 研究移交备忘录")),
|
|
71
|
+
"",
|
|
72
|
+
` ${c.bold(c.cyan("🔬 科研工作流 (Research Workflows)"))}`,
|
|
73
|
+
cmd("psyclaw brief", "", c.white("生成离线证据简报 (Offline Brief)")),
|
|
74
|
+
"",
|
|
75
|
+
` ${c.bold(c.cyan("📁 证据与沙盒 (Evidence & Ledger)"))}`,
|
|
76
|
+
cmd("psyclaw evidence add", "<path> [--level fulltext|...]", c.white("登记只读文献与证据文件指纹")),
|
|
77
|
+
"",
|
|
78
|
+
` ${c.bold(c.cyan("📊 看板与 TUI (Observability & UI)"))}`,
|
|
79
|
+
cmd("psyclaw shell", "", c.white("启动终端 TUI 智能体管理界面")),
|
|
80
|
+
cmd("/panel (对话内)", "", c.white("在 psyclaw 对话中输入 /panel 打开科研工作台")),
|
|
81
|
+
"",
|
|
82
|
+
` ${c.bold(c.cyan("🧩 生态与更新 (Ecosystem & Updates)"))}`,
|
|
83
|
+
cmd("psyclaw agents", "", c.white("扫描已安装的外部领域智能体")),
|
|
84
|
+
cmd("psyclaw install", "<agent-id> [--yes]", c.white("安装受信任扩展与技能")),
|
|
85
|
+
cmd("psyclaw import", "<agent-id> [--yes]", c.white("导入外部智能体技能")),
|
|
86
|
+
cmd("psyclaw check-updates", "", c.white("检查运行时与生态更新报告")),
|
|
87
|
+
cmd("psyclaw update", "[--yes] [--force]", c.white("升级底层 Pi 运行时")),
|
|
88
|
+
"",
|
|
89
|
+
` ${c.darkGray("──────────────────────────────────────────────────────────")}`,
|
|
90
|
+
` ${c.gray("文档与源码:")} ${c.cyan(c.underline("https://github.com/Exekiel179/psyclaw"))}`,
|
|
91
|
+
"",
|
|
92
|
+
].join("\n");
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Render a styled info card box.
|
|
96
|
+
*/
|
|
97
|
+
export function renderCard(title, fields) {
|
|
98
|
+
const width = 56;
|
|
99
|
+
const top = c.teal(`┌─ ${c.bold(title)} `.padEnd(width + 10, "─") + "┐");
|
|
100
|
+
const bottom = c.teal("└" + "─".repeat(width - 2) + "┘");
|
|
101
|
+
const rows = fields.map((f) => {
|
|
102
|
+
const line = ` ${c.gray(f.label.padEnd(12))} ${c.white(f.value)}`;
|
|
103
|
+
return c.teal("│") + line.padEnd(width - 2) + c.teal("│");
|
|
104
|
+
});
|
|
105
|
+
return ["", top, ...rows, bottom, ""].join("\n");
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Render a styled success card for command results.
|
|
109
|
+
*/
|
|
110
|
+
export function renderSuccessCard(title, details) {
|
|
111
|
+
const lines = [` ${c.green("✔")} ${c.bold(title)}`];
|
|
112
|
+
if (details) {
|
|
113
|
+
for (const [k, v] of Object.entries(details)) {
|
|
114
|
+
lines.push(` ${c.darkGray("•")} ${c.gray(k + ":")} ${c.white(v)}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return lines.join("\n") + "\n";
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=cli-ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-ui.js","sourceRoot":"","sources":["../../../src/style/cli-ui.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,gBAAgB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,GAAG,CAAC,CAAC;AAE5G,SAAS,IAAI,CAAC,IAAY,EAAE,IAAY;IACtC,OAAO,gBAAgB,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3D,CAAC;AAED,MAAM,CAAC,MAAM,CAAC,GAAG;IACf,KAAK,EAAE,gBAAgB,CAAC,C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O,CAAC,EAAE,CAAC;YAC7C,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const STYLE_CONTRACT_VERSION: "psyclaw/style-contract/v1";
|
|
2
|
+
export type ArtifactKind = "figure" | "table" | "manuscript";
|
|
3
|
+
export interface JournalProfile {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
source: string;
|
|
7
|
+
ref: string;
|
|
8
|
+
version: string;
|
|
9
|
+
license: string;
|
|
10
|
+
/** Profiles are descriptive until their rules have been independently verified. */
|
|
11
|
+
status?: "verified" | "unverified" | "degraded";
|
|
12
|
+
rules?: Readonly<Record<string, unknown>>;
|
|
13
|
+
}
|
|
14
|
+
export interface StyleCheckFinding {
|
|
15
|
+
rule: string;
|
|
16
|
+
severity: "block" | "warn";
|
|
17
|
+
message: string;
|
|
18
|
+
}
|
|
19
|
+
export interface StyleCheckResult {
|
|
20
|
+
schemaVersion: typeof STYLE_CONTRACT_VERSION;
|
|
21
|
+
ok: boolean;
|
|
22
|
+
findings: StyleCheckFinding[];
|
|
23
|
+
}
|
|
24
|
+
export interface ArtifactIdentity {
|
|
25
|
+
kind: ArtifactKind;
|
|
26
|
+
slug: string;
|
|
27
|
+
version: string;
|
|
28
|
+
extension: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ReproducibilityCheck {
|
|
31
|
+
scriptPath?: string;
|
|
32
|
+
scriptSha256?: string;
|
|
33
|
+
inputHashes?: Readonly<Record<string, string>>;
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/style/contracts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,2BAAoC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JournalProfile } from "./contracts.js";
|
|
2
|
+
declare const SHA: RegExp;
|
|
3
|
+
/** Descriptor-first registry. Registration never implies that a journal rule is trusted. */
|
|
4
|
+
export declare class JournalProfileRegistry {
|
|
5
|
+
private readonly profiles;
|
|
6
|
+
private defaultId;
|
|
7
|
+
constructor(profiles?: readonly JournalProfile[], defaultId?: string);
|
|
8
|
+
register(profile: JournalProfile): JournalProfile;
|
|
9
|
+
get(id: string): JournalProfile | undefined;
|
|
10
|
+
list(): readonly JournalProfile[];
|
|
11
|
+
default(): JournalProfile;
|
|
12
|
+
setDefault(id: string): void;
|
|
13
|
+
}
|
|
14
|
+
export declare const DEFAULT_JOURNAL_PROFILE: JournalProfile;
|
|
15
|
+
export declare function createDefaultJournalProfileRegistry(): JournalProfileRegistry;
|
|
16
|
+
export { SHA };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const ID = /^[a-z0-9][a-z0-9._-]{0,63}$/;
|
|
2
|
+
const SHA = /^[a-f0-9]{64}$/i;
|
|
3
|
+
function validate(profile) {
|
|
4
|
+
if (!ID.test(profile.id))
|
|
5
|
+
throw new Error("journal profile id must be a stable identifier");
|
|
6
|
+
for (const field of ["name", "source", "ref", "version", "license"]) {
|
|
7
|
+
if (!profile[field]?.trim())
|
|
8
|
+
throw new Error(`journal profile ${field} is required`);
|
|
9
|
+
}
|
|
10
|
+
if (profile.status === "verified" && profile.source.trim() === "")
|
|
11
|
+
throw new Error("verified profile requires a source");
|
|
12
|
+
return Object.freeze({ ...profile, status: profile.status ?? "unverified", rules: profile.rules ?? {} });
|
|
13
|
+
}
|
|
14
|
+
/** Descriptor-first registry. Registration never implies that a journal rule is trusted. */
|
|
15
|
+
export class JournalProfileRegistry {
|
|
16
|
+
profiles = new Map();
|
|
17
|
+
defaultId;
|
|
18
|
+
constructor(profiles = [], defaultId) {
|
|
19
|
+
for (const profile of profiles)
|
|
20
|
+
this.register(profile);
|
|
21
|
+
this.defaultId = defaultId ?? profiles[0]?.id ?? "generic";
|
|
22
|
+
if (!this.profiles.has(this.defaultId)) {
|
|
23
|
+
this.register({ id: "generic", name: "Generic manuscript", source: "psyclaw", ref: "builtin", version: "v1", license: "MIT", status: "verified" });
|
|
24
|
+
this.defaultId = "generic";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
register(profile) {
|
|
28
|
+
const normalized = validate(profile);
|
|
29
|
+
if (this.profiles.has(normalized.id))
|
|
30
|
+
throw new Error(`journal profile already registered: ${normalized.id}`);
|
|
31
|
+
this.profiles.set(normalized.id, normalized);
|
|
32
|
+
return normalized;
|
|
33
|
+
}
|
|
34
|
+
get(id) { return this.profiles.get(id); }
|
|
35
|
+
list() { return [...this.profiles.values()]; }
|
|
36
|
+
default() { return this.profiles.get(this.defaultId); }
|
|
37
|
+
setDefault(id) {
|
|
38
|
+
if (!this.profiles.has(id))
|
|
39
|
+
throw new Error(`journal profile not found: ${id}`);
|
|
40
|
+
this.defaultId = id;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export const DEFAULT_JOURNAL_PROFILE = Object.freeze({
|
|
44
|
+
id: "generic", name: "Generic manuscript", source: "psyclaw", ref: "builtin", version: "v1", license: "MIT", status: "verified", rules: {},
|
|
45
|
+
});
|
|
46
|
+
export function createDefaultJournalProfileRegistry() {
|
|
47
|
+
return new JournalProfileRegistry([DEFAULT_JOURNAL_PROFILE], "generic");
|
|
48
|
+
}
|
|
49
|
+
export { SHA };
|
|
50
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/style/registry.ts"],"names":[],"mappings":"AAEA,MAAM,EAAE,GAAG,6BAA6B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,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE;CAC3I,CAAC,CAAC;AAEH,MAAM,UAAU,mCAAmC;IACjD,OAAO,IAAI,sBAAsB,CAAC,CAAC,uBAAuB,CAAC,EAAE,SAAS,CAAC,CAAC;AAC1E,CAAC;AAED,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Type, type Static } from "typebox";
|
|
2
|
+
/**
|
|
3
|
+
* Versioned admission manifest. Unknown fields are rejected, and every field
|
|
4
|
+
* that matters for supply-chain trust (source ref, content hash, SPDX license,
|
|
5
|
+
* dependency pins, SBOM reference) is required or explicitly validated.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ManifestSchema: Type.TObject<{
|
|
8
|
+
schemaVersion: Type.TLiteral<"psyclaw/manifest/v1">;
|
|
9
|
+
id: Type.TString;
|
|
10
|
+
version: Type.TString;
|
|
11
|
+
source: Type.TObject<{
|
|
12
|
+
kind: Type.TUnion<[Type.TLiteral<"git">, Type.TLiteral<"workspace">, Type.TLiteral<"file">]>;
|
|
13
|
+
ref: Type.TString;
|
|
14
|
+
url: Type.TOptional<Type.TString>;
|
|
15
|
+
}>;
|
|
16
|
+
contentSha256: Type.TString;
|
|
17
|
+
license: Type.TObject<{
|
|
18
|
+
spdx: Type.TString;
|
|
19
|
+
evidenceRef: Type.TOptional<Type.TString>;
|
|
20
|
+
}>;
|
|
21
|
+
dependencies: Type.TArray<Type.TObject<{
|
|
22
|
+
name: Type.TString;
|
|
23
|
+
version: Type.TString;
|
|
24
|
+
license: Type.TOptional<Type.TString>;
|
|
25
|
+
sha256: Type.TOptional<Type.TString>;
|
|
26
|
+
}>>;
|
|
27
|
+
sbom: Type.TOptional<Type.TObject<{
|
|
28
|
+
format: Type.TLiteral<"CycloneDX">;
|
|
29
|
+
specVersion: Type.TLiteral<"1.5">;
|
|
30
|
+
path: Type.TString;
|
|
31
|
+
sha256: Type.TString;
|
|
32
|
+
}>>;
|
|
33
|
+
capabilities: Type.TArray<Type.TString>;
|
|
34
|
+
trust: Type.TUnion<[Type.TLiteral<"discover-only">, Type.TLiteral<"approved">, Type.TLiteral<"blocked">]>;
|
|
35
|
+
contract: Type.TOptional<Type.TObject<{
|
|
36
|
+
inputSchema: Type.TOptional<Type.TString>;
|
|
37
|
+
outputSchema: Type.TOptional<Type.TString>;
|
|
38
|
+
fixtures: Type.TArray<Type.TString>;
|
|
39
|
+
}>>;
|
|
40
|
+
}>;
|
|
41
|
+
export type ManifestShape = Static<typeof ManifestSchema>;
|
|
42
|
+
export declare function asManifest(value: unknown): ManifestShape;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { Compile } from "typebox/compile";
|
|
3
|
+
/**
|
|
4
|
+
* Versioned admission manifest. Unknown fields are rejected, and every field
|
|
5
|
+
* that matters for supply-chain trust (source ref, content hash, SPDX license,
|
|
6
|
+
* dependency pins, SBOM reference) is required or explicitly validated.
|
|
7
|
+
*/
|
|
8
|
+
export const ManifestSchema = Type.Object({
|
|
9
|
+
schemaVersion: Type.Literal("psyclaw/manifest/v1"),
|
|
10
|
+
id: Type.String({ minLength: 1 }),
|
|
11
|
+
version: Type.String({ minLength: 1 }),
|
|
12
|
+
source: Type.Object({
|
|
13
|
+
kind: Type.Union([Type.Literal("git"), Type.Literal("workspace"), Type.Literal("file")]),
|
|
14
|
+
ref: Type.String({ minLength: 1 }),
|
|
15
|
+
url: Type.Optional(Type.String({ minLength: 1 })),
|
|
16
|
+
}, { additionalProperties: false }),
|
|
17
|
+
contentSha256: Type.String({ pattern: "^[a-f0-9]{64}$" }),
|
|
18
|
+
license: Type.Object({
|
|
19
|
+
spdx: Type.String({ minLength: 1 }),
|
|
20
|
+
evidenceRef: Type.Optional(Type.String({ minLength: 1 })),
|
|
21
|
+
}, { additionalProperties: false }),
|
|
22
|
+
dependencies: Type.Array(Type.Object({
|
|
23
|
+
name: Type.String({ minLength: 1 }),
|
|
24
|
+
version: Type.String({ minLength: 1 }),
|
|
25
|
+
license: Type.Optional(Type.String({ minLength: 1 })),
|
|
26
|
+
sha256: Type.Optional(Type.String({ pattern: "^[a-f0-9]{64}$" })),
|
|
27
|
+
}, { additionalProperties: false })),
|
|
28
|
+
sbom: Type.Optional(Type.Object({
|
|
29
|
+
format: Type.Literal("CycloneDX"),
|
|
30
|
+
specVersion: Type.Literal("1.5"),
|
|
31
|
+
path: Type.String({ minLength: 1 }),
|
|
32
|
+
sha256: Type.String({ pattern: "^[a-f0-9]{64}$" }),
|
|
33
|
+
}, { additionalProperties: false })),
|
|
34
|
+
capabilities: Type.Array(Type.String({ minLength: 1 })),
|
|
35
|
+
trust: Type.Union([Type.Literal("discover-only"), Type.Literal("approved"), Type.Literal("blocked")]),
|
|
36
|
+
contract: Type.Optional(Type.Object({
|
|
37
|
+
inputSchema: Type.Optional(Type.String({ minLength: 1 })),
|
|
38
|
+
outputSchema: Type.Optional(Type.String({ minLength: 1 })),
|
|
39
|
+
fixtures: Type.Array(Type.String({ minLength: 1 })),
|
|
40
|
+
}, { additionalProperties: false })),
|
|
41
|
+
}, { additionalProperties: false });
|
|
42
|
+
const compiled = Compile(ManifestSchema);
|
|
43
|
+
export function asManifest(value) {
|
|
44
|
+
if (!compiled.Check(value)) {
|
|
45
|
+
const errors = [...compiled.Errors(value)].map((error) => {
|
|
46
|
+
const path = "path" in error && typeof error.path === "string" ? error.path : "/";
|
|
47
|
+
return `${path}: ${error.message}`;
|
|
48
|
+
});
|
|
49
|
+
throw new Error(`manifest schema invalid: ${errors.join("; ")}`);
|
|
50
|
+
}
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":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
|
4
|
+
version: string;
|
|
5
|
+
purl?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CycloneDxBom {
|
|
8
|
+
bomFormat: "CycloneDX";
|
|
9
|
+
specVersion: "1.5";
|
|
10
|
+
serialNumber: string;
|
|
11
|
+
version: 1;
|
|
12
|
+
metadata: {
|
|
13
|
+
timestamp: string;
|
|
14
|
+
component: {
|
|
15
|
+
type: "application";
|
|
16
|
+
name: string;
|
|
17
|
+
version: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
components: SbomComponent[];
|
|
21
|
+
}
|
|
22
|
+
export interface SbomOptions {
|
|
23
|
+
name: string;
|
|
24
|
+
version: string;
|
|
25
|
+
components: {
|
|
26
|
+
name: string;
|
|
27
|
+
version: string;
|
|
28
|
+
}[];
|
|
29
|
+
now?: () => string;
|
|
30
|
+
}
|
|
31
|
+
/** Build a minimal, parseable CycloneDX 1.5 JSON SBOM from a component list. */
|
|
32
|
+
export declare function buildSbom(options: SbomOptions): CycloneDxBom;
|
|
33
|
+
/** Stable digest over the sorted component identity list. */
|
|
34
|
+
export declare function sbomSummaryHash(bom: CycloneDxBom): string;
|
|
35
|
+
/** Extract the locked `name@version` entries from a pnpm lockfile. */
|
|
36
|
+
export declare function loadLockedPackages(root: string): Promise<{
|
|
37
|
+
name: string;
|
|
38
|
+
version: string;
|
|
39
|
+
}[]>;
|
|
40
|
+
export interface LicenseAudit {
|
|
41
|
+
total: number;
|
|
42
|
+
declared: number;
|
|
43
|
+
unknown: number;
|
|
44
|
+
summaryHash: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Best-effort license audit over installed packages. A package whose
|
|
48
|
+
* `package.json` is unreadable or whose `license` is not a non-empty string is
|
|
49
|
+
* counted as `unknown`, never silently upgraded.
|
|
50
|
+
*/
|
|
51
|
+
export declare function auditLicenses(root: string, components: readonly {
|
|
52
|
+
name: string;
|
|
53
|
+
version: string;
|
|
54
|
+
}[]): Promise<LicenseAudit>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { parse as parseYaml } from "yaml";
|
|
5
|
+
/** Build a minimal, parseable CycloneDX 1.5 JSON SBOM from a component list. */
|
|
6
|
+
export function buildSbom(options) {
|
|
7
|
+
const components = options.components
|
|
8
|
+
.map(({ name, version }) => ({
|
|
9
|
+
type: "library",
|
|
10
|
+
name,
|
|
11
|
+
version,
|
|
12
|
+
purl: `pkg:npm/${name}@${version}`,
|
|
13
|
+
}))
|
|
14
|
+
.sort((left, right) => left.name.localeCompare(right.name) || left.version.localeCompare(right.version));
|
|
15
|
+
return {
|
|
16
|
+
bomFormat: "CycloneDX",
|
|
17
|
+
specVersion: "1.5",
|
|
18
|
+
serialNumber: `urn:uuid:${randomUUID()}`,
|
|
19
|
+
version: 1,
|
|
20
|
+
metadata: {
|
|
21
|
+
timestamp: (options.now ?? (() => new Date().toISOString()))(),
|
|
22
|
+
component: { type: "application", name: options.name, version: options.version },
|
|
23
|
+
},
|
|
24
|
+
components,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** Stable digest over the sorted component identity list. */
|
|
28
|
+
export function sbomSummaryHash(bom) {
|
|
29
|
+
const canonical = JSON.stringify(bom.components.map((component) => [component.name, component.version]));
|
|
30
|
+
return createHash("sha256").update(canonical, "utf8").digest("hex");
|
|
31
|
+
}
|
|
32
|
+
/** Extract the locked `name@version` entries from a pnpm lockfile. */
|
|
33
|
+
export async function loadLockedPackages(root) {
|
|
34
|
+
const lockText = await readFile(join(root, "pnpm-lock.yaml"), "utf8");
|
|
35
|
+
const lock = parseYaml(lockText);
|
|
36
|
+
const packages = lock.packages ?? {};
|
|
37
|
+
const result = [];
|
|
38
|
+
for (const key of Object.keys(packages)) {
|
|
39
|
+
const at = key.lastIndexOf("@");
|
|
40
|
+
if (at <= 0)
|
|
41
|
+
continue;
|
|
42
|
+
const name = key.slice(0, at);
|
|
43
|
+
const version = key.slice(at + 1).split("(")[0] ?? "";
|
|
44
|
+
if (name.length === 0 || version.length === 0)
|
|
45
|
+
continue;
|
|
46
|
+
result.push({ name, version });
|
|
47
|
+
}
|
|
48
|
+
return result.sort((left, right) => `${left.name}@${left.version}`.localeCompare(`${right.name}@${right.version}`));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Best-effort license audit over installed packages. A package whose
|
|
52
|
+
* `package.json` is unreadable or whose `license` is not a non-empty string is
|
|
53
|
+
* counted as `unknown`, never silently upgraded.
|
|
54
|
+
*/
|
|
55
|
+
export async function auditLicenses(root, components) {
|
|
56
|
+
let declared = 0;
|
|
57
|
+
let unknown = 0;
|
|
58
|
+
for (const component of components) {
|
|
59
|
+
try {
|
|
60
|
+
const text = await readFile(join(root, "node_modules", component.name, "package.json"), "utf8");
|
|
61
|
+
const manifest = JSON.parse(text);
|
|
62
|
+
if (typeof manifest.license === "string" && manifest.license.trim().length > 0)
|
|
63
|
+
declared += 1;
|
|
64
|
+
else
|
|
65
|
+
unknown += 1;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
unknown += 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const total = components.length;
|
|
72
|
+
const summaryHash = createHash("sha256")
|
|
73
|
+
.update(`${total}:${declared}:${unknown}`)
|
|
74
|
+
.digest("hex");
|
|
75
|
+
return { total, declared, unknown, summaryHash };
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=sbom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sbom.js","sourceRoot":"","sources":["../../../src/trust/sbom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;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