@spexcode/spec-cli 0.6.5

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 (201) hide show
  1. package/README.md +95 -0
  2. package/bin/spex.mjs +76 -0
  3. package/dist/attach.d.ts +2 -0
  4. package/dist/attach.js +48 -0
  5. package/dist/claude-headless.d.ts +33 -0
  6. package/dist/claude-headless.js +307 -0
  7. package/dist/cli.d.ts +1 -0
  8. package/dist/cli.js +1859 -0
  9. package/dist/client.d.ts +111 -0
  10. package/dist/client.js +476 -0
  11. package/dist/cockpit.d.ts +7 -0
  12. package/dist/cockpit.js +26 -0
  13. package/dist/codex-headless.d.ts +1 -0
  14. package/dist/codex-headless.js +7 -0
  15. package/dist/codex-runtime-generations.d.ts +53 -0
  16. package/dist/codex-runtime-generations.js +686 -0
  17. package/dist/commit-surgery.d.ts +1 -0
  18. package/dist/commit-surgery.js +90 -0
  19. package/dist/contract-filter.d.ts +14 -0
  20. package/dist/contract-filter.js +219 -0
  21. package/dist/dashboard-assets.d.ts +6 -0
  22. package/dist/dashboard-assets.js +50 -0
  23. package/dist/delivery-queue.d.ts +23 -0
  24. package/dist/delivery-queue.js +179 -0
  25. package/dist/doctor.d.ts +9 -0
  26. package/dist/doctor.js +547 -0
  27. package/dist/eval-host.d.ts +1 -0
  28. package/dist/eval-host.js +19 -0
  29. package/dist/execution-trace.d.ts +26 -0
  30. package/dist/execution-trace.js +475 -0
  31. package/dist/file-write.d.ts +2 -0
  32. package/dist/file-write.js +26 -0
  33. package/dist/flat.d.ts +89 -0
  34. package/dist/flat.js +1076 -0
  35. package/dist/gateway-auth.d.ts +56 -0
  36. package/dist/gateway-auth.js +168 -0
  37. package/dist/gateway-hub.d.ts +28 -0
  38. package/dist/gateway-hub.js +361 -0
  39. package/dist/gateway.d.ts +37 -0
  40. package/dist/gateway.js +503 -0
  41. package/dist/graphCache.d.ts +27 -0
  42. package/dist/graphCache.js +716 -0
  43. package/dist/graphSnapshot.d.ts +14 -0
  44. package/dist/graphSnapshot.js +35 -0
  45. package/dist/graphStream.d.ts +85 -0
  46. package/dist/graphStream.js +1195 -0
  47. package/dist/guidance-catalog.d.ts +64 -0
  48. package/dist/guidance-catalog.js +166 -0
  49. package/dist/guide.d.ts +8 -0
  50. package/dist/guide.js +684 -0
  51. package/dist/harness-select.d.ts +18 -0
  52. package/dist/harness-select.js +62 -0
  53. package/dist/harness.d.ts +325 -0
  54. package/dist/harness.js +3026 -0
  55. package/dist/headless-controller.d.ts +9 -0
  56. package/dist/headless-controller.js +47 -0
  57. package/dist/help.d.ts +10 -0
  58. package/dist/help.js +574 -0
  59. package/dist/hook-prompts.d.ts +18 -0
  60. package/dist/hook-prompts.js +122 -0
  61. package/dist/hooks.d.ts +1 -0
  62. package/dist/hooks.js +27 -0
  63. package/dist/host-resources.d.ts +97 -0
  64. package/dist/host-resources.js +795 -0
  65. package/dist/host.d.ts +88 -0
  66. package/dist/host.js +663 -0
  67. package/dist/index.d.ts +1 -0
  68. package/dist/index.js +899 -0
  69. package/dist/init.d.ts +1 -0
  70. package/dist/init.js +284 -0
  71. package/dist/issues-cli.d.ts +6 -0
  72. package/dist/issues-cli.js +334 -0
  73. package/dist/issues.d.ts +69 -0
  74. package/dist/issues.js +189 -0
  75. package/dist/lint.d.ts +34 -0
  76. package/dist/lint.js +476 -0
  77. package/dist/listen.d.ts +7 -0
  78. package/dist/listen.js +24 -0
  79. package/dist/localIssues.d.ts +65 -0
  80. package/dist/localIssues.js +582 -0
  81. package/dist/login-page.d.ts +5 -0
  82. package/dist/login-page.js +86 -0
  83. package/dist/loop-in.d.ts +23 -0
  84. package/dist/loop-in.js +68 -0
  85. package/dist/machine-peer.d.ts +69 -0
  86. package/dist/machine-peer.js +603 -0
  87. package/dist/materialize.d.ts +18 -0
  88. package/dist/materialize.js +468 -0
  89. package/dist/mentions.d.ts +50 -0
  90. package/dist/mentions.js +117 -0
  91. package/dist/opencode-headless.d.ts +4 -0
  92. package/dist/opencode-headless.js +208 -0
  93. package/dist/opencode.d.ts +3 -0
  94. package/dist/opencode.js +142 -0
  95. package/dist/pi-harness.d.ts +3 -0
  96. package/dist/pi-harness.js +129 -0
  97. package/dist/pi-headless.d.ts +25 -0
  98. package/dist/pi-headless.js +196 -0
  99. package/dist/plugin-harness.d.ts +21 -0
  100. package/dist/plugin-harness.js +146 -0
  101. package/dist/pty-bridge.d.ts +10 -0
  102. package/dist/pty-bridge.js +404 -0
  103. package/dist/pty-helper.d.mts +1 -0
  104. package/dist/pty-helper.mjs +101 -0
  105. package/dist/pty-native-helper.d.mts +2 -0
  106. package/dist/pty-native-helper.mjs +23 -0
  107. package/dist/public-graph.d.ts +46 -0
  108. package/dist/public-graph.js +56 -0
  109. package/dist/ranker.d.ts +15 -0
  110. package/dist/ranker.js +188 -0
  111. package/dist/reaper.d.ts +6 -0
  112. package/dist/reaper.js +81 -0
  113. package/dist/reviews.d.ts +189 -0
  114. package/dist/reviews.js +350 -0
  115. package/dist/runtime-guard.d.ts +6 -0
  116. package/dist/runtime-guard.js +37 -0
  117. package/dist/runtime-ownership.d.ts +21 -0
  118. package/dist/runtime-ownership.js +84 -0
  119. package/dist/search.bench.d.mts +1 -0
  120. package/dist/search.bench.mjs +75 -0
  121. package/dist/search.d.ts +20 -0
  122. package/dist/search.js +61 -0
  123. package/dist/session-cursors.d.ts +14 -0
  124. package/dist/session-cursors.js +82 -0
  125. package/dist/session-declarations.d.ts +13 -0
  126. package/dist/session-declarations.js +126 -0
  127. package/dist/session-execution.d.ts +10 -0
  128. package/dist/session-execution.js +70 -0
  129. package/dist/session-files.d.ts +28 -0
  130. package/dist/session-files.js +130 -0
  131. package/dist/session-follow.d.ts +31 -0
  132. package/dist/session-follow.js +179 -0
  133. package/dist/session-reparent.d.ts +10 -0
  134. package/dist/session-reparent.js +33 -0
  135. package/dist/session-timeline.d.ts +51 -0
  136. package/dist/session-timeline.js +233 -0
  137. package/dist/session-web.d.ts +24 -0
  138. package/dist/session-web.js +141 -0
  139. package/dist/sessions.d.ts +412 -0
  140. package/dist/sessions.js +4239 -0
  141. package/dist/sh.d.ts +1 -0
  142. package/dist/sh.js +3 -0
  143. package/dist/shim-runtime.d.ts +1 -0
  144. package/dist/shim-runtime.js +161 -0
  145. package/dist/slash-commands.d.ts +9 -0
  146. package/dist/slash-commands.js +307 -0
  147. package/dist/source-files.d.ts +9 -0
  148. package/dist/source-files.js +113 -0
  149. package/dist/supervise.d.ts +1 -0
  150. package/dist/supervise.js +308 -0
  151. package/dist/tree.d.ts +25 -0
  152. package/dist/tree.js +98 -0
  153. package/dist/tsx-bin.d.ts +3 -0
  154. package/dist/tsx-bin.js +41 -0
  155. package/dist/uninstall.d.ts +3 -0
  156. package/dist/uninstall.js +177 -0
  157. package/dist/uploads.d.ts +36 -0
  158. package/dist/uploads.js +243 -0
  159. package/dist/worktree-sources.d.ts +1 -0
  160. package/dist/worktree-sources.js +47 -0
  161. package/hooks/compat/mark-active-0.5.2-eef1.fixture +53 -0
  162. package/hooks/compat/mark-active-sed-v0.fixture +46 -0
  163. package/hooks/dispatch.sh +105 -0
  164. package/hooks/harness.sh +272 -0
  165. package/package.json +47 -0
  166. package/templates/hooks/commit-msg +14 -0
  167. package/templates/hooks/post-checkout +25 -0
  168. package/templates/hooks/post-merge +34 -0
  169. package/templates/hooks/pre-commit +120 -0
  170. package/templates/hooks/prepare-commit-msg +35 -0
  171. package/templates/hooks/reference-transaction +105 -0
  172. package/templates/spec/project/.plugins/commands/extract/spec.md +66 -0
  173. package/templates/spec/project/.plugins/commands/regroup/spec.md +25 -0
  174. package/templates/spec/project/.plugins/commands/rename/spec.md +11 -0
  175. package/templates/spec/project/.plugins/commands/spec.md +30 -0
  176. package/templates/spec/project/.plugins/commands/supervisor/spec.md +8 -0
  177. package/templates/spec/project/.plugins/commands/tidy/spec.md +43 -0
  178. package/templates/spec/project/.plugins/core/comment-altitude/spec.md +9 -0
  179. package/templates/spec/project/.plugins/core/idle/idle.sh +15 -0
  180. package/templates/spec/project/.plugins/core/idle/spec.md +13 -0
  181. package/templates/spec/project/.plugins/core/mark-active/mark-active.sh +59 -0
  182. package/templates/spec/project/.plugins/core/mark-active/spec.md +22 -0
  183. package/templates/spec/project/.plugins/core/session-fail/fail.sh +12 -0
  184. package/templates/spec/project/.plugins/core/session-fail/spec.md +15 -0
  185. package/templates/spec/project/.plugins/core/spec-first/spec-first.sh +43 -0
  186. package/templates/spec/project/.plugins/core/spec-first/spec.md +17 -0
  187. package/templates/spec/project/.plugins/core/spec-of-file/spec-of-file.sh +66 -0
  188. package/templates/spec/project/.plugins/core/spec-of-file/spec.md +15 -0
  189. package/templates/spec/project/.plugins/core/spec.md +22 -0
  190. package/templates/spec/project/.plugins/core/stop-gate/spec.md +23 -0
  191. package/templates/spec/project/.plugins/core/stop-gate/stop-gate.sh +149 -0
  192. package/templates/spec/project/.plugins/prompts/atomic-landing/spec.md +15 -0
  193. package/templates/spec/project/.plugins/prompts/forge-link/spec.md +10 -0
  194. package/templates/spec/project/.plugins/prompts/memory-hygiene/spec.md +13 -0
  195. package/templates/spec/project/.plugins/prompts/reproduce-before-fix/spec.md +12 -0
  196. package/templates/spec/project/.plugins/prompts/spec.md +24 -0
  197. package/templates/spec/project/.plugins/skills/distill/digest.mjs +136 -0
  198. package/templates/spec/project/.plugins/skills/distill/spec.md +67 -0
  199. package/templates/spec/project/.plugins/skills/spec.md +19 -0
  200. package/templates/spec/project/.plugins/spec.md +23 -0
  201. package/templates/spec/project/spec.md +20 -0
