sysprom 1.0.0 → 1.0.6
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 +207 -0
- package/dist/schema.json +510 -0
- package/dist/src/canonical-json.d.ts +23 -0
- package/dist/src/canonical-json.js +120 -0
- package/dist/src/cli/commands/add.d.ts +22 -0
- package/dist/src/cli/commands/add.js +95 -0
- package/dist/src/cli/commands/check.d.ts +10 -0
- package/dist/src/cli/commands/check.js +33 -0
- package/dist/src/cli/commands/graph.d.ts +15 -0
- package/dist/src/cli/commands/graph.js +32 -0
- package/dist/src/cli/commands/init.d.ts +2 -0
- package/dist/src/cli/commands/init.js +44 -0
- package/dist/src/cli/commands/json2md.d.ts +2 -0
- package/dist/src/cli/commands/json2md.js +60 -0
- package/dist/src/cli/commands/md2json.d.ts +2 -0
- package/dist/src/cli/commands/md2json.js +29 -0
- package/dist/src/cli/commands/plan.d.ts +2 -0
- package/dist/src/cli/commands/plan.js +227 -0
- package/dist/src/cli/commands/query.d.ts +2 -0
- package/dist/src/cli/commands/query.js +275 -0
- package/dist/src/cli/commands/remove.d.ts +13 -0
- package/dist/src/cli/commands/remove.js +50 -0
- package/dist/src/cli/commands/rename.d.ts +14 -0
- package/dist/src/cli/commands/rename.js +34 -0
- package/dist/src/cli/commands/search.d.ts +11 -0
- package/dist/src/cli/commands/search.js +37 -0
- package/dist/src/cli/commands/speckit.d.ts +2 -0
- package/dist/src/cli/commands/speckit.js +318 -0
- package/dist/src/cli/commands/stats.d.ts +10 -0
- package/dist/src/cli/commands/stats.js +51 -0
- package/dist/src/cli/commands/task.d.ts +2 -0
- package/dist/src/cli/commands/task.js +162 -0
- package/dist/src/cli/commands/update.d.ts +2 -0
- package/dist/src/cli/commands/update.js +219 -0
- package/dist/src/cli/commands/validate.d.ts +10 -0
- package/dist/src/cli/commands/validate.js +30 -0
- package/dist/src/cli/define-command.d.ts +34 -0
- package/dist/src/cli/define-command.js +237 -0
- package/dist/src/cli/index.d.ts +2 -0
- package/dist/src/cli/index.js +3 -0
- package/dist/src/cli/program.d.ts +4 -0
- package/dist/src/cli/program.js +46 -0
- package/dist/src/cli/shared.d.ts +26 -0
- package/dist/src/cli/shared.js +41 -0
- package/dist/src/generate-schema.d.ts +1 -0
- package/dist/src/generate-schema.js +9 -0
- package/dist/src/index.d.ts +48 -0
- package/dist/src/index.js +99 -0
- package/dist/src/io.d.ts +22 -0
- package/dist/src/io.js +66 -0
- package/dist/src/json-to-md.d.ts +26 -0
- package/dist/src/json-to-md.js +498 -0
- package/dist/src/md-to-json.d.ts +22 -0
- package/dist/src/md-to-json.js +548 -0
- package/dist/src/operations/add-node.d.ts +887 -0
- package/dist/src/operations/add-node.js +21 -0
- package/dist/src/operations/add-plan-task.d.ts +594 -0
- package/dist/src/operations/add-plan-task.js +25 -0
- package/dist/src/operations/add-relationship.d.ts +635 -0
- package/dist/src/operations/add-relationship.js +25 -0
- package/dist/src/operations/check.d.ts +301 -0
- package/dist/src/operations/check.js +66 -0
- package/dist/src/operations/define-operation.d.ts +14 -0
- package/dist/src/operations/define-operation.js +21 -0
- package/dist/src/operations/graph.d.ts +303 -0
- package/dist/src/operations/graph.js +71 -0
- package/dist/src/operations/index.d.ts +38 -0
- package/dist/src/operations/index.js +45 -0
- package/dist/src/operations/init-document.d.ts +299 -0
- package/dist/src/operations/init-document.js +26 -0
- package/dist/src/operations/json-to-markdown.d.ts +298 -0
- package/dist/src/operations/json-to-markdown.js +13 -0
- package/dist/src/operations/mark-task-done.d.ts +594 -0
- package/dist/src/operations/mark-task-done.js +26 -0
- package/dist/src/operations/mark-task-undone.d.ts +594 -0
- package/dist/src/operations/mark-task-undone.js +26 -0
- package/dist/src/operations/markdown-to-json.d.ts +298 -0
- package/dist/src/operations/markdown-to-json.js +13 -0
- package/dist/src/operations/next-id.d.ts +322 -0
- package/dist/src/operations/next-id.js +29 -0
- package/dist/src/operations/node-history.d.ts +313 -0
- package/dist/src/operations/node-history.js +55 -0
- package/dist/src/operations/plan-add-task.d.ts +595 -0
- package/dist/src/operations/plan-add-task.js +18 -0
- package/dist/src/operations/plan-gate.d.ts +351 -0
- package/dist/src/operations/plan-gate.js +41 -0
- package/dist/src/operations/plan-init.d.ts +299 -0
- package/dist/src/operations/plan-init.js +17 -0
- package/dist/src/operations/plan-progress.d.ts +313 -0
- package/dist/src/operations/plan-progress.js +23 -0
- package/dist/src/operations/plan-status.d.ts +349 -0
- package/dist/src/operations/plan-status.js +41 -0
- package/dist/src/operations/query-node.d.ts +1065 -0
- package/dist/src/operations/query-node.js +27 -0
- package/dist/src/operations/query-nodes.d.ts +594 -0
- package/dist/src/operations/query-nodes.js +23 -0
- package/dist/src/operations/query-relationships.d.ts +343 -0
- package/dist/src/operations/query-relationships.js +27 -0
- package/dist/src/operations/remove-node.d.ts +895 -0
- package/dist/src/operations/remove-node.js +58 -0
- package/dist/src/operations/remove-relationship.d.ts +622 -0
- package/dist/src/operations/remove-relationship.js +26 -0
- package/dist/src/operations/rename.d.ts +594 -0
- package/dist/src/operations/rename.js +113 -0
- package/dist/src/operations/search.d.ts +593 -0
- package/dist/src/operations/search.js +39 -0
- package/dist/src/operations/speckit-diff.d.ts +330 -0
- package/dist/src/operations/speckit-diff.js +89 -0
- package/dist/src/operations/speckit-export.d.ts +300 -0
- package/dist/src/operations/speckit-export.js +17 -0
- package/dist/src/operations/speckit-import.d.ts +299 -0
- package/dist/src/operations/speckit-import.js +39 -0
- package/dist/src/operations/speckit-sync.d.ts +900 -0
- package/dist/src/operations/speckit-sync.js +116 -0
- package/dist/src/operations/state-at.d.ts +309 -0
- package/dist/src/operations/state-at.js +53 -0
- package/dist/src/operations/stats.d.ts +324 -0
- package/dist/src/operations/stats.js +85 -0
- package/dist/src/operations/task-list.d.ts +305 -0
- package/dist/src/operations/task-list.js +44 -0
- package/dist/src/operations/timeline.d.ts +312 -0
- package/dist/src/operations/timeline.js +46 -0
- package/dist/src/operations/trace-from-node.d.ts +1197 -0
- package/dist/src/operations/trace-from-node.js +36 -0
- package/dist/src/operations/update-metadata.d.ts +593 -0
- package/dist/src/operations/update-metadata.js +18 -0
- package/dist/src/operations/update-node.d.ts +957 -0
- package/dist/src/operations/update-node.js +24 -0
- package/dist/src/operations/update-plan-task.d.ts +595 -0
- package/dist/src/operations/update-plan-task.js +31 -0
- package/dist/src/operations/validate.d.ts +310 -0
- package/dist/src/operations/validate.js +82 -0
- package/dist/src/schema.d.ts +891 -0
- package/dist/src/schema.js +356 -0
- package/dist/src/speckit/generate.d.ts +7 -0
- package/dist/src/speckit/generate.js +546 -0
- package/dist/src/speckit/index.d.ts +4 -0
- package/dist/src/speckit/index.js +4 -0
- package/dist/src/speckit/parse.d.ts +11 -0
- package/dist/src/speckit/parse.js +712 -0
- package/dist/src/speckit/plan.d.ts +125 -0
- package/dist/src/speckit/plan.js +636 -0
- package/dist/src/speckit/project.d.ts +39 -0
- package/dist/src/speckit/project.js +141 -0
- package/dist/src/text.d.ts +23 -0
- package/dist/src/text.js +32 -0
- package/package.json +86 -8
- package/schema.json +510 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { defineOperation } from "./define-operation.js";
|
|
3
|
+
import { SysProMDocument } from "../schema.js";
|
|
4
|
+
function isRecord(value) {
|
|
5
|
+
return typeof value === "object" && value !== null;
|
|
6
|
+
}
|
|
7
|
+
function isNode(value) {
|
|
8
|
+
return (isRecord(value) &&
|
|
9
|
+
"id" in value &&
|
|
10
|
+
typeof value.id === "string" &&
|
|
11
|
+
"type" in value &&
|
|
12
|
+
typeof value.type === "string");
|
|
13
|
+
}
|
|
14
|
+
function isSysProMDocument(value) {
|
|
15
|
+
return (isRecord(value) &&
|
|
16
|
+
"nodes" in value &&
|
|
17
|
+
Array.isArray(value.nodes) &&
|
|
18
|
+
"metadata" in value &&
|
|
19
|
+
isRecord(value.metadata));
|
|
20
|
+
}
|
|
21
|
+
function renameNodeReferences(node, oldId, newId) {
|
|
22
|
+
if (!isRecord(node)) {
|
|
23
|
+
return node;
|
|
24
|
+
}
|
|
25
|
+
const updated = { ...node };
|
|
26
|
+
// Rename the node itself
|
|
27
|
+
if (updated.id === oldId) {
|
|
28
|
+
updated.id = newId;
|
|
29
|
+
}
|
|
30
|
+
// Update scope references
|
|
31
|
+
if (Array.isArray(updated.scope)) {
|
|
32
|
+
updated.scope = updated.scope.map((s) => {
|
|
33
|
+
return typeof s === "string" && s === oldId ? newId : s;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// Update includes references
|
|
37
|
+
if (Array.isArray(updated.includes)) {
|
|
38
|
+
updated.includes = updated.includes.map((i) => {
|
|
39
|
+
return typeof i === "string" && i === oldId ? newId : i;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
// Update selected (if it references a node)
|
|
43
|
+
if (updated.selected === oldId) {
|
|
44
|
+
updated.selected = newId;
|
|
45
|
+
}
|
|
46
|
+
// Update operations targets
|
|
47
|
+
if (Array.isArray(updated.operations)) {
|
|
48
|
+
updated.operations = updated.operations.map((op) => {
|
|
49
|
+
if (!isRecord(op))
|
|
50
|
+
return op;
|
|
51
|
+
if ("target" in op) {
|
|
52
|
+
return {
|
|
53
|
+
...op,
|
|
54
|
+
target: op.target === oldId ? newId : op.target,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return op;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// Recurse into subsystems
|
|
61
|
+
if (isSysProMDocument(updated.subsystem)) {
|
|
62
|
+
updated.subsystem = renameNodeId(updated.subsystem, oldId, newId);
|
|
63
|
+
}
|
|
64
|
+
return updated;
|
|
65
|
+
}
|
|
66
|
+
function renameNodeId(doc, oldId, newId) {
|
|
67
|
+
const updatedNodes = [];
|
|
68
|
+
for (const node of doc.nodes) {
|
|
69
|
+
const updated = renameNodeReferences(node, oldId, newId);
|
|
70
|
+
if (isNode(updated)) {
|
|
71
|
+
updatedNodes.push(updated);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Update relationships
|
|
75
|
+
const relationships = (doc.relationships ?? []).map((r) => ({
|
|
76
|
+
...r,
|
|
77
|
+
from: r.from === oldId ? newId : r.from,
|
|
78
|
+
to: r.to === oldId ? newId : r.to,
|
|
79
|
+
}));
|
|
80
|
+
// Update external references
|
|
81
|
+
const external_references = (doc.external_references ?? []).map((ref) => ({
|
|
82
|
+
...ref,
|
|
83
|
+
node_id: ref.node_id === oldId ? newId : ref.node_id,
|
|
84
|
+
}));
|
|
85
|
+
return {
|
|
86
|
+
...doc,
|
|
87
|
+
nodes: updatedNodes,
|
|
88
|
+
relationships: relationships.length > 0 ? relationships : undefined,
|
|
89
|
+
external_references: external_references.length > 0 ? external_references : undefined,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export const renameOp = defineOperation({
|
|
93
|
+
name: "rename",
|
|
94
|
+
description: "Rename a node ID across all references in the document. Updates the node's own ID, relationships, scope, includes, operations targets, external references, and recursively into subsystems.",
|
|
95
|
+
input: z.object({
|
|
96
|
+
doc: SysProMDocument,
|
|
97
|
+
oldId: z.string().describe("Current node ID"),
|
|
98
|
+
newId: z.string().describe("New node ID"),
|
|
99
|
+
}),
|
|
100
|
+
output: SysProMDocument,
|
|
101
|
+
fn({ doc, oldId, newId }) {
|
|
102
|
+
// Check old ID exists
|
|
103
|
+
const node = doc.nodes.find((n) => n.id === oldId);
|
|
104
|
+
if (!node) {
|
|
105
|
+
throw new Error(`Node not found: ${oldId}`);
|
|
106
|
+
}
|
|
107
|
+
// Check new ID doesn't already exist
|
|
108
|
+
if (doc.nodes.some((n) => n.id === newId)) {
|
|
109
|
+
throw new Error(`Node already exists: ${newId}`);
|
|
110
|
+
}
|
|
111
|
+
return renameNodeId(doc, oldId, newId);
|
|
112
|
+
},
|
|
113
|
+
});
|