@stdd/plugin 0.9.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.
Files changed (80) hide show
  1. package/.claude-plugin/plugin.json +9 -0
  2. package/.codex-plugin/plugin.json +21 -0
  3. package/LICENSE +21 -0
  4. package/README.md +47 -0
  5. package/extensions/stdd.mjs +77 -0
  6. package/hooks/claude-hooks.json +28 -0
  7. package/hooks/codex-hooks.json +28 -0
  8. package/package.json +38 -0
  9. package/runtime/adapters/README.md +158 -0
  10. package/runtime/cli/check.mjs +555 -0
  11. package/runtime/cli/ci.mjs +190 -0
  12. package/runtime/cli/claude-hooks.mjs +689 -0
  13. package/runtime/cli/config.mjs +27 -0
  14. package/runtime/cli/evidence.mjs +249 -0
  15. package/runtime/cli/generated-files.mjs +1693 -0
  16. package/runtime/cli/held-fs.mjs +415 -0
  17. package/runtime/cli/init.mjs +883 -0
  18. package/runtime/cli/ledger.mjs +1470 -0
  19. package/runtime/cli/lib.mjs +909 -0
  20. package/runtime/cli/path-bytes.mjs +83 -0
  21. package/runtime/cli/policy.mjs +112 -0
  22. package/runtime/cli/recorders.mjs +188 -0
  23. package/runtime/cli/review-fs.mjs +825 -0
  24. package/runtime/cli/review.mjs +1065 -0
  25. package/runtime/cli/runtime.mjs +32 -0
  26. package/runtime/cli/scope.mjs +185 -0
  27. package/runtime/cli/snapshot.mjs +897 -0
  28. package/runtime/cli/state-validation.mjs +168 -0
  29. package/runtime/cli/status.mjs +580 -0
  30. package/runtime/cli/stdd.mjs +536 -0
  31. package/runtime/cli/worker-fs.mjs +971 -0
  32. package/runtime/cli/worker-metadata.mjs +139 -0
  33. package/runtime/cli/worker.mjs +779 -0
  34. package/runtime/method/README.md +634 -0
  35. package/runtime/method/reference-commands.md +147 -0
  36. package/runtime/method/reference-generated-state.md +151 -0
  37. package/runtime/method/reference-integration.md +233 -0
  38. package/runtime/package.json +65 -0
  39. package/runtime/playbooks/brainstorming.md +46 -0
  40. package/runtime/playbooks/debugging.md +36 -0
  41. package/runtime/playbooks/delegate-slice.md +129 -0
  42. package/runtime/playbooks/finish-change.md +46 -0
  43. package/runtime/playbooks/implement.md +26 -0
  44. package/runtime/playbooks/investigation.md +33 -0
  45. package/runtime/playbooks/managed-playbooks.json +14 -0
  46. package/runtime/playbooks/planning.md +177 -0
  47. package/runtime/playbooks/pr-green.md +50 -0
  48. package/runtime/playbooks/start-change.md +37 -0
  49. package/runtime/playbooks/worktrees.md +45 -0
  50. package/runtime/prebuilds/stdd-fs/darwin-arm64/stdd-fs +0 -0
  51. package/runtime/prebuilds/stdd-fs/darwin-x64/stdd-fs +0 -0
  52. package/runtime/prebuilds/stdd-fs/linux-arm64/stdd-fs +0 -0
  53. package/runtime/prebuilds/stdd-fs/linux-x64/stdd-fs +0 -0
  54. package/runtime/prebuilds/stdd-fs/manifest.json +47 -0
  55. package/runtime/prebuilds/stdd-fs/win32-arm64/stdd-fs.exe +0 -0
  56. package/runtime/prebuilds/stdd-fs/win32-x64/stdd-fs.exe +0 -0
  57. package/runtime/sdk/adapters.mjs +279 -0
  58. package/runtime/sdk/file-observation.mjs +12 -0
  59. package/runtime/sdk/index.d.ts +140 -0
  60. package/runtime/sdk/index.mjs +31 -0
  61. package/runtime/sdk/native-fs.mjs +1235 -0
  62. package/runtime/sdk/path.mjs +71 -0
  63. package/runtime/sdk/text.mjs +42 -0
  64. package/runtime/sdk/workflow.mjs +294 -0
  65. package/runtime/templates/deferred-design.md +47 -0
  66. package/runtime/templates/github-stdd.yml +42 -0
  67. package/runtime/templates/gitlab-stdd.yml +72 -0
  68. package/runtime/templates/pr-description.md +35 -0
  69. package/scripts/adopting-root.mjs +42 -0
  70. package/scripts/stdd-hook.mjs +72 -0
  71. package/skills/stdd-brainstorming/SKILL.md +48 -0
  72. package/skills/stdd-debugging/SKILL.md +38 -0
  73. package/skills/stdd-delegate-slice/SKILL.md +118 -0
  74. package/skills/stdd-finish-change/SKILL.md +40 -0
  75. package/skills/stdd-implement/SKILL.md +28 -0
  76. package/skills/stdd-investigation/SKILL.md +35 -0
  77. package/skills/stdd-planning/SKILL.md +165 -0
  78. package/skills/stdd-pr-green/SKILL.md +52 -0
  79. package/skills/stdd-start-change/SKILL.md +39 -0
  80. package/skills/stdd-worktrees/SKILL.md +46 -0
