peaks-loop-shared 0.0.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/dist/fs.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export declare function pathExists(path: string): Promise<boolean>;
2
+ export declare function readText(path: string): Promise<string>;
3
+ export declare function listDirectories(path: string): Promise<string[]>;
4
+ export declare function isDirectory(path: string): Promise<boolean>;
5
+ //# sourceMappingURL=fs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAGA,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO/D;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE5D;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAGrE;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAMhE"}
package/dist/fs.js ADDED
@@ -0,0 +1,26 @@
1
+ import { access, readdir, readFile, stat } from 'node:fs/promises';
2
+ import { constants } from 'node:fs';
3
+ export async function pathExists(path) {
4
+ try {
5
+ await access(path, constants.F_OK);
6
+ return true;
7
+ }
8
+ catch {
9
+ return false;
10
+ }
11
+ }
12
+ export async function readText(path) {
13
+ return readFile(path, 'utf8');
14
+ }
15
+ export async function listDirectories(path) {
16
+ const entries = await readdir(path, { withFileTypes: true });
17
+ return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
18
+ }
19
+ export async function isDirectory(path) {
20
+ try {
21
+ return (await stat(path)).isDirectory();
22
+ }
23
+ catch {
24
+ return false;
25
+ }
26
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * peaks-loop-shared public surface.
3
+ *
4
+ * Re-exports the four pure-function utils this package owns:
5
+ * 1. fs — file system primitives (pathExists, isDirectory, ...)
6
+ * 2. paths — repo-root + skills/schemas/templates dirs + required
7
+ * skill + schema name lists
8
+ * 3. result — ResultEnvelope / ok() / fail() + sensitive-error redaction
9
+ * 4. version — CLI_VERSION (synced from main package.json by
10
+ * scripts/sync-version.mjs)
11
+ *
12
+ * Main peaks-loop package consumes these via `workspace:*` deps:
13
+ *
14
+ * import { ok, fail } from 'peaks-loop-shared';
15
+ * import { pathExists } from 'peaks-loop-shared/fs';
16
+ */
17
+ export * from './fs.js';
18
+ export * from './paths.js';
19
+ export * from './result.js';
20
+ export * from './version.js';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * peaks-loop-shared public surface.
3
+ *
4
+ * Re-exports the four pure-function utils this package owns:
5
+ * 1. fs — file system primitives (pathExists, isDirectory, ...)
6
+ * 2. paths — repo-root + skills/schemas/templates dirs + required
7
+ * skill + schema name lists
8
+ * 3. result — ResultEnvelope / ok() / fail() + sensitive-error redaction
9
+ * 4. version — CLI_VERSION (synced from main package.json by
10
+ * scripts/sync-version.mjs)
11
+ *
12
+ * Main peaks-loop package consumes these via `workspace:*` deps:
13
+ *
14
+ * import { ok, fail } from 'peaks-loop-shared';
15
+ * import { pathExists } from 'peaks-loop-shared/fs';
16
+ */
17
+ export * from './fs.js';
18
+ export * from './paths.js';
19
+ export * from './result.js';
20
+ export * from './version.js';
@@ -0,0 +1,7 @@
1
+ export declare const repoRoot: string;
2
+ export declare const skillsDir: string;
3
+ export declare const schemasDir: string;
4
+ export declare const templatesDir: string;
5
+ export declare const requiredSkillNames: readonly ["peaks-code", "peaks-prd", "peaks-ui", "peaks-rd", "peaks-qa", "peaks-sc", "peaks-txt", "peaks-sop"];
6
+ export declare const requiredSchemaFiles: readonly ["artifact-manifest.schema.json", "context-capsule.schema.json", "approval-record.schema.json", "change-impact.schema.json", "refactor-slice-spec.schema.json", "artifact-retention-report.schema.json", "capability-source.schema.json", "capability-item.schema.json", "capability-availability.schema.json", "recommendation-plan.schema.json", "artifact-workspace.schema.json", "mcp-server.schema.json", "mcp-install-spec.schema.json", "mcp-install-plan.schema.json", "mcp-apply-result.schema.json", "openspec-change-summary.schema.json", "openspec-render-request.schema.json", "openspec-validation-result.schema.json", "doctor-report.schema.json", "library-breaking-changes.schema.json"];
7
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,QAAQ,QAAqC,CAAC;AAC3D,eAAO,MAAM,SAAS,QAA8B,CAAC;AACrD,eAAO,MAAM,UAAU,QAA+B,CAAC;AACvD,eAAO,MAAM,YAAY,QAAiC,CAAC;AAE3D,eAAO,MAAM,kBAAkB,gHASrB,CAAC;AAEX,eAAO,MAAM,mBAAmB,srBAqBtB,CAAC"}
package/dist/paths.js ADDED
@@ -0,0 +1,50 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ function findRepoRoot(startPath) {
5
+ let currentPath = startPath;
6
+ while (currentPath !== dirname(currentPath)) {
7
+ if (existsSync(resolve(currentPath, 'package.json')) && existsSync(resolve(currentPath, 'skills'))) {
8
+ return currentPath;
9
+ }
10
+ currentPath = dirname(currentPath);
11
+ }
12
+ throw new Error(`Unable to locate Peaks repository root from ${startPath}`);
13
+ }
14
+ const currentFile = fileURLToPath(import.meta.url);
15
+ export const repoRoot = findRepoRoot(dirname(currentFile));
16
+ export const skillsDir = resolve(repoRoot, 'skills');
17
+ export const schemasDir = resolve(repoRoot, 'schemas');
18
+ export const templatesDir = resolve(repoRoot, 'templates');
19
+ export const requiredSkillNames = [
20
+ 'peaks-code',
21
+ 'peaks-prd',
22
+ 'peaks-ui',
23
+ 'peaks-rd',
24
+ 'peaks-qa',
25
+ 'peaks-sc',
26
+ 'peaks-txt',
27
+ 'peaks-sop'
28
+ ];
29
+ export const requiredSchemaFiles = [
30
+ 'artifact-manifest.schema.json',
31
+ 'context-capsule.schema.json',
32
+ 'approval-record.schema.json',
33
+ 'change-impact.schema.json',
34
+ 'refactor-slice-spec.schema.json',
35
+ 'artifact-retention-report.schema.json',
36
+ 'capability-source.schema.json',
37
+ 'capability-item.schema.json',
38
+ 'capability-availability.schema.json',
39
+ 'recommendation-plan.schema.json',
40
+ 'artifact-workspace.schema.json',
41
+ 'mcp-server.schema.json',
42
+ 'mcp-install-spec.schema.json',
43
+ 'mcp-install-plan.schema.json',
44
+ 'mcp-apply-result.schema.json',
45
+ 'openspec-change-summary.schema.json',
46
+ 'openspec-render-request.schema.json',
47
+ 'openspec-validation-result.schema.json',
48
+ 'doctor-report.schema.json',
49
+ 'library-breaking-changes.schema.json'
50
+ ];
@@ -0,0 +1,23 @@
1
+ export type ResultEnvelope<T> = {
2
+ ok: boolean;
3
+ command: string;
4
+ data: T;
5
+ warnings: string[];
6
+ nextActions: string[];
7
+ code?: string;
8
+ message?: string;
9
+ /**
10
+ * Slice 2026-06-23-audit-4th #B3: opaque per-failure correlation
11
+ * id. Always present on `fail()` envelopes. Lets a user say
12
+ * "my last failure was errorId=X; show me the JSONL log lines
13
+ * tagged with X" without grepping on a code/message that may be
14
+ * repeated. Also written to the next writeLogEntry call (best-effort)
15
+ * by the caller so the log entry can be cross-referenced.
16
+ */
17
+ errorId?: string;
18
+ };
19
+ export declare function ok<T>(command: string, data: T, warnings?: string[], nextActions?: string[]): ResultEnvelope<T>;
20
+ export declare function fail<T>(command: string, code: string, message: string, data: T, nextActions?: string[]): ResultEnvelope<T>;
21
+ export declare function getErrorMessage(error: unknown): string;
22
+ export declare function redactSensitiveErrorMessage(message: string): string;
23
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,CAAC,CAAC;IACR,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAgB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,GAAE,MAAM,EAAO,EAAE,WAAW,GAAE,MAAM,EAAO,GAAG,cAAc,CAAC,CAAC,CAAC,CAEtH;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,GAAE,MAAM,EAAO,GAAG,cAAc,CAAC,CAAC,CAAC,CAe9H;AAiBD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAUtD;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnE"}
package/dist/result.js ADDED
@@ -0,0 +1,46 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ export function ok(command, data, warnings = [], nextActions = []) {
3
+ return { ok: true, command, data, warnings, nextActions };
4
+ }
5
+ export function fail(command, code, message, data, nextActions = []) {
6
+ // Slice 2026-06-23-audit-4th #B3: mint a fresh errorId per failure.
7
+ // The id is opaque (uuid v4) and never reused; downstream log
8
+ // entries from the same code path can carry the same id for
9
+ // post-hoc correlation.
10
+ return {
11
+ ok: false,
12
+ command,
13
+ code,
14
+ message: redactSensitiveErrorMessage(message),
15
+ data,
16
+ warnings: [],
17
+ nextActions,
18
+ errorId: randomUUID()
19
+ };
20
+ }
21
+ const SENSITIVE_ERROR_PATTERNS = [
22
+ /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}\b/gi,
23
+ /-----BEGIN [A-Z ]*PRIVATE KEY-----/g,
24
+ /\b(?:api[\s_-]?key|token|password|secret)\s*[:=]\s*['\"]?[^\s'\"]{8,}/gi,
25
+ /\bAKIA[0-9A-Z]{16}\b/g,
26
+ /\bAIza[0-9A-Za-z_-]{20,}\b/g,
27
+ /\bghp_[0-9A-Za-z_]{20,}\b/g,
28
+ /\bgithub_pat_[0-9A-Za-z_]{20,}\b/g,
29
+ /\bglpat-[0-9A-Za-z_-]{20,}\b/g,
30
+ /\bxox[abprse]-[0-9A-Za-z-]{20,}\b/g,
31
+ /\bsk-[A-Za-z0-9_-]{16,}\b/g,
32
+ /\beyJ[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,
33
+ /(secret|token|password|api[-_ ]?key)/gi
34
+ ];
35
+ export function getErrorMessage(error) {
36
+ if (error instanceof Error) {
37
+ return error.message;
38
+ }
39
+ if (typeof error === 'string') {
40
+ return error;
41
+ }
42
+ return 'Unexpected error';
43
+ }
44
+ export function redactSensitiveErrorMessage(message) {
45
+ return SENSITIVE_ERROR_PATTERNS.reduce((redacted, pattern) => redacted.replace(pattern, '[redacted]'), message);
46
+ }
@@ -0,0 +1,2 @@
1
+ export declare const CLI_VERSION = "4.0.0-beta.15";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,kBAAkB,CAAC"}
@@ -0,0 +1 @@
1
+ export const CLI_VERSION = "4.0.0-beta.15";
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "peaks-loop-shared",
3
+ "version": "0.0.1",
4
+ "description": "Shared pure-function utils for peaks-loop workspace packages (fs / paths / result / version). Slice 3a.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ },
11
+ "./fs": {
12
+ "types": "./dist/fs.d.ts",
13
+ "default": "./dist/fs.js"
14
+ },
15
+ "./paths": {
16
+ "types": "./dist/paths.d.ts",
17
+ "default": "./dist/paths.js"
18
+ },
19
+ "./result": {
20
+ "types": "./dist/result.d.ts",
21
+ "default": "./dist/result.js"
22
+ },
23
+ "./version": {
24
+ "types": "./dist/version.d.ts",
25
+ "default": "./dist/version.js"
26
+ }
27
+ },
28
+ "files": [
29
+ "dist/**"
30
+ ],
31
+ "scripts": {
32
+ "build": "tsc -p tsconfig.json",
33
+ "test": "vitest run"
34
+ },
35
+ "engines": {
36
+ "node": ">=20.0.0"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ }
41
+ }