@peterxiaoyang/superspec 0.1.14 → 0.1.15-alpha

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 (126) hide show
  1. package/dist/cli.d.ts +2 -0
  2. package/dist/cli.js +302 -0
  3. package/dist/format.d.ts +29 -0
  4. package/dist/format.js +141 -0
  5. package/dist/next.d.ts +3 -0
  6. package/dist/next.js +161 -0
  7. package/dist/openspec.d.ts +9 -0
  8. package/dist/openspec.js +41 -0
  9. package/dist/record.d.ts +20 -0
  10. package/dist/record.js +211 -0
  11. package/dist/skill_loop.d.ts +23 -0
  12. package/dist/skill_loop.js +58 -0
  13. package/dist/store.d.ts +31 -0
  14. package/dist/store.js +213 -0
  15. package/dist/sync.d.ts +3 -0
  16. package/dist/sync.js +135 -0
  17. package/dist/task.d.ts +7 -0
  18. package/dist/task.js +44 -0
  19. package/dist/transition.d.ts +34 -0
  20. package/dist/transition.js +400 -0
  21. package/dist/types.d.ts +138 -0
  22. package/dist/types.js +3 -0
  23. package/package.json +8 -53
  24. package/templates/workflow/skills/superspec-apply/SKILL.md +46 -118
  25. package/templates/workflow/skills/superspec-archive/SKILL.md +22 -47
  26. package/templates/workflow/skills/superspec-explore/SKILL.md +38 -69
  27. package/templates/workflow/skills/superspec-propose/SKILL.md +58 -60
  28. package/templates/workflow/skills/superspec-review/SKILL.md +36 -81
  29. package/adapters/codex/agents/architect.toml +0 -13
  30. package/adapters/codex/agents/code-reviewer.toml +0 -13
  31. package/adapters/codex/agents/critic.toml +0 -13
  32. package/adapters/codex/agents/executor.toml +0 -13
  33. package/adapters/codex/agents/explore.toml +0 -13
  34. package/adapters/codex/agents/test-engineer.toml +0 -13
  35. package/adapters/codex/agents/test-runner.toml +0 -13
  36. package/adapters/codex/agents/verifier.toml +0 -13
  37. package/adapters/codex/install-map.json +0 -116
  38. package/bin/launch.js +0 -37
  39. package/bin/superspec-check.js +0 -4
  40. package/bin/superspec-hook.js +0 -4
  41. package/bin/superspec-init.js +0 -4
  42. package/bin/superspec.js +0 -4
  43. package/dist/src/apply_worker_chain.d.ts +0 -60
  44. package/dist/src/apply_worker_chain.js +0 -1283
  45. package/dist/src/apply_worker_chain_lifecycle.d.ts +0 -21
  46. package/dist/src/apply_worker_chain_lifecycle.js +0 -409
  47. package/dist/src/archive.d.ts +0 -23
  48. package/dist/src/archive.js +0 -430
  49. package/dist/src/cli.d.ts +0 -1
  50. package/dist/src/cli.js +0 -33
  51. package/dist/src/cli_args.d.ts +0 -32
  52. package/dist/src/cli_args.js +0 -454
  53. package/dist/src/core.d.ts +0 -20
  54. package/dist/src/core.js +0 -394
  55. package/dist/src/disclosure.d.ts +0 -35
  56. package/dist/src/disclosure.js +0 -671
  57. package/dist/src/doctor.d.ts +0 -44
  58. package/dist/src/doctor.js +0 -230
  59. package/dist/src/evidence.d.ts +0 -29
  60. package/dist/src/evidence.js +0 -1107
  61. package/dist/src/gates.d.ts +0 -19
  62. package/dist/src/gates.js +0 -1631
  63. package/dist/src/git.d.ts +0 -8
  64. package/dist/src/git.js +0 -112
  65. package/dist/src/hooks/adapter.d.ts +0 -5
  66. package/dist/src/hooks/adapter.js +0 -347
  67. package/dist/src/hooks/guard_api.d.ts +0 -12
  68. package/dist/src/hooks/guard_api.js +0 -797
  69. package/dist/src/hooks/health.d.ts +0 -4
  70. package/dist/src/hooks/health.js +0 -86
  71. package/dist/src/hooks/policy_event.d.ts +0 -41
  72. package/dist/src/hooks/policy_event.js +0 -2634
  73. package/dist/src/hooks/types.d.ts +0 -72
  74. package/dist/src/hooks/types.js +0 -1
  75. package/dist/src/hooks/validation.d.ts +0 -3
  76. package/dist/src/hooks/validation.js +0 -70
  77. package/dist/src/i18n.d.ts +0 -21
  78. package/dist/src/i18n.js +0 -720
  79. package/dist/src/init_cli.d.ts +0 -28
  80. package/dist/src/init_cli.js +0 -404
  81. package/dist/src/install_engine.d.ts +0 -71
  82. package/dist/src/install_engine.js +0 -538
  83. package/dist/src/invariants.d.ts +0 -16
  84. package/dist/src/invariants.js +0 -363
  85. package/dist/src/openspec.d.ts +0 -37
  86. package/dist/src/openspec.js +0 -274
  87. package/dist/src/packet_render.d.ts +0 -5
  88. package/dist/src/packet_render.js +0 -1767
  89. package/dist/src/packet_schema.d.ts +0 -59
  90. package/dist/src/packet_schema.js +0 -1
  91. package/dist/src/paths.d.ts +0 -22
  92. package/dist/src/paths.js +0 -203
  93. package/dist/src/project_init.d.ts +0 -33
  94. package/dist/src/project_init.js +0 -191
  95. package/dist/src/self_update.d.ts +0 -14
  96. package/dist/src/self_update.js +0 -56
  97. package/dist/src/state.d.ts +0 -37
  98. package/dist/src/state.js +0 -464
  99. package/dist/src/tasks.d.ts +0 -38
  100. package/dist/src/tasks.js +0 -373
  101. package/dist/src/util.d.ts +0 -163
  102. package/dist/src/util.js +0 -792
  103. package/dist/superspec.d.ts +0 -6
  104. package/dist/superspec.js +0 -97
  105. package/dist/superspec_guard.d.ts +0 -4
  106. package/dist/superspec_guard.js +0 -19
  107. package/dist/superspec_hook.d.ts +0 -4
  108. package/dist/superspec_hook.js +0 -35
  109. package/dist/superspec_init.d.ts +0 -2
  110. package/dist/superspec_init.js +0 -17
  111. package/schemas/hook-event.schema.json +0 -27
  112. package/schemas/install-manifest.schema.json +0 -97
  113. package/templates/hooks/codex-hooks.json +0 -35
  114. package/templates/sidecar/archive-preservation.json +0 -11
  115. package/templates/sidecar/business-invariants.md +0 -38
  116. package/templates/sidecar/config.yaml +0 -13
  117. package/templates/sidecar/discovery.md +0 -33
  118. package/templates/sidecar/test-contract.md +0 -27
  119. package/templates/workflow/prompts/architect.md +0 -27
  120. package/templates/workflow/prompts/code-reviewer.md +0 -34
  121. package/templates/workflow/prompts/critic.md +0 -30
  122. package/templates/workflow/prompts/executor.md +0 -32
  123. package/templates/workflow/prompts/explore.md +0 -27
  124. package/templates/workflow/prompts/test-engineer.md +0 -28
  125. package/templates/workflow/prompts/test-runner.md +0 -35
  126. package/templates/workflow/prompts/verifier.md +0 -35