@@ -0,0 +1,168 @@
1
+ // Structural predicates shared by every durable state document stdd writes:
2
+ // the session ledger, the managed-worker metadata, and the install manifest.
3
+ import path from "node:path";
4
+ import { isPrintableSingleLine } from "../sdk/text.mjs";
5
+
6
+ export const MANIFEST_HASH_PATTERN = /^sha256:[0-9a-f]{64}$/u;
7
+
8
+ export function isPlainLedgerRecord(value) {
9
+ return typeof value === "object" && value !== null && !Array.isArray(value);
10
+ }
11
+
12
+ export function isLedgerStringArray(value) {
13
+ return Array.isArray(value) && value.every(isPrintableSingleLine);
14
+ }
15
+
16
+ export function isReviewInodeIdentity(value) {
17
+ return (
18
+ typeof value === "object" &&
19
+ value !== null &&
20
+ !Array.isArray(value) &&
21
+ Object.keys(value).sort().join(",") === "dev,ino,mode,nlink,uid" &&
22
+ ["dev", "ino", "uid", "mode", "nlink"].every((field) => /^(?:0|[1-9][0-9]*)$/.test(value[field]))
23
+ );
24
+ }
25
+
26
+ const REVIEW_PORTABLE_IDENTITY_FIELDS = ["fileId", "kind", "platform", "version", "volume"];
27
+ const REVIEW_PORTABLE_OBSERVATION_FIELDS = ["identity", "linkCount", "owner", "permissions"];
28
+
29
+ function exactObjectFields(value, fields) {
30
+ return (
31
+ typeof value === "object" &&
32
+ value !== null &&
33
+ !Array.isArray(value) &&
34
+ Object.keys(value).sort().join(",") === [...fields].sort().join(",")
35
+ );
36
+ }
37
+
38
+ function unsignedDecimal(value) {
39
+ return typeof value === "string" && /^(?:0|[1-9][0-9]*)$/.test(value);
40
+ }
41
+
42
+ function normalizedReviewTempRootPath(value, platform) {
43
+ if (typeof value !== "string" || !["linux", "darwin", "win32"].includes(platform)) return null;
44
+ const pathApi = platform === "win32" ? path.win32 : path.posix;
45
+ if (!pathApi.isAbsolute(value)) return null;
46
+ let normalized = pathApi.normalize(value);
47
+ if (platform === "win32") {
48
+ normalized = normalized.replace(/^([a-z]):/u, (_, drive) => `${drive.toUpperCase()}:`);
49
+ }
50
+ return value === normalized ? normalized : null;
51
+ }
52
+
53
+ function isReviewPortableObservation(value, kind, privateRequired = true) {
54
+ if (!exactObjectFields(value, REVIEW_PORTABLE_OBSERVATION_FIELDS)) return false;
55
+ const identity = value.identity;
56
+ if (
57
+ !exactObjectFields(identity, REVIEW_PORTABLE_IDENTITY_FIELDS) ||
58
+ identity.version !== 2 ||
59
+ !["linux", "darwin", "win32"].includes(identity.platform) ||
60
+ identity.kind !== kind ||
61
+ !unsignedDecimal(identity.volume) ||
62
+ !(identity.platform === "win32"
63
+ ? typeof identity.fileId === "string" && /^[0-9a-f]{32}$/.test(identity.fileId)
64
+ : unsignedDecimal(identity.fileId)) ||
65
+ !unsignedDecimal(value.linkCount)
66
+ ) {
67
+ return false;
68
+ }
69
+ return identity.platform === "win32"
70
+ ? typeof value.owner === "string" &&
71
+ /^S-(?:[0-9]+-)+[0-9]+$/.test(value.owner) &&
72
+ (privateRequired
73
+ ? /^O:([^:]+)D:P\(A;;FA;;;\1\)\(A;;FA;;;SY\)\(A;;FA;;;BA\)$/.test(value.permissions)
74
+ : value.permissions.startsWith("O:") && value.permissions.includes("D:"))
75
+ : unsignedDecimal(value.owner) && unsignedDecimal(value.permissions);
76
+ }
77
+
78
+ function sameReviewPortableObservation(left, right, kind, privateRequired = true) {
79
+ return (
80
+ isReviewPortableObservation(left, kind, privateRequired) &&
81
+ isReviewPortableObservation(right, kind, privateRequired) &&
82
+ REVIEW_PORTABLE_OBSERVATION_FIELDS.every((field) =>
83
+ field === "identity"
84
+ ? REVIEW_PORTABLE_IDENTITY_FIELDS.every(
85
+ (identityField) => left.identity[identityField] === right.identity[identityField],
86
+ )
87
+ : left[field] === right[field],
88
+ )
89
+ );
90
+ }
91
+
92
+ export function sameReviewPrivateState(left, right) {
93
+ const leftFields =
94
+ left?.version === 2
95
+ ? "artifacts,directory,tempRoot,tempRootPath,version"
96
+ : "artifacts,directory,tempRoot,version";
97
+ const rightFields =
98
+ right?.version === 2
99
+ ? "artifacts,directory,tempRoot,tempRootPath,version"
100
+ : "artifacts,directory,tempRoot,version";
101
+ if (
102
+ typeof left !== "object" ||
103
+ left === null ||
104
+ typeof right !== "object" ||
105
+ right === null ||
106
+ Object.keys(left).sort().join(",") !== leftFields ||
107
+ Object.keys(right).sort().join(",") !== rightFields ||
108
+ left.version !== right.version ||
109
+ ![1, 2].includes(left.version) ||
110
+ typeof left.artifacts !== "object" ||
111
+ left.artifacts === null ||
112
+ Array.isArray(left.artifacts) ||
113
+ typeof right.artifacts !== "object" ||
114
+ right.artifacts === null ||
115
+ Array.isArray(right.artifacts)
116
+ ) {
117
+ return false;
118
+ }
119
+ if (left.version === 2) {
120
+ if (
121
+ left.tempRoot?.identity?.platform !== right.tempRoot?.identity?.platform ||
122
+ normalizedReviewTempRootPath(left.tempRootPath, left.tempRoot?.identity?.platform) === null ||
123
+ normalizedReviewTempRootPath(right.tempRootPath, right.tempRoot?.identity?.platform) === null ||
124
+ left.tempRootPath !== right.tempRootPath ||
125
+ !sameReviewPortableObservation(left.tempRoot, right.tempRoot, "directory", false) ||
126
+ !sameReviewPortableObservation(left.directory, right.directory, "directory")
127
+ ) {
128
+ return false;
129
+ }
130
+ } else if (
131
+ !isReviewInodeIdentity(left.tempRoot) ||
132
+ !isReviewInodeIdentity(right.tempRoot) ||
133
+ !isReviewInodeIdentity(left.directory) ||
134
+ !isReviewInodeIdentity(right.directory) ||
135
+ ["tempRoot", "directory"].some((identity) =>
136
+ ["dev", "ino", "uid", "mode", "nlink"].some(
137
+ (field) => left[identity][field] !== right[identity][field],
138
+ ),
139
+ )
140
+ ) {
141
+ return false;
142
+ }
143
+ const leftArtifacts = left.artifacts;
144
+ const rightArtifacts = right.artifacts;
145
+ const leftDirectoryOwner = left.version === 2 ? left.directory.owner : left.directory.uid;
146
+ const rightDirectoryOwner = right.version === 2 ? right.directory.owner : right.directory.uid;
147
+ const leftNames = Object.keys(leftArtifacts).sort();
148
+ const rightNames = Object.keys(rightArtifacts).sort();
149
+ if (
150
+ leftNames.length !== rightNames.length ||
151
+ leftNames.some((name, index) => name !== rightNames[index])
152
+ ) {
153
+ return false;
154
+ }
155
+ return leftNames.every((name) =>
156
+ left.version === 2
157
+ ? leftArtifacts[name]?.owner === leftDirectoryOwner &&
158
+ rightArtifacts[name]?.owner === rightDirectoryOwner &&
159
+ sameReviewPortableObservation(leftArtifacts[name], rightArtifacts[name], "file")
160
+ : isReviewInodeIdentity(leftArtifacts[name]) &&
161
+ isReviewInodeIdentity(rightArtifacts[name]) &&
162
+ leftArtifacts[name].uid === leftDirectoryOwner &&
163
+ rightArtifacts[name].uid === rightDirectoryOwner &&
164
+ ["dev", "ino", "uid", "mode", "nlink"].every(
165
+ (field) => leftArtifacts[name][field] === rightArtifacts[name][field],
166
+ ),
167
+ );
168
+ }