@@ -0,0 +1,64 @@
1
+ export declare const GUIDANCE_SCHEMA_VERSION: 1;
2
+ export declare const GUIDANCE_CATALOG_SCHEMA: "spexcode.guidance-catalog/v1";
3
+ export declare const GUIDANCE_PAYLOAD_NAME: "guidance-catalog.json";
4
+ export type GuidanceKind = 'plugin' | 'help' | 'guide';
5
+ export type GuidanceSurface = 'system' | 'command' | 'hook' | 'skill' | 'agent' | 'review';
6
+ export type GuidanceContentRole = 'prompt' | 'help' | 'guide' | 'signal';
7
+ export type GuidanceSource = Readonly<{
8
+ path: string;
9
+ contentHash: string;
10
+ revision: string;
11
+ }>;
12
+ export type GuidanceEntry = Readonly<{
13
+ id: string;
14
+ kind: GuidanceKind;
15
+ surface?: GuidanceSurface;
16
+ title: string;
17
+ description: string;
18
+ contentRole: GuidanceContentRole;
19
+ content: string;
20
+ source: GuidanceSource;
21
+ runtime?: Readonly<{
22
+ path: string;
23
+ revision: string;
24
+ events: readonly string[];
25
+ order: number;
26
+ block: boolean;
27
+ }>;
28
+ }>;
29
+ export type EffectiveSystemContract = Readonly<{
30
+ content: string;
31
+ contentHash: string;
32
+ sourceEntryIds: readonly string[];
33
+ }>;
34
+ export type GuidanceBundle = Readonly<{
35
+ schemaVersion: typeof GUIDANCE_SCHEMA_VERSION;
36
+ revision: string;
37
+ entries: readonly GuidanceEntry[];
38
+ bundleHash: string;
39
+ catalogSchema: typeof GUIDANCE_CATALOG_SCHEMA;
40
+ payloadName: typeof GUIDANCE_PAYLOAD_NAME;
41
+ sourceRevision: string;
42
+ effectiveSystemContract: EffectiveSystemContract;
43
+ }>;
44
+ type GitReader = (args: string[]) => string;
45
+ export type GuidanceCatalogOptions = Readonly<{
46
+ root?: string;
47
+ revision?: string;
48
+ sourceRevision?: (path: string) => string;
49
+ gitReader?: GitReader;
50
+ }>;
51
+ /**
52
+ * Immutable product-side projection over the authoritative plugin/help/guide surfaces.
53
+ * The constructor reads existing registries and materializes one export payload at call time.
54
+ */
55
+ export declare class GuidanceCatalog {
56
+ readonly bundle: GuidanceBundle;
57
+ constructor(options?: GuidanceCatalogOptions);
58
+ entries(): readonly GuidanceEntry[];
59
+ toJSON(): GuidanceBundle;
60
+ exportJson(): string;
61
+ write(path: string): void;
62
+ }
63
+ export declare function buildGuidanceCatalog(options?: GuidanceCatalogOptions): GuidanceCatalog;
64
+ export {};
@@ -0,0 +1,166 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { writeFileSync } from 'node:fs';
3
+ import { join, relative } from 'node:path';
4
+ import { git, repoRoot } from '@spexcode/spec-core';
5
+ import { loadAgentConfig, loadConfig, loadHookConfig, loadReviewConfig, loadSkillConfig, loadSystemConfig, } from '@spexcode/spec-core';
6
+ import { helpCatalogEntries } from './help.js';
7
+ import { guideCatalogEntries } from './guide.js';
8
+ import { HookPromptCatalog, HOOK_PROMPT_SOURCE } from './hook-prompts.js';
9
+ export const GUIDANCE_SCHEMA_VERSION = 1;
10
+ export const GUIDANCE_CATALOG_SCHEMA = 'spexcode.guidance-catalog/v1';
11
+ export const GUIDANCE_PAYLOAD_NAME = 'guidance-catalog.json';
12
+ const SURFACES = [
13
+ ['agent', loadAgentConfig],
14
+ ['command', loadConfig],
15
+ ['hook', loadHookConfig],
16
+ ['review', loadReviewConfig],
17
+ ['skill', loadSkillConfig],
18
+ ['system', loadSystemConfig],
19
+ ];
20
+ const sha256 = (text) => createHash('sha256').update(text, 'utf8').digest('hex');
21
+ function freeze(value) {
22
+ if (!value || typeof value !== 'object' || Object.isFrozen(value))
23
+ return value;
24
+ for (const child of Object.values(value))
25
+ freeze(child);
26
+ return Object.freeze(value);
27
+ }
28
+ function sourcePathForPreset(preset) {
29
+ return join(preset.dir, 'spec.md').replaceAll('\\', '/');
30
+ }
31
+ function sortEntries(entries) {
32
+ return entries.sort((a, b) => {
33
+ const left = `${a.kind}\0${a.id}\0${a.surface ?? ''}\0${a.source.path}`;
34
+ const right = `${b.kind}\0${b.id}\0${b.surface ?? ''}\0${b.source.path}`;
35
+ return left < right ? -1 : left > right ? 1 : 0;
36
+ });
37
+ }
38
+ function sourceRevision(root, path, readGit) {
39
+ const result = readGit(['-C', root, 'log', '-1', '--format=%H', '--', path]).trim();
40
+ return result || 'working-tree';
41
+ }
42
+ function currentRevision(root, readGit) {
43
+ return readGit(['-C', root, 'rev-parse', 'HEAD']).trim() || 'working-tree';
44
+ }
45
+ function entrySource(root, path, text, revision, readSourceRevision) {
46
+ return { path: relative(root, join(root, path)).replaceAll('\\', '/'), contentHash: sha256(text), revision: readSourceRevision(path) || revision };
47
+ }
48
+ /**
49
+ * Immutable product-side projection over the authoritative plugin/help/guide surfaces.
50
+ * The constructor reads existing registries and materializes one export payload at call time.
51
+ */
52
+ export class GuidanceCatalog {
53
+ bundle;
54
+ constructor(options = {}) {
55
+ const root = options.root ?? repoRoot();
56
+ const readGit = options.gitReader ?? git;
57
+ const revision = options.revision ?? currentRevision(root, readGit);
58
+ const readSourceRevision = options.sourceRevision ?? ((path) => sourceRevision(root, path, readGit));
59
+ const sourceRevisions = new Map();
60
+ const sourceRevisionFor = (path) => {
61
+ const known = sourceRevisions.get(path);
62
+ if (known)
63
+ return known;
64
+ const value = readSourceRevision(path) || revision;
65
+ sourceRevisions.set(path, value);
66
+ return value;
67
+ };
68
+ const entries = [];
69
+ const hookPrompts = new HookPromptCatalog();
70
+ for (const [surface, loader] of SURFACES) {
71
+ for (const preset of loader()) {
72
+ if (surface === 'hook') {
73
+ const prompt = hookPrompts.entry(preset.name);
74
+ const handler = preset.files.find((file) => file.endsWith('.sh'));
75
+ if (!handler)
76
+ throw new Error(`surface:hook node '${preset.name}' ships no .sh script (one co-located .sh required)`);
77
+ entries.push({
78
+ id: `plugin:${surface}:${preset.name}`,
79
+ kind: 'plugin',
80
+ surface,
81
+ title: prompt.title,
82
+ description: prompt.description,
83
+ contentRole: prompt.role,
84
+ content: prompt.content,
85
+ source: entrySource(root, HOOK_PROMPT_SOURCE, prompt.content, revision, sourceRevisionFor),
86
+ runtime: {
87
+ path: handler,
88
+ revision: sourceRevisionFor(handler),
89
+ events: [...preset.events],
90
+ order: preset.order,
91
+ block: preset.block,
92
+ },
93
+ });
94
+ continue;
95
+ }
96
+ const path = sourcePathForPreset(preset);
97
+ entries.push({
98
+ id: `plugin:${surface}:${preset.name}`,
99
+ kind: 'plugin',
100
+ surface,
101
+ title: preset.title,
102
+ description: preset.desc,
103
+ contentRole: 'prompt',
104
+ content: preset.body,
105
+ source: entrySource(root, path, preset.body, revision, sourceRevisionFor),
106
+ });
107
+ }
108
+ }
109
+ for (const entry of helpCatalogEntries()) {
110
+ const path = 'spec-cli/src/help.ts';
111
+ entries.push({
112
+ id: `help:${entry.id}`,
113
+ kind: 'help',
114
+ title: entry.title,
115
+ description: 'CLI command usage and safety guidance',
116
+ contentRole: 'help',
117
+ content: entry.text,
118
+ source: entrySource(root, path, entry.text, revision, sourceRevisionFor),
119
+ });
120
+ }
121
+ for (const entry of guideCatalogEntries()) {
122
+ const path = 'spec-cli/src/guide.ts';
123
+ entries.push({
124
+ id: `guide:${entry.id}`,
125
+ kind: 'guide',
126
+ title: entry.title,
127
+ description: 'CLI workflow and format guidance',
128
+ contentRole: 'guide',
129
+ content: entry.text,
130
+ source: entrySource(root, path, entry.text, revision, sourceRevisionFor),
131
+ });
132
+ }
133
+ const systemEntries = entries.filter((entry) => entry.kind === 'plugin' && entry.surface === 'system');
134
+ const effectiveSystemContent = systemEntries.map((entry) => entry.content.trim()).filter(Boolean).join('\n\n');
135
+ const payload = {
136
+ schemaVersion: GUIDANCE_SCHEMA_VERSION,
137
+ revision,
138
+ entries: sortEntries(entries),
139
+ catalogSchema: GUIDANCE_CATALOG_SCHEMA,
140
+ payloadName: GUIDANCE_PAYLOAD_NAME,
141
+ sourceRevision: revision,
142
+ effectiveSystemContract: {
143
+ content: effectiveSystemContent,
144
+ contentHash: sha256(effectiveSystemContent),
145
+ sourceEntryIds: systemEntries.map((entry) => entry.id),
146
+ },
147
+ };
148
+ const bundleHash = sha256(JSON.stringify(payload));
149
+ this.bundle = freeze({ ...payload, bundleHash });
150
+ }
151
+ entries() {
152
+ return this.bundle.entries;
153
+ }
154
+ toJSON() {
155
+ return this.bundle;
156
+ }
157
+ exportJson() {
158
+ return `${JSON.stringify(this.bundle, null, 2)}\n`;
159
+ }
160
+ write(path) {
161
+ writeFileSync(path, this.exportJson(), 'utf8');
162
+ }
163
+ }
164
+ export function buildGuidanceCatalog(options = {}) {
165
+ return new GuidanceCatalog(options);
166
+ }
@@ -0,0 +1,8 @@
1
+ export declare function guideText(topic?: string): string | null;
2
+ export declare function guideTopics(): string[];
3
+ export type GuideCatalogEntry = Readonly<{
4
+ id: string;
5
+ title: string;
6
+ text: string;
7
+ }>;
8
+ export declare function guideCatalogEntries(): readonly GuideCatalogEntry[];