thoth-agents 0.2.11 → 0.3.1

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 (149) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/.claude-plugin/marketplace.json +21 -0
  3. package/README.md +301 -311
  4. package/dist/agents/configured-role-prompt.d.ts +9 -0
  5. package/dist/agents/prompt-sections.d.ts +8 -4
  6. package/dist/agents/prompt-utils.d.ts +0 -4
  7. package/dist/{chunk-ASKXWU6E.js → chunk-2MZ5C2RN.js} +1078 -1725
  8. package/dist/chunk-XO74DXBZ.js +1781 -0
  9. package/dist/{chunk-6BNAV534.js → chunk-YUCGIJPP.js} +12 -30
  10. package/dist/cli/claude-code-install.d.ts +24 -26
  11. package/dist/cli/claude-code-paths.d.ts +0 -28
  12. package/dist/cli/codex-install.d.ts +2 -2
  13. package/dist/cli/codex-paths.d.ts +0 -2
  14. package/dist/cli/index.js +279 -119
  15. package/dist/cli/install.d.ts +5 -1
  16. package/dist/cli/model-catalog/cache.d.ts +1 -1
  17. package/dist/cli/operations/claude-code.d.ts +6 -3
  18. package/dist/cli/operations/codex.d.ts +2 -1
  19. package/dist/cli/operations/opencode.d.ts +2 -1
  20. package/dist/cli/operations/types.d.ts +9 -1
  21. package/dist/cli/package-root.d.ts +1 -0
  22. package/dist/cli/providers.d.ts +6 -116
  23. package/dist/cli/skills.d.ts +19 -32
  24. package/dist/cli/thoth-mem-install.d.ts +45 -0
  25. package/dist/cli/tui/components/StatusView.d.ts +12 -1
  26. package/dist/cli/tui/index.js +256 -142
  27. package/dist/cli/tui/operations.d.ts +4 -3
  28. package/dist/cli/types.d.ts +0 -10
  29. package/dist/config/constants.d.ts +20 -16
  30. package/dist/config/index.d.ts +0 -1
  31. package/dist/config/loader.d.ts +1 -1
  32. package/dist/config/schema.d.ts +2 -38
  33. package/dist/config/utils.d.ts +1 -2
  34. package/dist/harness/adapters/codex-surfaces.d.ts +3 -3
  35. package/dist/harness/core/agent-pack.d.ts +37 -29
  36. package/dist/harness/core/memory-governance.d.ts +24 -48
  37. package/dist/harness/core/sdd.d.ts +364 -131
  38. package/dist/harness/generate-integration-packages.d.ts +20 -0
  39. package/dist/harness/opencode-init-command.d.ts +11 -0
  40. package/dist/harness/types.d.ts +14 -1
  41. package/dist/harness/writers/claude-code-subagent.d.ts +3 -1
  42. package/dist/hooks/index.d.ts +0 -5
  43. package/dist/index.js +562 -1314
  44. package/dist/mcp/index.d.ts +1 -2
  45. package/package.json +17 -12
  46. package/plugin/.claude-plugin/.thoth-agents-plugin-assets.json +50 -0
  47. package/plugin/.claude-plugin/plugin.json +8 -0
  48. package/plugin/.codex-plugin/.thoth-agents-plugin-assets.json +16 -0
  49. package/plugin/.codex-plugin/plugin.json +7 -0
  50. package/plugin/.mcp.json +19 -0
  51. package/plugin/agents/deep.md +89 -0
  52. package/plugin/agents/designer.md +89 -0
  53. package/plugin/agents/explorer.md +90 -0
  54. package/plugin/agents/librarian.md +90 -0
  55. package/plugin/agents/oracle.md +92 -0
  56. package/plugin/agents/orchestrator.md +128 -0
  57. package/plugin/agents/quick.md +89 -0
  58. package/plugin/codex.mcp.json +17 -0
  59. package/plugin/settings.json +3 -0
  60. package/plugin/skills/thoth-archive/SKILL.md +40 -0
  61. package/plugin/skills/thoth-archive/scripts/archive.mjs +748 -0
  62. package/plugin/skills/thoth-constitution/SKILL.md +45 -0
  63. package/plugin/skills/thoth-constitution/scripts/validate.mjs +167 -0
  64. package/plugin/skills/thoth-constitution/templates/constitution.md +54 -0
  65. package/plugin/skills/thoth-init/SKILL.md +30 -0
  66. package/plugin/skills/thoth-init/scripts/init.mjs +141 -0
  67. package/plugin/skills/thoth-sdd/SKILL.md +83 -0
  68. package/plugin/skills/thoth-sdd/references/phases/analyze.md +21 -0
  69. package/plugin/skills/thoth-sdd/references/phases/checklist.md +20 -0
  70. package/plugin/skills/thoth-sdd/references/phases/clarify.md +15 -0
  71. package/plugin/skills/thoth-sdd/references/phases/converge.md +14 -0
  72. package/plugin/skills/thoth-sdd/references/phases/explore.md +10 -0
  73. package/plugin/skills/thoth-sdd/references/phases/implement.md +19 -0
  74. package/plugin/skills/thoth-sdd/references/phases/plan.md +15 -0
  75. package/plugin/skills/thoth-sdd/references/phases/specify.md +21 -0
  76. package/plugin/skills/thoth-sdd/references/phases/tasks.md +20 -0
  77. package/plugin/skills/thoth-sdd/references/phases/verify.md +22 -0
  78. package/plugin/skills/thoth-sdd/scripts/validate.mjs +1117 -0
  79. package/plugin/skills/thoth-sdd/templates/archive-report.md +25 -0
  80. package/plugin/skills/thoth-sdd/templates/checklist.md +27 -0
  81. package/plugin/skills/thoth-sdd/templates/plan.md +38 -0
  82. package/plugin/skills/thoth-sdd/templates/spec.md +54 -0
  83. package/plugin/skills/thoth-sdd/templates/tasks.md +29 -0
  84. package/plugin/skills/thoth-sdd/templates/verify-report.md +28 -0
  85. package/skills/README.md +12 -0
  86. package/skills/thoth-archive/SKILL.md +40 -0
  87. package/skills/thoth-archive/scripts/archive.mjs +748 -0
  88. package/skills/thoth-constitution/SKILL.md +45 -0
  89. package/skills/thoth-constitution/scripts/validate.mjs +167 -0
  90. package/skills/thoth-constitution/templates/constitution.md +54 -0
  91. package/skills/thoth-init/SKILL.md +30 -0
  92. package/skills/thoth-init/scripts/init.mjs +141 -0
  93. package/skills/thoth-sdd/SKILL.md +83 -0
  94. package/skills/thoth-sdd/references/phases/analyze.md +21 -0
  95. package/skills/thoth-sdd/references/phases/checklist.md +20 -0
  96. package/skills/thoth-sdd/references/phases/clarify.md +15 -0
  97. package/skills/thoth-sdd/references/phases/converge.md +14 -0
  98. package/skills/thoth-sdd/references/phases/explore.md +10 -0
  99. package/skills/thoth-sdd/references/phases/implement.md +19 -0
  100. package/skills/thoth-sdd/references/phases/plan.md +15 -0
  101. package/skills/thoth-sdd/references/phases/specify.md +21 -0
  102. package/skills/thoth-sdd/references/phases/tasks.md +20 -0
  103. package/skills/thoth-sdd/references/phases/verify.md +22 -0
  104. package/skills/thoth-sdd/scripts/validate.mjs +1117 -0
  105. package/skills/thoth-sdd/templates/archive-report.md +25 -0
  106. package/skills/thoth-sdd/templates/checklist.md +27 -0
  107. package/skills/thoth-sdd/templates/plan.md +38 -0
  108. package/skills/thoth-sdd/templates/spec.md +54 -0
  109. package/skills/thoth-sdd/templates/tasks.md +29 -0
  110. package/skills/thoth-sdd/templates/verify-report.md +28 -0
  111. package/thoth-agents.schema.json +0 -39
  112. package/dist/chunk-OZE7JVGS.js +0 -2344
  113. package/dist/cli/custom-skills.d.ts +0 -49
  114. package/dist/cli/skill-manifest.d.ts +0 -32
  115. package/dist/harness/core/skills.d.ts +0 -211
  116. package/dist/harness/generate-codex-plugin.d.ts +0 -9
  117. package/dist/harness/writers/claude-code-skill-layout.d.ts +0 -16
  118. package/dist/harness/writers/fs-skill-collect.d.ts +0 -7
  119. package/dist/harness/writers/skill-layout.d.ts +0 -16
  120. package/dist/hooks/chat-headers.d.ts +0 -16
  121. package/dist/hooks/phase-reminder/index.d.ts +0 -28
  122. package/dist/hooks/post-read-nudge/index.d.ts +0 -18
  123. package/dist/hooks/skill-sync.d.ts +0 -10
  124. package/dist/hooks/thoth-mem/index.d.ts +0 -46
  125. package/dist/hooks/thoth-mem/protocol.d.ts +0 -7
  126. package/dist/mcp/thoth.d.ts +0 -3
  127. package/dist/sdd/artifact-governance/artifact-loader.d.ts +0 -130
  128. package/dist/sdd/artifact-governance/index.d.ts +0 -6
  129. package/dist/sdd/artifact-governance/tasks-validator.d.ts +0 -17
  130. package/dist/sdd/artifact-governance/types.d.ts +0 -52
  131. package/dist/thoth/client.d.ts +0 -14
  132. package/dist/thoth/index.d.ts +0 -2
  133. package/src/skills/_shared/openspec-convention.md +0 -350
  134. package/src/skills/_shared/persistence-contract.md +0 -163
  135. package/src/skills/_shared/thoth-mem-convention.md +0 -123
  136. package/src/skills/executing-plans/SKILL.md +0 -288
  137. package/src/skills/plan-reviewer/SKILL.md +0 -219
  138. package/src/skills/requirements-interview/SKILL.md +0 -233
  139. package/src/skills/sdd-apply/SKILL.md +0 -89
  140. package/src/skills/sdd-archive/SKILL.md +0 -92
  141. package/src/skills/sdd-clarify/SKILL.md +0 -105
  142. package/src/skills/sdd-constitution/SKILL.md +0 -107
  143. package/src/skills/sdd-design/SKILL.md +0 -155
  144. package/src/skills/sdd-init/SKILL.md +0 -233
  145. package/src/skills/sdd-propose/SKILL.md +0 -101
  146. package/src/skills/sdd-spec/SKILL.md +0 -136
  147. package/src/skills/sdd-tasks/SKILL.md +0 -232
  148. package/src/skills/sdd-verify/SKILL.md +0 -131
  149. package/src/skills/thoth-mem-agents/SKILL.md +0 -210
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: thoth-constitution
3
+ description: Create or explicitly amend the project constitution, choose its governance SemVer bump, propagate its impact, and validate lifecycle metadata. Use only for constitution lifecycle work; routine SDD planning reads the constitution without activating this skill.
4
+ ---
5
+
6
+ # Thoth Constitution
7
+
8
+ The canonical project constitution is `openspec/memory/constitution.md`.
9
+
10
+ ## Routine SDD
11
+
12
+ - Read every active principle before planning.
13
+ - Record concrete pre-design and post-design Constitution Check evidence in
14
+ `plan.md`.
15
+ - Do not amend the constitution, bump its version, or run lifecycle validation
16
+ for an ordinary feature change.
17
+
18
+ ## Explicit amendment
19
+
20
+ Activate this lifecycle only on explicit user direction or when the user accepts
21
+ a confirmed durable governance change.
22
+
23
+ 1. Read the current constitution and every affected template, instruction, and
24
+ durable workflow document.
25
+ 2. Classify the governance version bump:
26
+ - **MAJOR** removes or redefines a principle or compatibility boundary.
27
+ - **MINOR** adds a principle/section or materially expands guidance.
28
+ - **PATCH** clarifies wording without semantic change.
29
+ 3. Preserve the original ratification date, set `Last amended` to today, and
30
+ update `Version` using complete `MAJOR.MINOR.PATCH` SemVer.
31
+ 4. Prepend or refresh the HTML-comment `Sync Impact Report`: old → new version,
32
+ modified principles, added/removed sections, affected templates with status,
33
+ and follow-up TODOs.
34
+ 5. Propagate the accepted rule to every affected template, instruction, and
35
+ documentation surface in the same change.
36
+ 6. Remove unexplained placeholders and deferred TODOs, then run:
37
+
38
+ ```bash
39
+ node skills/thoth-constitution/scripts/validate.mjs \
40
+ --constitution openspec/memory/constitution.md --json
41
+ ```
42
+
43
+ Initialization copies `templates/constitution.md` only when the project has no
44
+ constitution, resolves its date placeholders, and never overwrites a
45
+ project-owned constitution.
@@ -0,0 +1,167 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { existsSync, readFileSync } from 'node:fs';
4
+ import { resolve } from 'node:path';
5
+
6
+ function parseArgs(argv) {
7
+ const options = { json: false };
8
+ for (let index = 0; index < argv.length; index += 1) {
9
+ const argument = argv[index];
10
+ if (argument === '--json') options.json = true;
11
+ else if (argument === '--constitution') {
12
+ options.constitution = argv[++index];
13
+ } else {
14
+ throw new Error(`Unknown argument: ${argument}`);
15
+ }
16
+ }
17
+ if (!options.constitution) throw new Error('--constitution is required');
18
+ return options;
19
+ }
20
+
21
+ function issue(code, message) {
22
+ return { code, message };
23
+ }
24
+
25
+ function metadata(content, name) {
26
+ return new RegExp(`^\\*\\*${name}\\*\\*:\\s*([^<\\n]+)`, 'im')
27
+ .exec(content)?.[1]
28
+ .trim();
29
+ }
30
+
31
+ function isIsoDate(value) {
32
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(value ?? '')) return false;
33
+ const date = new Date(`${value}T00:00:00.000Z`);
34
+ return (
35
+ !Number.isNaN(date.valueOf()) && date.toISOString().slice(0, 10) === value
36
+ );
37
+ }
38
+
39
+ function validate(content) {
40
+ const errors = [];
41
+ if (
42
+ /\bYYYY-MM-DD\b|\[[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+\]|TODO\([A-Z0-9_]+\)/.test(
43
+ content,
44
+ )
45
+ ) {
46
+ errors.push(
47
+ issue(
48
+ 'CONSTITUTION-PLACEHOLDER',
49
+ 'Resolve every template placeholder and deferred TODO before adoption.',
50
+ ),
51
+ );
52
+ }
53
+
54
+ const version = metadata(content, 'Version');
55
+ if (!/^\d+\.\d+\.\d+$/.test(version ?? '')) {
56
+ errors.push(
57
+ issue(
58
+ 'CONSTITUTION-VERSION',
59
+ 'Version must be a complete MAJOR.MINOR.PATCH value.',
60
+ ),
61
+ );
62
+ }
63
+
64
+ const ratified = metadata(content, 'Ratified');
65
+ const lastAmended = metadata(content, 'Last amended');
66
+ if (!isIsoDate(ratified) || !isIsoDate(lastAmended)) {
67
+ errors.push(
68
+ issue(
69
+ 'CONSTITUTION-DATE',
70
+ 'Ratified and Last amended must be real ISO dates in YYYY-MM-DD format.',
71
+ ),
72
+ );
73
+ } else if (lastAmended < ratified) {
74
+ errors.push(
75
+ issue(
76
+ 'CONSTITUTION-DATE-ORDER',
77
+ 'Last amended cannot precede the ratification date.',
78
+ ),
79
+ );
80
+ }
81
+
82
+ const report = /^\s*<!--([\s\S]*?)-->/.exec(content)?.[1];
83
+ const requiredImpactFields = [
84
+ 'Version change',
85
+ 'Modified principles',
86
+ 'Added sections',
87
+ 'Removed sections',
88
+ 'Templates',
89
+ 'Follow-up TODOs',
90
+ ];
91
+ if (
92
+ !report?.includes('Sync Impact Report') ||
93
+ requiredImpactFields.some(
94
+ (field) => !new RegExp(`^- ${field}:\\s*\\S`, 'im').test(report),
95
+ )
96
+ ) {
97
+ errors.push(
98
+ issue(
99
+ 'CONSTITUTION-SYNC-IMPACT',
100
+ 'Prepend a complete Sync Impact Report describing the amendment propagation.',
101
+ ),
102
+ );
103
+ }
104
+ if (
105
+ version &&
106
+ report &&
107
+ !new RegExp(
108
+ `^- Version change:\\s*.+?(?:->|→)\\s*${version.replaceAll('.', '\\.')}(?:\\s|$)`,
109
+ 'im',
110
+ ).test(report)
111
+ ) {
112
+ errors.push(
113
+ issue(
114
+ 'CONSTITUTION-SYNC-VERSION',
115
+ 'The Sync Impact Report version transition must end at the adopted version.',
116
+ ),
117
+ );
118
+ }
119
+
120
+ const governance = /^##\s+Governance\s*$([\s\S]*)/im.exec(content)?.[1];
121
+ if (
122
+ !governance ||
123
+ !['MAJOR', 'MINOR', 'PATCH'].every((term) =>
124
+ new RegExp(`\\b${term}\\b`).test(governance),
125
+ )
126
+ ) {
127
+ errors.push(
128
+ issue(
129
+ 'CONSTITUTION-SEMVER-POLICY',
130
+ 'Governance must define explicit MAJOR, MINOR, and PATCH amendment semantics.',
131
+ ),
132
+ );
133
+ }
134
+
135
+ if (!/^##\s+(?:Core )?Principles\s*$/im.test(content)) {
136
+ errors.push(
137
+ issue(
138
+ 'CONSTITUTION-PRINCIPLES',
139
+ 'Define an explicit Principles section with active project rules.',
140
+ ),
141
+ );
142
+ }
143
+
144
+ return { valid: errors.length === 0, version, errors };
145
+ }
146
+
147
+ try {
148
+ const options = parseArgs(process.argv.slice(2));
149
+ const path = resolve(options.constitution);
150
+ if (!existsSync(path)) throw new Error(`Constitution not found: ${path}`);
151
+ const result = validate(readFileSync(path, 'utf8'));
152
+ if (options.json) {
153
+ process.stdout.write(`${JSON.stringify(result)}\n`);
154
+ } else if (result.valid) {
155
+ process.stdout.write(`Constitution ${result.version} is valid.\n`);
156
+ } else {
157
+ process.stderr.write(
158
+ `${result.errors.map((error) => `${error.code}: ${error.message}`).join('\n')}\n`,
159
+ );
160
+ }
161
+ if (!result.valid) process.exitCode = 1;
162
+ } catch (error) {
163
+ process.stderr.write(
164
+ `${error instanceof Error ? error.message : String(error)}\n`,
165
+ );
166
+ process.exitCode = 2;
167
+ }
@@ -0,0 +1,54 @@
1
+ <!--
2
+ Sync Impact Report
3
+ - Version change: N/A -> 1.0.0
4
+ - Modified principles: None (initial ratification)
5
+ - Added sections: Principles; Governance
6
+ - Removed sections: None
7
+ - Templates: ✅ initialized by thoth-init
8
+ - Follow-up TODOs: None
9
+ -->
10
+ # Project Constitution
11
+
12
+ **Version**: 1.0.0<br>
13
+ **Ratified**: YYYY-MM-DD<br>
14
+ **Last amended**: YYYY-MM-DD
15
+
16
+ ## Principles
17
+
18
+ ### I. User-value first
19
+
20
+ Every change MUST map to an observable user or operator outcome. Speculative
21
+ infrastructure without a current requirement is prohibited.
22
+
23
+ ### II. Simplicity and bounded scope
24
+
25
+ Delivery MUST use the smallest coherent design that satisfies accepted
26
+ requirements. Non-goals MUST be named, and scope cannot expand silently.
27
+
28
+ ### III. Testable contracts
29
+
30
+ Behavioral requirements MUST have observable acceptance evidence. Behavior
31
+ changes MUST use test-first execution at an agreed public seam when practical.
32
+
33
+ ### IV. Independent assurance
34
+
35
+ The implementation writer cannot approve its own work. Analyze and verify MUST
36
+ be performed by an independent read-only reviewer.
37
+
38
+ ### V. Traceable delivery
39
+
40
+ Specifications, plans, tasks, implementation evidence, verification verdicts,
41
+ and archive reports MUST remain traceable without relying on chat history.
42
+
43
+ ## Governance
44
+
45
+ - Planning MUST record evidence-backed Constitution Check results before and
46
+ after design; routine feature work reads the principles but does not amend or
47
+ revalidate constitution lifecycle metadata.
48
+ - Exceptions MUST identify the principle, reason, risk, owner, and removal
49
+ condition.
50
+ - Amendments require explicit user direction, an updated Sync Impact Report,
51
+ and propagation to affected templates, instructions, and documentation.
52
+ - MAJOR versions remove or redefine governance compatibility.
53
+ - MINOR versions add a principle or materially expand guidance.
54
+ - PATCH versions clarify wording without changing its meaning.
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: thoth-init
3
+ description: Initialize project SDD governance and OpenCode local skills from the installed bundle; Codex global agents and instructions remain CLI-owned.
4
+ ---
5
+
6
+ # Thoth Init
7
+
8
+ Initialize the current project from this installed skill bundle. Resolve
9
+ `<skill-dir>` as the directory containing this `SKILL.md`, then run the bundled
10
+ script by absolute path:
11
+
12
+ ```text
13
+ node "<skill-dir>/scripts/init.mjs" --project <project-root> --harness <opencode|codex|claude> --json
14
+ ```
15
+
16
+ - OpenCode materializes the four thoth-owned workflow skills under
17
+ `.agents/skills/`.
18
+ - Codex init creates project governance only. Codex plugin manifests cannot
19
+ install custom agents or global instructions; first run the mandatory
20
+ thoth-agents CLI setup that manages `~/.codex/agents/`,
21
+ `~/.codex/AGENTS.md`, and `~/.codex/config.toml`.
22
+ - Claude uses auto-discovered plugin agents and owned skills; init creates only
23
+ project governance assets.
24
+
25
+ For every harness, installation must already have used the thoth-agents CLI to
26
+ install mandatory external skills from their canonical repositories. This init
27
+ skill never invokes the CLI or downloads a skill.
28
+
29
+ The operation is offline and idempotent. It never overwrites the project
30
+ constitution, templates, or unrelated instruction content.
@@ -0,0 +1,141 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ cpSync,
5
+ existsSync,
6
+ mkdirSync,
7
+ readdirSync,
8
+ readFileSync,
9
+ statSync,
10
+ writeFileSync,
11
+ } from 'node:fs';
12
+ import { dirname, join, resolve } from 'node:path';
13
+ import { fileURLToPath } from 'node:url';
14
+
15
+ const SCRIPT_PATH = fileURLToPath(import.meta.url);
16
+ const SKILL_ROOT = dirname(dirname(SCRIPT_PATH));
17
+ const BUNDLE_ROOT = dirname(SKILL_ROOT);
18
+ const OWNED_SKILL_NAMES = [
19
+ 'thoth-init',
20
+ 'thoth-sdd',
21
+ 'thoth-constitution',
22
+ 'thoth-archive',
23
+ ];
24
+
25
+ function parseArgs(argv) {
26
+ const options = { json: false };
27
+ for (let index = 0; index < argv.length; index += 1) {
28
+ const argument = argv[index];
29
+ if (argument === '--json') options.json = true;
30
+ else if (argument === '--project') options.project = argv[++index];
31
+ else if (argument === '--harness') options.harness = argv[++index];
32
+ else throw new Error(`Unknown argument: ${argument}`);
33
+ }
34
+ if (!options.project) throw new Error('--project is required');
35
+ if (!['opencode', 'codex', 'claude'].includes(options.harness)) {
36
+ throw new Error('--harness must be opencode, codex, or claude');
37
+ }
38
+ return options;
39
+ }
40
+
41
+ function copyMissing(source, target, report) {
42
+ if (!existsSync(source)) return;
43
+ const sourceStat = statSync(source);
44
+ if (sourceStat.isDirectory()) {
45
+ mkdirSync(target, { recursive: true });
46
+ for (const entry of readdirSync(source)) {
47
+ copyMissing(join(source, entry), join(target, entry), report);
48
+ }
49
+ return;
50
+ }
51
+ if (existsSync(target)) {
52
+ report.skipped.push(target);
53
+ return;
54
+ }
55
+ mkdirSync(dirname(target), { recursive: true });
56
+ cpSync(source, target, { errorOnExist: true });
57
+ report.created.push(target);
58
+ }
59
+
60
+ function writeMissing(target, content, report) {
61
+ if (existsSync(target)) {
62
+ report.skipped.push(target);
63
+ return;
64
+ }
65
+ mkdirSync(dirname(target), { recursive: true });
66
+ writeFileSync(target, content);
67
+ report.created.push(target);
68
+ }
69
+
70
+ function installConstitution(project, report) {
71
+ const target = join(project, 'openspec', 'memory', 'constitution.md');
72
+ const template = join(
73
+ BUNDLE_ROOT,
74
+ 'thoth-constitution',
75
+ 'templates',
76
+ 'constitution.md',
77
+ );
78
+ if (!existsSync(template)) return;
79
+ const today = new Date().toISOString().slice(0, 10);
80
+ writeMissing(
81
+ target,
82
+ readFileSync(template, 'utf8').replaceAll('YYYY-MM-DD', today),
83
+ report,
84
+ );
85
+ }
86
+
87
+ function installGovernance(project, report) {
88
+ installConstitution(project, report);
89
+ const templatesRoot = join(BUNDLE_ROOT, 'thoth-sdd', 'templates');
90
+ if (existsSync(templatesRoot)) {
91
+ for (const entry of readdirSync(templatesRoot)) {
92
+ copyMissing(
93
+ join(templatesRoot, entry),
94
+ join(project, 'openspec', 'templates', entry),
95
+ report,
96
+ );
97
+ }
98
+ }
99
+ writeMissing(
100
+ join(project, 'openspec', '.thoth-agents.json'),
101
+ `${JSON.stringify({ version: 1, initializedBy: 'thoth-agents' }, null, 2)}\n`,
102
+ report,
103
+ );
104
+ }
105
+
106
+ function installOpenCode(project, report) {
107
+ for (const skillName of OWNED_SKILL_NAMES) {
108
+ copyMissing(
109
+ join(BUNDLE_ROOT, skillName),
110
+ join(project, '.agents', 'skills', skillName),
111
+ report,
112
+ );
113
+ }
114
+ }
115
+
116
+ try {
117
+ const options = parseArgs(process.argv.slice(2));
118
+ const project = resolve(options.project);
119
+ mkdirSync(project, { recursive: true });
120
+ const report = {
121
+ status: 'ready',
122
+ harness: options.harness,
123
+ project,
124
+ created: [],
125
+ managed: [],
126
+ skipped: [],
127
+ };
128
+
129
+ installGovernance(project, report);
130
+ if (options.harness === 'opencode') installOpenCode(project, report);
131
+
132
+ const output = options.json
133
+ ? JSON.stringify(report)
134
+ : `thoth-agents initialized ${project} for ${options.harness}`;
135
+ process.stdout.write(`${output}\n`);
136
+ } catch (error) {
137
+ process.stderr.write(
138
+ `${error instanceof Error ? error.message : String(error)}\n`,
139
+ );
140
+ process.exitCode = 1;
141
+ }
@@ -0,0 +1,83 @@
1
+ ---
2
+ name: thoth-sdd
3
+ description: Run thoth-agents Direct, Accelerated, or Full specification-driven development with Spec Kit-grade artifacts, OpenSpec-style durable deltas, fast-forward planning, and oracle-only analysis and verification.
4
+ ---
5
+
6
+ # Thoth SDD
7
+
8
+ Select the lightest route that preserves correctness:
9
+
10
+ - **Direct**: `implement -> verify`
11
+ - **Accelerated**: `specify -> plan -> tasks -> implement -> verify -> archive`
12
+ - **Full**: `explore -> specify -> plan -> tasks -> analyze -> implement -> verify -> archive`
13
+
14
+ Conditional phases are `clarify`, `checklist`, and `converge`. Direct creates no
15
+ SDD artifacts and may cover multiple documentation or mechanical files when the
16
+ intent is clear and risk is low.
17
+
18
+ Accelerated is a **fast-forward** route: root writes `spec.md`, `plan.md`, and
19
+ `tasks.md` in one uninterrupted pass, validates structure without a routine user
20
+ pause, and creates optional artifacts only for a concrete risk. Full uses
21
+ phase-by-phase gates because uncertainty or failure cost justifies them.
22
+
23
+ An explicitly named route wins. A generic request to “use SDD” sets Accelerated
24
+ as the minimum; it does not force Full. User input is requested only for a
25
+ material decision that evidence and safe assumptions cannot resolve.
26
+
27
+ ## Ownership
28
+
29
+ - Root owns sequential coordination artifacts, gate execution, and archive.
30
+ - Explorer owns Full-route repository discovery.
31
+ - Designer, quick, deep, or root may implement according to scope.
32
+ - Oracle always owns `analyze` and **every** `verify`. The implementation writer
33
+ never approves its own work.
34
+
35
+ ## Progressive loading
36
+
37
+ Use only installed local contracts during the pipeline. Never invoke the
38
+ thoth-agents CLI, `npx skills add`, or a network fetch to advance an SDD phase.
39
+ If a required contract or external skill is missing, stop and report an
40
+ incomplete installation instead of provisioning it mid-workflow.
41
+
42
+ Read only the current phase contract:
43
+
44
+ | Phase | Contract |
45
+ | --- | --- |
46
+ | explore | `references/phases/explore.md` |
47
+ | specify | `references/phases/specify.md` |
48
+ | clarify | `references/phases/clarify.md` |
49
+ | plan | `references/phases/plan.md` |
50
+ | checklist | `references/phases/checklist.md` |
51
+ | tasks | `references/phases/tasks.md` |
52
+ | analyze | `references/phases/analyze.md` |
53
+ | implement | `references/phases/implement.md` |
54
+ | verify | `references/phases/verify.md` |
55
+ | converge | `references/phases/converge.md` |
56
+ | archive | bundled `thoth-archive` skill |
57
+
58
+ ## Validation gates
59
+
60
+ Run the validator from this skill directory:
61
+
62
+ ```text
63
+ node scripts/validate.mjs --change openspec/changes/<feature> --route <accelerated|full> --through <specify|plan|tasks|checklist|ready|closeout> --json
64
+ ```
65
+
66
+ - **Accelerated**: `specify`, then `ready` after the fast-forward planning pass,
67
+ then `closeout` after independent verification and an archive report marked
68
+ `READY`.
69
+ - **Full**: `specify`, `plan`, `tasks`, then `ready` before oracle analysis, and
70
+ `closeout` after independent verification.
71
+ - **Checklist**: run only when activated; the later `ready` gate includes it if
72
+ present.
73
+
74
+ `ready` validates the artifacts needed before analysis/implementation.
75
+ `closeout` additionally requires completed tasks, independent oracle PASS,
76
+ complete FR/buildable-SC evidence, an observed PASS or explicit residual RISK
77
+ for every outcome SC, and an archive report ready for the transactional archive
78
+ transition.
79
+
80
+ When implementation evidence refines the same intent, root updates the canonical
81
+ artifact and revalidates only affected downstream artifacts/gates. A changed
82
+ intent starts a new change. Structural validation prevents malformed artifacts;
83
+ oracle still judges completeness, correctness, coherence, and evidence.
@@ -0,0 +1,21 @@
1
+ # Analyze contract
2
+
3
+ **Owner**: oracle (read-only, independent)<br>
4
+ **Applies to**: Full
5
+
6
+ Review `spec.md`, `plan.md`, `tasks.md`, the constitution, and any activated
7
+ checklist across three separate dimensions:
8
+
9
+ - **Completeness**: all accepted scope, FRs, buildable SCs, stories, failures,
10
+ and constraints have downstream coverage.
11
+ - **Correctness**: requirements and technical choices are testable, feasible,
12
+ and consistent with repository evidence and the constitution.
13
+ - **Coherence**: spec, plan, tasks, dependencies, and verification seams do not
14
+ contradict or duplicate one another.
15
+
16
+ Buildable SCs require tasks; outcome SCs require measurable validation intent,
17
+ not fake implementation tasks. Report stable finding IDs with
18
+ CRITICAL/HIGH/MEDIUM/LOW severity, coverage percentages, checklist status, and a
19
+ `ready` or `blocked` verdict. Any CRITICAL finding, constitution violation, or
20
+ FR/buildable SC with zero task coverage blocks implementation. Never edit
21
+ artifacts; root owns remediation.
@@ -0,0 +1,20 @@
1
+ # Checklist contract
2
+
3
+ **Owner**: root<br>
4
+ **Output**: `checklists/requirements.md`<br>
5
+ **Activation**: high contract/failure risk, compliance sensitivity, or
6
+ ambiguity-prone scope
7
+
8
+ Record the concrete activation reason. Use sequential `CHK###` items to audit
9
+ the requirements—not implementation—across the base taxonomy: Completeness,
10
+ Clarity, Consistency, Measurability, and Coverage.
11
+
12
+ Add only applicable domain lenses, such as security, privacy, accessibility,
13
+ compliance, performance, migration, or domain-specific failure rules. If none
14
+ apply, record an evidence-backed `None` decision instead of boilerplate checks.
15
+ Map every US, FR, SC, actor, failure mode, and relevant constraint to evidence.
16
+
17
+ After clarification or planning changes, check affected revalidation items. If
18
+ no requirement-affecting artifact changed, record an evidence-backed `Not
19
+ required` no-op. Unresolved high-risk gaps return to specify; checklist status
20
+ must never be inferred from code tests.
@@ -0,0 +1,15 @@
1
+ # Clarify contract
2
+
3
+ **Owner**: root<br>
4
+ **Activation**: material ambiguity only
5
+
6
+ Classify requirement dimensions as **Clear**, **Partial**, or **Missing** across
7
+ scope, actors, data, interactions, non-functional constraints, failure behavior,
8
+ and success evidence. Resolve from repository evidence or a safe documented
9
+ assumption first. Ask one targeted human question only when the answer materially
10
+ changes the result; Full SDD should normally ask no more than five high-impact
11
+ questions in one clarification pass.
12
+
13
+ Write every accepted answer directly into `spec.md`, cite the changed FR/SC/story,
14
+ then re-run structural validation and revalidate any existing requirements
15
+ checklist. Do not create a parallel clarification document.
@@ -0,0 +1,14 @@
1
+ # Converge contract
2
+
3
+ **Owner**: root<br>
4
+ **Activation**: failed artifact-backed verification
5
+
6
+ Classify every oracle gap as `missing`, `partial`, `contradicts`, or
7
+ `unrequested`. Append one traceable remediation task per actionable gap to a new
8
+ Convergence section in `tasks.md`, ordered by severity and linked to its finding,
9
+ FR/buildable SC, exact writer surface, and verification outcome.
10
+
11
+ Never rewrite, renumber, reorder, or delete earlier tasks, and never edit product
12
+ code during convergence. If no actionable gap exists, leave `tasks.md`
13
+ byte-for-byte unchanged. Return to implement, then always ask oracle to verify
14
+ again.
@@ -0,0 +1,10 @@
1
+ # Explore contract
2
+
3
+ **Owner**: explorer (read-only)<br>
4
+ **Applies to**: Full
5
+
6
+ Resolve only repository uncertainty that affects requirements or design. Inspect
7
+ the smallest useful anchors and return relevant paths/symbols, confirmed current
8
+ behavior, constraints, safe assumptions, unresolved human-owned decisions, and
9
+ recommended specification anchors. Do not write files or return raw logs. Stop
10
+ when root can specify without repeating discovery.
@@ -0,0 +1,19 @@
1
+ # Implement contract
2
+
3
+ **Owner**: root, designer, quick, or deep; exactly one writer per mutable surface
4
+
5
+ Root marks selected artifact-backed tasks `[~]`, then assigns exact paths,
6
+ accepted FR/buildable-SC scope, non-goals, and verification commands. Use the
7
+ mandatory `tdd` skill for behavior changes and work in vertical red/green
8
+ slices. Child writers never edit task state; root marks `[x]` only after checking
9
+ task-specific evidence.
10
+
11
+ Implementation evidence may refine an artifact without restarting the workflow:
12
+
13
+ - If it preserves the accepted intent, return the evidence to root; root updates
14
+ the canonical artifact and revalidates only affected downstream artifacts and
15
+ gates.
16
+ - If it changes intent or accepted product scope, start a new change rather than
17
+ silently expanding this one.
18
+
19
+ Report files changed, checks executed, deviations, and remaining work.
@@ -0,0 +1,15 @@
1
+ # Plan contract
2
+
3
+ **Owner**: root<br>
4
+ **Output**: `openspec/changes/<feature>/plan.md`
5
+
6
+ Start from `templates/plan.md`. Read active constitution principles and record
7
+ evidence-backed pre-design and post-design Constitution Checks. Routine SDD does
8
+ not amend the constitution or run its lifecycle validator; activate
9
+ `thoth-constitution` only when an explicit constitution amendment is in scope.
10
+
11
+ Map each technical choice to FR/SC or a confirmed repository constraint. Name
12
+ affected components, interfaces, exact paths, migrations, risks, rollback, and
13
+ verification seams. Create `research.md`, `data-model.md`, `contracts/`, or
14
+ `quickstart.md` only when that artifact resolves a concrete implementation risk.
15
+ Any unexplained constitution failure blocks tasks.
@@ -0,0 +1,21 @@
1
+ # Specify contract
2
+
3
+ **Owner**: root<br>
4
+ **Output**: `openspec/changes/<feature>/spec.md`
5
+
6
+ Start from `templates/spec.md` and remain implementation-neutral.
7
+
8
+ - Record **Why**, **Impact**, and affected kebab-case capability slugs (or
9
+ `None`).
10
+ - Define prioritized, independently testable `US#` stories. Every story needs
11
+ `Covers: FR-###, SC-###` and Given/When/Then acceptance scenarios.
12
+ - Give every sequential FR a descriptive title, a normative `MUST`/`SHALL`
13
+ statement, and exactly one delta marker: `INTERNAL`, `ADDED`, `MODIFIED`,
14
+ `REMOVED`, or `RENAMED ... FROM ...`.
15
+ - Type each measurable SC as `buildable` or `outcome`. Buildable criteria require
16
+ implementation coverage; outcome criteria remain product/operational
17
+ verification targets without fake tasks.
18
+ - State assumptions, dependencies, edge cases, and explicit non-goals.
19
+
20
+ Do not advance while a material ambiguity would change scope, behavior,
21
+ architecture, or durable delta intent.