specatlas 0.1.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/LICENSE +21 -0
- package/dist/approvals-HCBC7QDM-PSBJC7EV.js +8 -0
- package/dist/bin.js +14507 -0
- package/dist/chunk-DKFIPJ74.js +123 -0
- package/dist/chunk-IFALGLUJ.js +225 -0
- package/dist/fsx-VF2P7ALA-XKEWTMDH.js +27 -0
- package/package.json +47 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
|
|
28
|
+
// ../core/dist/chunk-5RKNY2ZC.js
|
|
29
|
+
import { promises as fs } from "fs";
|
|
30
|
+
import path from "path";
|
|
31
|
+
async function exists(p) {
|
|
32
|
+
try {
|
|
33
|
+
await fs.access(p);
|
|
34
|
+
return true;
|
|
35
|
+
} catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function isDirectory(p) {
|
|
40
|
+
try {
|
|
41
|
+
const st = await fs.stat(p);
|
|
42
|
+
return st.isDirectory();
|
|
43
|
+
} catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function readText(p) {
|
|
48
|
+
return fs.readFile(p, "utf8");
|
|
49
|
+
}
|
|
50
|
+
async function readTextIfExists(p) {
|
|
51
|
+
try {
|
|
52
|
+
return await fs.readFile(p, "utf8");
|
|
53
|
+
} catch {
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function writeText(p, content) {
|
|
58
|
+
await ensureDir(path.dirname(p));
|
|
59
|
+
await fs.writeFile(p, content, "utf8");
|
|
60
|
+
}
|
|
61
|
+
async function ensureDir(p) {
|
|
62
|
+
await fs.mkdir(p, { recursive: true });
|
|
63
|
+
}
|
|
64
|
+
async function copyFile(from, to) {
|
|
65
|
+
await ensureDir(path.dirname(to));
|
|
66
|
+
await fs.copyFile(from, to);
|
|
67
|
+
}
|
|
68
|
+
async function listDir(p) {
|
|
69
|
+
try {
|
|
70
|
+
return await fs.readdir(p);
|
|
71
|
+
} catch {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async function listDirs(p) {
|
|
76
|
+
const entries = await listDir(p);
|
|
77
|
+
const out = [];
|
|
78
|
+
for (const e of entries) {
|
|
79
|
+
if (await isDirectory(path.join(p, e))) out.push(e);
|
|
80
|
+
}
|
|
81
|
+
return out.sort();
|
|
82
|
+
}
|
|
83
|
+
async function walkFiles(root, opts = {}) {
|
|
84
|
+
const skip = new Set(opts.skipDirs ?? ["node_modules", ".git", "dist", "coverage", ".sdd"]);
|
|
85
|
+
const out = [];
|
|
86
|
+
async function rec(dir) {
|
|
87
|
+
let entries;
|
|
88
|
+
try {
|
|
89
|
+
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
90
|
+
} catch {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
for (const e of entries) {
|
|
94
|
+
if (e.isDirectory()) {
|
|
95
|
+
if (skip.has(e.name)) continue;
|
|
96
|
+
await rec(path.join(dir, e.name));
|
|
97
|
+
} else if (e.isFile()) {
|
|
98
|
+
out.push({ path: path.join(dir, e.name), name: e.name });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
await rec(root);
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
function toPosix(p) {
|
|
106
|
+
return p.split(path.sep).join("/");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export {
|
|
110
|
+
__commonJS,
|
|
111
|
+
__toESM,
|
|
112
|
+
exists,
|
|
113
|
+
isDirectory,
|
|
114
|
+
readText,
|
|
115
|
+
readTextIfExists,
|
|
116
|
+
writeText,
|
|
117
|
+
ensureDir,
|
|
118
|
+
copyFile,
|
|
119
|
+
listDir,
|
|
120
|
+
listDirs,
|
|
121
|
+
walkFiles,
|
|
122
|
+
toPosix
|
|
123
|
+
};
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
readTextIfExists,
|
|
4
|
+
toPosix,
|
|
5
|
+
writeText
|
|
6
|
+
} from "./chunk-DKFIPJ74.js";
|
|
7
|
+
|
|
8
|
+
// ../core/dist/chunk-2BFXQ65Q.js
|
|
9
|
+
import path from "path";
|
|
10
|
+
import { stringify as stringifyYaml } from "yaml";
|
|
11
|
+
import { createHash } from "crypto";
|
|
12
|
+
import { parse as parseYaml } from "yaml";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
function diag(code, severity, message, opts = {}) {
|
|
15
|
+
const d = { code, severity, message };
|
|
16
|
+
if (opts.path !== void 0) d.path = opts.path;
|
|
17
|
+
if (opts.line !== void 0) d.line = opts.line;
|
|
18
|
+
if (opts.suggestion !== void 0) d.suggestion = opts.suggestion;
|
|
19
|
+
return d;
|
|
20
|
+
}
|
|
21
|
+
function countBySeverity(diags) {
|
|
22
|
+
let errors = 0;
|
|
23
|
+
let warnings = 0;
|
|
24
|
+
let infos = 0;
|
|
25
|
+
for (const d of diags) {
|
|
26
|
+
if (d.severity === "error") errors += 1;
|
|
27
|
+
else if (d.severity === "warning") warnings += 1;
|
|
28
|
+
else infos += 1;
|
|
29
|
+
}
|
|
30
|
+
return { errors, warnings, infos };
|
|
31
|
+
}
|
|
32
|
+
function canonicalizeMarkdown(md) {
|
|
33
|
+
let text = md;
|
|
34
|
+
if (text.charCodeAt(0) === 65279) text = text.slice(1);
|
|
35
|
+
const lines = text.replace(/\r\n?/g, "\n").split("\n");
|
|
36
|
+
const out = [];
|
|
37
|
+
let blankRun = 0;
|
|
38
|
+
for (const line of lines) {
|
|
39
|
+
const trimmedEnd = line.replace(/[ \t]+$/g, "");
|
|
40
|
+
if (trimmedEnd.trim() === "") {
|
|
41
|
+
blankRun += 1;
|
|
42
|
+
if (blankRun > 1) continue;
|
|
43
|
+
out.push("");
|
|
44
|
+
} else {
|
|
45
|
+
blankRun = 0;
|
|
46
|
+
out.push(trimmedEnd);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
while (out.length > 0 && out[0] === "") out.shift();
|
|
50
|
+
while (out.length > 0 && out[out.length - 1] === "") out.pop();
|
|
51
|
+
return out.join("\n") + "\n";
|
|
52
|
+
}
|
|
53
|
+
function sha256(content) {
|
|
54
|
+
const h = createHash("sha256");
|
|
55
|
+
h.update(content);
|
|
56
|
+
return `sha256:${h.digest("hex")}`;
|
|
57
|
+
}
|
|
58
|
+
function artifactHash(markdown) {
|
|
59
|
+
return sha256(canonicalizeMarkdown(markdown));
|
|
60
|
+
}
|
|
61
|
+
function shortHash(hash) {
|
|
62
|
+
return hash.replace(/^sha256:/, "").slice(0, 8);
|
|
63
|
+
}
|
|
64
|
+
var changeMetaSchema = z.object({
|
|
65
|
+
schema_version: z.number().int().positive().default(1),
|
|
66
|
+
slug: z.string().min(1),
|
|
67
|
+
title: z.string().optional(),
|
|
68
|
+
domain: z.string().optional(),
|
|
69
|
+
lane: z.enum(["fix", "standard", "full"]).default("standard"),
|
|
70
|
+
risk: z.enum(["low", "medium", "high"]).optional(),
|
|
71
|
+
created: z.string().optional(),
|
|
72
|
+
owner: z.string().optional(),
|
|
73
|
+
tracker: z.object({ provider: z.string(), id: z.string() }).optional(),
|
|
74
|
+
paused: z.object({ reason: z.string(), at: z.string(), by: z.string() }).optional(),
|
|
75
|
+
lane_history: z.array(z.object({ from: z.enum(["fix", "standard", "full"]), to: z.enum(["fix", "standard", "full"]), at: z.string(), by: z.string() })).optional(),
|
|
76
|
+
diagram_exceptions: z.array(z.string()).optional(),
|
|
77
|
+
overrides: z.array(z.object({ gate: z.string(), reason: z.string(), by: z.string(), at: z.string() })).optional()
|
|
78
|
+
});
|
|
79
|
+
function parseChangeMeta(raw, filePath) {
|
|
80
|
+
const diagnostics = [];
|
|
81
|
+
let data;
|
|
82
|
+
try {
|
|
83
|
+
data = parseYaml(raw);
|
|
84
|
+
} catch (err) {
|
|
85
|
+
return { diagnostics: [diag("ATLAS-META-001", "error", `meta.yaml inv\xE1lido: ${err.message}`, { path: filePath })] };
|
|
86
|
+
}
|
|
87
|
+
const parsed = changeMetaSchema.safeParse(data);
|
|
88
|
+
if (!parsed.success) {
|
|
89
|
+
return {
|
|
90
|
+
diagnostics: parsed.error.issues.map(
|
|
91
|
+
(issue) => diag("ATLAS-META-002", "error", `meta.yaml (${issue.path.join(".") || "ra\xEDz"}): ${issue.message}`, { path: filePath })
|
|
92
|
+
)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const v = parsed.data;
|
|
96
|
+
const meta = { schemaVersion: v.schema_version, slug: v.slug, lane: v.lane };
|
|
97
|
+
if (v.title !== void 0) meta.title = v.title;
|
|
98
|
+
if (v.domain !== void 0) meta.domain = v.domain;
|
|
99
|
+
if (v.risk !== void 0) meta.risk = v.risk;
|
|
100
|
+
if (v.created !== void 0) meta.created = v.created;
|
|
101
|
+
if (v.owner !== void 0) meta.owner = v.owner;
|
|
102
|
+
if (v.tracker !== void 0) meta.tracker = v.tracker;
|
|
103
|
+
if (v.paused !== void 0) meta.paused = v.paused;
|
|
104
|
+
if (v.lane_history !== void 0) meta.laneHistory = v.lane_history;
|
|
105
|
+
if (v.diagram_exceptions !== void 0) meta.diagramExceptions = v.diagram_exceptions;
|
|
106
|
+
if (v.overrides !== void 0) meta.overrides = v.overrides;
|
|
107
|
+
for (const override of meta.overrides ?? []) {
|
|
108
|
+
if (!override.reason || !override.by) {
|
|
109
|
+
diagnostics.push(diag("ATLAS-LIFECYCLE-004", "error", `Override del gate "${override.gate}" sin motivo o autor`, { path: filePath }));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return { meta, diagnostics };
|
|
113
|
+
}
|
|
114
|
+
var approvalsSchema = z.object({
|
|
115
|
+
schema_version: z.number().int().positive().default(1),
|
|
116
|
+
approvals: z.array(
|
|
117
|
+
z.object({
|
|
118
|
+
artifact: z.string(),
|
|
119
|
+
artifact_hash: z.string(),
|
|
120
|
+
approved_by: z.string(),
|
|
121
|
+
approved_at: z.string(),
|
|
122
|
+
channel: z.enum(["presentation", "editor", "pr", "tracker", "cli"]).default("cli"),
|
|
123
|
+
note: z.string().optional()
|
|
124
|
+
})
|
|
125
|
+
).default([])
|
|
126
|
+
});
|
|
127
|
+
function parseApprovals(raw, filePath) {
|
|
128
|
+
let data;
|
|
129
|
+
try {
|
|
130
|
+
data = parseYaml(raw);
|
|
131
|
+
} catch (err) {
|
|
132
|
+
return { diagnostics: [diag("ATLAS-APPROVALS-001", "error", `approvals.yaml inv\xE1lido: ${err.message}`, { path: filePath })] };
|
|
133
|
+
}
|
|
134
|
+
const parsed = approvalsSchema.safeParse(data);
|
|
135
|
+
if (!parsed.success) {
|
|
136
|
+
return {
|
|
137
|
+
diagnostics: parsed.error.issues.map(
|
|
138
|
+
(issue) => diag("ATLAS-APPROVALS-002", "error", `approvals.yaml (${issue.path.join(".") || "ra\xEDz"}): ${issue.message}`, { path: filePath })
|
|
139
|
+
)
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
const file = {
|
|
143
|
+
schemaVersion: parsed.data.schema_version,
|
|
144
|
+
approvals: parsed.data.approvals.map((a) => {
|
|
145
|
+
const approval = {
|
|
146
|
+
artifact: a.artifact,
|
|
147
|
+
artifactHash: a.artifact_hash,
|
|
148
|
+
approvedBy: a.approved_by,
|
|
149
|
+
approvedAt: a.approved_at,
|
|
150
|
+
channel: a.channel
|
|
151
|
+
};
|
|
152
|
+
if (a.note !== void 0) approval.note = a.note;
|
|
153
|
+
return approval;
|
|
154
|
+
})
|
|
155
|
+
};
|
|
156
|
+
return { approvals: file, diagnostics: [] };
|
|
157
|
+
}
|
|
158
|
+
function normalizeArtifact(sddDir, artifact) {
|
|
159
|
+
const abs = path.isAbsolute(artifact) ? artifact : path.resolve(sddDir, artifact);
|
|
160
|
+
const rel = toPosix(path.relative(sddDir, abs));
|
|
161
|
+
return { rel, abs };
|
|
162
|
+
}
|
|
163
|
+
async function signApproval(opts) {
|
|
164
|
+
const root = path.resolve(opts.root);
|
|
165
|
+
const sddDir = path.join(root, ".sdd");
|
|
166
|
+
const file = path.join(sddDir, "approvals.yaml");
|
|
167
|
+
const diagnostics = [];
|
|
168
|
+
const { rel, abs } = normalizeArtifact(sddDir, opts.artifact);
|
|
169
|
+
if (!opts.by.trim()) {
|
|
170
|
+
diagnostics.push(diag("ATLAS-APPROVE-001", "error", "La aprobaci\xF3n requiere el nombre de quien aprueba (--by)", { suggestion: 'Ejemplo: satlas approve changes/x/spec.md --by "Mar\xEDa P\xE9rez"`' }));
|
|
171
|
+
return { file, diagnostics };
|
|
172
|
+
}
|
|
173
|
+
const content = await readTextIfExists(abs);
|
|
174
|
+
if (content === void 0) {
|
|
175
|
+
diagnostics.push(diag("ATLAS-APPROVE-002", "error", `No existe el artefacto a aprobar: ${rel}`, { path: abs }));
|
|
176
|
+
return { file, diagnostics };
|
|
177
|
+
}
|
|
178
|
+
const existing = await readTextIfExists(file);
|
|
179
|
+
let approvals = [];
|
|
180
|
+
if (existing !== void 0) {
|
|
181
|
+
const parsed = parseApprovals(existing, file);
|
|
182
|
+
diagnostics.push(...parsed.diagnostics);
|
|
183
|
+
approvals = parsed.approvals?.approvals ?? [];
|
|
184
|
+
}
|
|
185
|
+
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
186
|
+
const approval = {
|
|
187
|
+
artifact: rel,
|
|
188
|
+
artifactHash: artifactHash(content),
|
|
189
|
+
approvedBy: opts.by.trim(),
|
|
190
|
+
approvedAt: now.toISOString(),
|
|
191
|
+
channel: opts.channel ?? "cli"
|
|
192
|
+
};
|
|
193
|
+
if (opts.note) approval.note = opts.note;
|
|
194
|
+
approvals = approvals.filter((a) => a.artifact !== rel);
|
|
195
|
+
approvals.push(approval);
|
|
196
|
+
const doc = {
|
|
197
|
+
schema_version: 1,
|
|
198
|
+
approvals: approvals.map((a) => {
|
|
199
|
+
const row = {
|
|
200
|
+
artifact: a.artifact,
|
|
201
|
+
artifact_hash: a.artifactHash,
|
|
202
|
+
approved_by: a.approvedBy,
|
|
203
|
+
approved_at: a.approvedAt,
|
|
204
|
+
channel: a.channel
|
|
205
|
+
};
|
|
206
|
+
if (a.note) row["note"] = a.note;
|
|
207
|
+
return row;
|
|
208
|
+
})
|
|
209
|
+
};
|
|
210
|
+
if (!opts.dryRun) {
|
|
211
|
+
await writeText(file, stringifyYaml(doc, { lineWidth: 120 }));
|
|
212
|
+
}
|
|
213
|
+
return { approval, file, diagnostics };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export {
|
|
217
|
+
diag,
|
|
218
|
+
countBySeverity,
|
|
219
|
+
sha256,
|
|
220
|
+
artifactHash,
|
|
221
|
+
shortHash,
|
|
222
|
+
parseChangeMeta,
|
|
223
|
+
parseApprovals,
|
|
224
|
+
signApproval
|
|
225
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
copyFile,
|
|
4
|
+
ensureDir,
|
|
5
|
+
exists,
|
|
6
|
+
isDirectory,
|
|
7
|
+
listDir,
|
|
8
|
+
listDirs,
|
|
9
|
+
readText,
|
|
10
|
+
readTextIfExists,
|
|
11
|
+
toPosix,
|
|
12
|
+
walkFiles,
|
|
13
|
+
writeText
|
|
14
|
+
} from "./chunk-DKFIPJ74.js";
|
|
15
|
+
export {
|
|
16
|
+
copyFile,
|
|
17
|
+
ensureDir,
|
|
18
|
+
exists,
|
|
19
|
+
isDirectory,
|
|
20
|
+
listDir,
|
|
21
|
+
listDirs,
|
|
22
|
+
readText,
|
|
23
|
+
readTextIfExists,
|
|
24
|
+
toPosix,
|
|
25
|
+
walkFiles,
|
|
26
|
+
writeText
|
|
27
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "specatlas",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SpecAtlas: kernel determinista de Spec-Driven Development (CLI)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"specatlas": "dist/bin.js",
|
|
9
|
+
"satlas": "dist/bin.js"
|
|
10
|
+
},
|
|
11
|
+
"main": "dist/bin.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"sdd",
|
|
20
|
+
"spec-driven-development",
|
|
21
|
+
"specs",
|
|
22
|
+
"agents",
|
|
23
|
+
"cli",
|
|
24
|
+
"traceability"
|
|
25
|
+
],
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/AlonsoAM/specatlas.git",
|
|
29
|
+
"directory": "packages/cli"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/AlonsoAM/specatlas",
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/AlonsoAM/specatlas/issues"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"yaml": "^2.6.1",
|
|
37
|
+
"zod": "^3.24.1"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@specatlas/adapters": "0.1.0",
|
|
41
|
+
"@specatlas/core": "0.1.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"typecheck": "tsc --noEmit",
|
|
45
|
+
"build": "tsup"
|
|
46
|
+
}
|
|
47
|
+
}
|