@@ -1,44 +0,0 @@
1
- import { type JsonMap } from "./util.ts";
2
- type RunResult = {
3
- status: number | null;
4
- stdout: string;
5
- stderr: string;
6
- error?: Error;
7
- };
8
- type RunFn = (cmd: string, args: string[], opts?: {
9
- cwd?: string;
10
- timeout?: number;
11
- platform?: NodeJS.Platform;
12
- }) => RunResult;
13
- type CommandExistsFn = (cmd: string, meta?: {
14
- cwd?: string;
15
- }) => boolean;
16
- type CheckStatus = "ok" | "warn" | "fail";
17
- export type DoctorCheck = {
18
- status: CheckStatus;
19
- name: string;
20
- detail: string;
21
- refs?: string[];
22
- };
23
- export type DoctorReport = {
24
- ok: boolean;
25
- cwd: string;
26
- superspec: JsonMap;
27
- node: JsonMap;
28
- npm: JsonMap;
29
- openspec: JsonMap;
30
- checks: DoctorCheck[];
31
- next_actions: string[];
32
- };
33
- export declare function superspec_package_version(packageRoot?: string): string;
34
- export declare function build_doctor_report(opts?: {
35
- cwd?: string;
36
- packageRoot?: string;
37
- argv0?: string;
38
- platform?: NodeJS.Platform;
39
- commandExistsFn?: CommandExistsFn;
40
- run?: RunFn;
41
- }): DoctorReport;
42
- export declare function render_doctor_report(report: DoctorReport): string;
43
- export declare function main_doctor(argv?: string[]): number;
44
- export {};
@@ -1,230 +0,0 @@
1
- import { existsSync, lstatSync, readFileSync, readlinkSync, realpathSync } from "node:fs";
2
- import { join, resolve } from "node:path";
3
- import { PACKAGE_ROOT } from "./install_engine.js";
4
- import { openspec_cli_probe } from "./openspec.js";
5
- import { commandExists, runCommand } from "./util.js";
6
- function readPackageJson(packageRoot) {
7
- try {
8
- const parsed = JSON.parse(readFileSync(join(packageRoot, "package.json"), "utf8"));
9
- return parsed && typeof parsed === "object" ? parsed : {};
10
- }
11
- catch {
12
- return {};
13
- }
14
- }
15
- export function superspec_package_version(packageRoot = PACKAGE_ROOT) {
16
- const version = readPackageJson(packageRoot).version;
17
- return typeof version === "string" && version ? version : "0.0.0";
18
- }
19
- function realpathMaybe(filePath) {
20
- try {
21
- return realpathSync(filePath);
22
- }
23
- catch {
24
- return resolve(filePath);
25
- }
26
- }
27
- function pathInfo(filePath) {
28
- if (!filePath)
29
- return null;
30
- const info = { path: filePath, exists: existsSync(filePath) };
31
- if (!info.exists)
32
- return info;
33
- try {
34
- const stat = lstatSync(filePath);
35
- info.kind = stat.isSymbolicLink() ? "symlink" : stat.isDirectory() ? "directory" : stat.isFile() ? "file" : "other";
36
- if (stat.isSymbolicLink())
37
- info.link_target = readlinkSync(filePath);
38
- info.realpath = realpathMaybe(filePath);
39
- }
40
- catch (err) {
41
- info.error = err.message;
42
- }
43
- return info;
44
- }
45
- function firstNonEmptyLine(text) {
46
- return text.split(/\r?\n/u).map((line) => line.trim()).find((line) => line.length > 0) ?? null;
47
- }
48
- function commandPath(cmd, opts) {
49
- if (!opts.commandExistsFn(cmd, { cwd: opts.cwd }))
50
- return null;
51
- const proc = opts.platform === "win32"
52
- ? opts.run("where.exe", [cmd], { cwd: opts.cwd, timeout: 15_000, platform: opts.platform })
53
- : opts.run("sh", ["-c", `command -v ${cmd}`], { cwd: opts.cwd, timeout: 15_000, platform: opts.platform });
54
- if (proc.error || proc.status !== 0)
55
- return null;
56
- return firstNonEmptyLine(proc.stdout);
57
- }
58
- function npmValue(args, opts) {
59
- if (!opts.commandExistsFn("npm", { cwd: opts.cwd }))
60
- return { available: false, value: null, error: "npm not found on PATH" };
61
- const proc = opts.run("npm", args, { cwd: opts.cwd, timeout: 15_000, platform: opts.platform });
62
- if (proc.error || proc.status !== 0) {
63
- return {
64
- available: true,
65
- value: null,
66
- error: (proc.error?.message ?? (proc.stderr || proc.stdout)).trim(),
67
- };
68
- }
69
- return { available: true, value: firstNonEmptyLine(proc.stdout), error: null };
70
- }
71
- function containsUnscopedSuperspecNodeModule(value) {
72
- if (!value)
73
- return false;
74
- return /[/\\]node_modules[/\\]superspec[/\\]/u.test(value);
75
- }
76
- function add(checks, status, name, detail, refs) {
77
- checks.push({ status, name, detail, refs });
78
- }
79
- export function build_doctor_report(opts = {}) {
80
- const cwd = resolve(opts.cwd ?? process.cwd());
81
- const packageRoot = opts.packageRoot ?? PACKAGE_ROOT;
82
- const platform = opts.platform ?? process.platform;
83
- const run = opts.run ?? runCommand;
84
- const commandExistsFn = opts.commandExistsFn ?? ((cmd, meta) => commandExists(cmd, { cwd: meta?.cwd, platform }));
85
- const packageJson = readPackageJson(packageRoot);
86
- const version = superspec_package_version(packageRoot);
87
- const packageName = typeof packageJson.name === "string" ? packageJson.name : "unknown";
88
- const expectedBin = join(packageRoot, "bin", "superspec.js");
89
- const resolvedCommand = commandPath("superspec", { cwd, platform, commandExistsFn, run });
90
- const command = pathInfo(resolvedCommand);
91
- const prefix = npmValue(["prefix", "-g"], { cwd, platform, commandExistsFn, run });
92
- const root = npmValue(["root", "-g"], { cwd, platform, commandExistsFn, run });
93
- const npmRoot = typeof root.value === "string" ? root.value : null;
94
- const scopedPackage = npmRoot ? pathInfo(join(npmRoot, "@peterxiaoyang", "superspec")) : null;
95
- const unscopedPackage = npmRoot ? pathInfo(join(npmRoot, "superspec")) : null;
96
- const openspecProbe = openspec_cli_probe({ cwd, commandExistsFn, run });
97
- const checks = [];
98
- const nextActions = [];
99
- if (packageName === "@peterxiaoyang/superspec" && version !== "0.0.0") {
100
- add(checks, "ok", "package metadata", `${packageName}@${version}`);
101
- }
102
- else {
103
- add(checks, "fail", "package metadata", `could not identify @peterxiaoyang/superspec package metadata under ${packageRoot}`);
104
- }
105
- if (openspecProbe.ok) {
106
- add(checks, "ok", "OpenSpec CLI", openspecProbe.message);
107
- }
108
- else {
109
- add(checks, "fail", "OpenSpec CLI", openspecProbe.message);
110
- nextActions.push("npm install -g @fission-ai/openspec@latest");
111
- }
112
- if (!command) {
113
- add(checks, "warn", "superspec command", "`superspec` is not resolvable from PATH in this shell");
114
- }
115
- else {
116
- const commandRealpath = typeof command.realpath === "string" ? command.realpath : undefined;
117
- const commandTarget = typeof command.link_target === "string" ? command.link_target : undefined;
118
- if (containsUnscopedSuperspecNodeModule(commandRealpath) || containsUnscopedSuperspecNodeModule(commandTarget)) {
119
- add(checks, "fail", "superspec command owner", "`superspec` points at the unscoped `superspec` package, which conflicts with @peterxiaoyang/superspec", [String(command.path)]);
120
- nextActions.push("npm uninstall -g superspec");
121
- nextActions.push("npm install -g @peterxiaoyang/superspec@latest");
122
- }
123
- else if (existsSync(expectedBin) && commandRealpath && realpathMaybe(expectedBin) !== commandRealpath) {
124
- add(checks, "warn", "superspec command owner", "`superspec` on PATH does not point at this package root", [String(command.path), expectedBin]);
125
- }
126
- else {
127
- add(checks, "ok", "superspec command owner", "`superspec` resolves to this package");
128
- }
129
- }
130
- if (root.error) {
131
- add(checks, "warn", "npm global root", String(root.error));
132
- }
133
- else if (npmRoot) {
134
- add(checks, "ok", "npm global root", npmRoot);
135
- }
136
- if (unscopedPackage?.exists) {
137
- add(checks, "warn", "unscoped superspec package", "global package `superspec` is installed and can claim the same `superspec` binary", [String(unscopedPackage.path)]);
138
- nextActions.push("npm uninstall -g superspec");
139
- }
140
- if (scopedPackage && !scopedPackage.exists) {
141
- add(checks, "warn", "scoped superspec package", "@peterxiaoyang/superspec is not present under npm global root", [String(scopedPackage.path)]);
142
- }
143
- const dedupedNextActions = [...new Set(nextActions)];
144
- return {
145
- ok: !checks.some((check) => check.status === "fail"),
146
- cwd,
147
- superspec: {
148
- name: packageName,
149
- version,
150
- package_root: packageRoot,
151
- expected_bin: expectedBin,
152
- entry: opts.argv0 ?? process.argv[1] ?? null,
153
- command,
154
- scoped_global_package: scopedPackage,
155
- unscoped_global_package: unscopedPackage,
156
- },
157
- node: {
158
- version: process.versions.node,
159
- exec_path: process.execPath,
160
- platform,
161
- },
162
- npm: {
163
- prefix,
164
- root,
165
- },
166
- openspec: {
167
- ok: openspecProbe.ok,
168
- state: openspecProbe.state,
169
- version: openspecProbe.version,
170
- message: openspecProbe.message,
171
- },
172
- checks,
173
- next_actions: dedupedNextActions,
174
- };
175
- }
176
- export function render_doctor_report(report) {
177
- const lines = [
178
- "SuperSpec doctor",
179
- "",
180
- `SuperSpec: ${report.superspec.name}@${report.superspec.version}`,
181
- `Package root: ${report.superspec.package_root}`,
182
- `Command path: ${report.superspec.command?.path ?? "not found"}`,
183
- `OpenSpec: ${report.openspec.message}`,
184
- `Node: ${report.node.version} (${report.node.platform})`,
185
- `npm prefix: ${report.npm.prefix.value ?? "unknown"}`,
186
- `npm root: ${report.npm.root.value ?? "unknown"}`,
187
- "",
188
- "Checks:",
189
- ...report.checks.map((check) => {
190
- const refs = check.refs && check.refs.length > 0 ? ` (${check.refs.join(", ")})` : "";
191
- return ` [${check.status}] ${check.name}: ${check.detail}${refs}`;
192
- }),
193
- ];
194
- if (report.next_actions.length > 0) {
195
- lines.push("", "Next actions:", ...report.next_actions.map((action) => ` ${action}`));
196
- }
197
- lines.push("");
198
- return lines.join("\n");
199
- }
200
- function doctorHelp() {
201
- return [
202
- "usage: superspec doctor [--json]",
203
- "",
204
- "diagnoses SuperSpec, OpenSpec, npm global package, and PATH wiring.",
205
- "",
206
- "options:",
207
- " --json print machine-readable JSON",
208
- " -h, --help show this help",
209
- "",
210
- ].join("\n");
211
- }
212
- export function main_doctor(argv = process.argv.slice(2)) {
213
- if (argv.includes("-h") || argv.includes("--help")) {
214
- process.stdout.write(doctorHelp());
215
- return 0;
216
- }
217
- const unknown = argv.filter((arg) => arg !== "--json");
218
- if (unknown.length > 0) {
219
- process.stderr.write(`superspec doctor: unknown option ${JSON.stringify(unknown[0])}\n\n${doctorHelp()}`);
220
- return 2;
221
- }
222
- const report = build_doctor_report();
223
- if (argv.includes("--json")) {
224
- process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
225
- }
226
- else {
227
- process.stdout.write(render_doctor_report(report));
228
- }
229
- return report.ok ? 0 : 1;
230
- }
@@ -1,29 +0,0 @@
1
- import type { JsonMap, Reason } from "./util.ts";
2
- export declare function role_target_ref_reasons(ev: JsonMap, targetRoot: string): Reason[];
3
- export declare function loaded_ref_reasons(ev: JsonMap, repoRoot: string): Reason[];
4
- export declare function verify_reference_reasons(changeRoot: string, ev: JsonMap, evidences: JsonMap[]): Reason[];
5
- export declare function is_final_verification_only_evidence(ev: JsonMap): boolean;
6
- export declare function final_verification_evidences(evidences: JsonMap[]): JsonMap[];
7
- export declare function index_evidence(changeRoot: string): JsonMap[];
8
- export declare function evidence_fingerprint(changeRoot: string): string;
9
- export declare function validate_evidence_schema(ev: JsonMap, change: string, changeRoot: string, repoRoot: string): Reason[];
10
- export declare function code_review_lane_evidence_reasons(ev: JsonMap, evidences: JsonMap[]): Reason[];
11
- export declare function pass_task_reopens(evidences: JsonMap[], taskId?: string | null): JsonMap[];
12
- export declare function live_task_reopens(evidences: JsonMap[], taskId?: string | null): JsonMap[];
13
- export declare function live_task_reopen_resolutions(evidences: JsonMap[], taskId?: string | null): JsonMap[];
14
- export declare function unresolved_live_task_reopens(evidences: JsonMap[], taskId?: string | null): JsonMap[];
15
- export declare function find_pass(evidences: JsonMap[], filters?: {
16
- gate?: string | null;
17
- kind?: string | null;
18
- task_id?: string | null;
19
- }): JsonMap[];
20
- export declare function superseded_ids(evidences: JsonMap[]): Set<string>;
21
- export declare function duplicate_evidence_id_reasons(evidences: JsonMap[]): Reason[];
22
- export declare function dangling_evidence_ref_reasons(evidences: JsonMap[]): Reason[];
23
- export declare function supersede_reasons(evidences: JsonMap[]): Reason[];
24
- export declare function live_pass(evidences: JsonMap[], filters?: {
25
- gate?: string | null;
26
- kind?: string | null;
27
- task_id?: string | null;
28
- }): JsonMap[];
29
- export declare function live_user_confirmations(evidences: JsonMap[], gate: string): JsonMap[];