thoth-agents 0.3.5 → 0.3.7

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 (40) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +25 -16
  3. package/dist/{chunk-W5GCMYA3.js → chunk-HIXSRHEG.js} +295 -66
  4. package/dist/cli/index.js +37 -4
  5. package/dist/cli/install.d.ts +2 -0
  6. package/dist/cli/operations/opencode.d.ts +2 -2
  7. package/dist/cli/owned-skills.d.ts +20 -0
  8. package/dist/cli/tui/index.js +1 -1
  9. package/dist/harness/core/owned-skills.d.ts +2 -0
  10. package/dist/index.js +5 -4
  11. package/package.json +1 -1
  12. package/plugin/.claude-plugin/plugin.json +1 -1
  13. package/plugin/.codex-plugin/plugin.json +1 -1
  14. package/plugin/skills/plan-reviewer/SKILL.md +5 -1
  15. package/plugin/skills/thoth-archive/SKILL.md +7 -3
  16. package/plugin/skills/thoth-constitution/SKILL.md +7 -4
  17. package/plugin/skills/thoth-init/SKILL.md +28 -20
  18. package/plugin/skills/thoth-init/scripts/init.mjs +99 -74
  19. package/plugin/skills/thoth-sdd/SKILL.md +17 -13
  20. package/plugin/skills/thoth-sdd/references/phases/checklist.md +3 -0
  21. package/plugin/skills/thoth-sdd/references/phases/plan.md +8 -4
  22. package/plugin/skills/thoth-sdd/references/phases/specify.md +3 -1
  23. package/plugin/skills/thoth-sdd/references/phases/tasks.md +10 -3
  24. package/plugin/skills/thoth-sdd/references/phases/verify.md +4 -3
  25. package/plugin/skills/thoth-sdd/templates/plan.md +14 -6
  26. package/plugin/skills/thoth-sdd/templates/tasks.md +20 -7
  27. package/skills/README.md +5 -3
  28. package/skills/plan-reviewer/SKILL.md +5 -1
  29. package/skills/thoth-archive/SKILL.md +7 -3
  30. package/skills/thoth-constitution/SKILL.md +7 -4
  31. package/skills/thoth-init/SKILL.md +28 -20
  32. package/skills/thoth-init/scripts/init.mjs +99 -74
  33. package/skills/thoth-sdd/SKILL.md +17 -13
  34. package/skills/thoth-sdd/references/phases/checklist.md +3 -0
  35. package/skills/thoth-sdd/references/phases/plan.md +8 -4
  36. package/skills/thoth-sdd/references/phases/specify.md +3 -1
  37. package/skills/thoth-sdd/references/phases/tasks.md +10 -3
  38. package/skills/thoth-sdd/references/phases/verify.md +4 -3
  39. package/skills/thoth-sdd/templates/plan.md +14 -6
  40. package/skills/thoth-sdd/templates/tasks.md +20 -7
package/dist/cli/index.js CHANGED
@@ -42,8 +42,9 @@ import {
42
42
  getRequiredSkillInstallCommand,
43
43
  installRequiredSkill,
44
44
  listOperationHarnesses,
45
- normalizeEffortSelection
46
- } from "../chunk-W5GCMYA3.js";
45
+ normalizeEffortSelection,
46
+ syncOpenCodeOwnedSkills
47
+ } from "../chunk-HIXSRHEG.js";
47
48
  import {
48
49
  ALL_AGENT_NAMES,
49
50
  detectCurrentConfig,
@@ -551,9 +552,30 @@ function formatConfigSummary(dryRun) {
551
552
  lines.push(
552
553
  ` ${DIM}\u25CB thoth-mem remains the owner of hooks, MCP, skill, lifecycle, persistence, receipts, and recovery.${RESET}`
553
554
  );
555
+ lines.push(` ${SYMBOLS.check} Global thoth-owned OpenCode skills`);
554
556
  lines.push(` ${SYMBOLS.check} Required external skills for this harness`);
555
557
  return lines.join("\n");
556
558
  }
559
+ function installOwnedSkillsForOpenCode(dryRun, dependencies) {
560
+ const result = syncOpenCodeOwnedSkills({
561
+ dryRun,
562
+ homeDir: dependencies.homeDir ?? homedir(),
563
+ packageRoot: dependencies.opencodeOwnedSkillPackageRoot
564
+ });
565
+ for (const skill of result.skills) {
566
+ printInfo(` - ${skill.name}: ${skill.destinationPath}`);
567
+ }
568
+ if (!result.success) {
569
+ printError(
570
+ `Failed to synchronize global thoth-owned OpenCode skills: ${result.error ?? "unknown error"}`
571
+ );
572
+ return false;
573
+ }
574
+ printSuccess(
575
+ dryRun ? "Global thoth-owned OpenCode skills planned" : "Global thoth-owned OpenCode skills synchronized"
576
+ );
577
+ return true;
578
+ }
557
579
  function installRequiredSkillsForHarness(harness, dryRun, homeDir = homedir()) {
558
580
  if (dryRun) {
559
581
  printInfo(`Dry run mode - required ${harness} skills:`);
@@ -617,7 +639,7 @@ async function runInstall(config, dependencies) {
617
639
  const detected = detectCurrentConfig();
618
640
  const isUpdate = detected.isInstalled;
619
641
  printHeader(isUpdate);
620
- const totalSteps = 5;
642
+ const totalSteps = 6;
621
643
  let step = 1;
622
644
  printStep(step++, totalSteps, "Checking OpenCode installation...");
623
645
  if (config.dryRun) {
@@ -666,8 +688,19 @@ ${JSON.stringify(liteConfig, null, 2)}
666
688
  return 1;
667
689
  }
668
690
  }
691
+ printStep(
692
+ step++,
693
+ totalSteps,
694
+ "Synchronizing global thoth-owned OpenCode skills..."
695
+ );
696
+ if (!installOwnedSkillsForOpenCode(config.dryRun, dependencies)) return 1;
669
697
  printStep(step++, totalSteps, "Installing required external skills...");
670
- if (!installRequiredSkillsForHarness("opencode", config.dryRun)) return 1;
698
+ if (!installRequiredSkillsForHarness(
699
+ "opencode",
700
+ config.dryRun,
701
+ dependencies.homeDir ?? homedir()
702
+ ))
703
+ return 1;
671
704
  printStep(step++, totalSteps, "Configuring provider-owned thoth-mem...");
672
705
  if (!installThothMemForHarness("opencode", config.dryRun, dependencies)) {
673
706
  return 1;
@@ -1,6 +1,8 @@
1
1
  import { type ThothMemSetupOptions, type ThothMemSetupResult } from './thoth-mem-install';
2
2
  import type { InstallArgs, InstallConfig } from './types';
3
3
  export interface InstallDependencies {
4
+ homeDir?: string;
5
+ opencodeOwnedSkillPackageRoot?: string;
4
6
  runThothMemSetup?: (options: ThothMemSetupOptions) => ThothMemSetupResult;
5
7
  }
6
8
  export declare function createInstallConfig(args: InstallArgs): InstallConfig;
@@ -9,7 +9,7 @@ export declare const opencodeOperationAdapter: {
9
9
  };
10
10
  export declare function getOpenCodeStatus(context?: OperationContext, evidence?: ProviderEvidenceInput): HarnessStatusReport;
11
11
  export declare function buildOpenCodeUpdatePlan(_context?: OperationContext): OperationPlan;
12
- export declare function buildOpenCodeSyncPlan(_context?: OperationContext): OperationPlan;
13
- export declare function buildOpenCodeInstallPlan(_context?: OperationContext): OperationPlan;
12
+ export declare function buildOpenCodeSyncPlan(context?: OperationContext): OperationPlan;
13
+ export declare function buildOpenCodeInstallPlan(context?: OperationContext): OperationPlan;
14
14
  export declare function buildOpenCodeModelPlan(input: ModelConfigInput, _context?: OperationContext): OperationPlan;
15
15
  export declare function applyOpenCodePlan(plan: OperationPlan): OperationApplyResult;
@@ -0,0 +1,20 @@
1
+ import { type ThothOwnedSkillName } from '../harness/core/owned-skills';
2
+ export interface OpenCodeOwnedSkillSyncOptions {
3
+ dryRun?: boolean;
4
+ homeDir?: string;
5
+ packageRoot?: string;
6
+ }
7
+ export interface OpenCodeOwnedSkillSyncEntry {
8
+ name: ThothOwnedSkillName;
9
+ sourcePath: string;
10
+ destinationPath: string;
11
+ }
12
+ export interface OpenCodeOwnedSkillSyncResult {
13
+ success: boolean;
14
+ status: 'planned' | 'installed' | 'failed';
15
+ skills: OpenCodeOwnedSkillSyncEntry[];
16
+ error?: string;
17
+ }
18
+ export declare function resolveOwnedSkillPackageRoot(moduleUrl: string): string;
19
+ export declare function getOpenCodeOwnedSkillEntries(options?: Pick<OpenCodeOwnedSkillSyncOptions, 'homeDir' | 'packageRoot'>): OpenCodeOwnedSkillSyncEntry[];
20
+ export declare function syncOpenCodeOwnedSkills(options?: OpenCodeOwnedSkillSyncOptions): OpenCodeOwnedSkillSyncResult;
@@ -2,7 +2,7 @@ import {
2
2
  defaultTuiOperations,
3
3
  effortChoicesForModel,
4
4
  listOperationHarnesses
5
- } from "../../chunk-W5GCMYA3.js";
5
+ } from "../../chunk-HIXSRHEG.js";
6
6
  import "../../chunk-F2K4CS5J.js";
7
7
 
8
8
  // src/cli/tui/index.tsx
@@ -0,0 +1,2 @@
1
+ export declare const THOTH_OWNED_SKILL_NAMES: readonly ["thoth-init", "thoth-sdd", "thoth-constitution", "thoth-archive", "plan-reviewer"];
2
+ export type ThothOwnedSkillName = (typeof THOTH_OWNED_SKILL_NAMES)[number];
package/dist/index.js CHANGED
@@ -42,12 +42,13 @@ function createOpenCodeInitCommand({
42
42
  subtask: false,
43
43
  template: `Initialize this project now using the bundled thoth-init skill.
44
44
 
45
- The operation must stay project-scoped, idempotent, and offline. Run:
45
+ The operation must stay scoped to openspec/, idempotent, and offline. Run:
46
46
 
47
- node "${scriptPath}" --project "${projectRoot}" --harness opencode --json
47
+ node "${scriptPath}" --project "${projectRoot}" --json
48
48
 
49
- Inspect the JSON result, report created and preserved files, and do not download
50
- skills or invoke the thoth-agents CLI.
49
+ Inspect the JSON result and report created, managed, and preserved OpenSpec
50
+ assets. Do not install skills or agents, download dependencies, modify harness
51
+ configuration, or invoke the thoth-agents CLI.
51
52
 
52
53
  Bundled skill contract:
53
54
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thoth-agents",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Adaptive multi-harness orchestration with seven roles, runtime-autonomous Spec Kit-compatible SDD routes, and external provider boundaries.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thoth-agents",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Adaptive multi-harness agent pack with seven roles and a runtime-autonomous Spec Kit-compatible SDD bundle for Claude Code.",
5
5
  "author": {
6
6
  "name": "thoth-agents"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thoth-agents",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Bundled Spec Kit-compatible SDD skills and MCP configuration; the seven-role global Codex layer requires thoth-agents CLI setup.",
5
5
  "skills": "./skills/",
6
6
  "mcpServers": "./codex.mcp.json"
@@ -26,10 +26,14 @@ Oracle review; mandatory final Oracle verify still applies.
26
26
 
27
27
  ## Ownership and inputs
28
28
 
29
+ Resolve `<skill-dir>` as the directory containing this `SKILL.md`. Every bundled
30
+ asset path in this contract is anchored to that installed skill root rather than
31
+ the project or current working directory.
32
+
29
33
  Root coordinates the phase and dispatches Oracle. Oracle remains read-only: it
30
34
  must not edit source, SDD artifacts, or coordination state. Root persists the
31
35
  returned review at `openspec/changes/<change>/plan-review.md` using
32
- `templates/plan-review.md`.
36
+ `<skill-dir>/templates/plan-review.md`.
33
37
 
34
38
  Review these canonical inputs:
35
39
 
@@ -6,16 +6,20 @@ description: Close a passing artifact-backed thoth-agents change by transactiona
6
6
  # Thoth Archive
7
7
 
8
8
  Archive is the required terminal transition for Accelerated and Full routes.
9
+ Resolve `<skill-dir>` as the directory containing this `SKILL.md`, and resolve
10
+ `<skills-root>` as its parent directory. Bundled paths below are anchored to
11
+ those installed roots rather than the project or current working directory.
9
12
 
10
13
  1. Confirm every task is `[x]`, `verify-report.md` records independent oracle
11
14
  `PASS`, its compliance matrix covers every FR and buildable SC, every outcome
12
15
  SC has observed PASS evidence or an explicit residual RISK, and no unresolved
13
16
  CRITICAL issue remains.
14
- 2. Prepare `archive-report.md` from the bundled template with status `READY`,
17
+ 2. Prepare `archive-report.md` from
18
+ `<skills-root>/thoth-sdd/templates/archive-report.md` with status `READY`,
15
19
  verification lineage, completed scope, deviations, residual warnings, and
16
20
  the pending canonical-sync line.
17
- 3. Run the thoth-sdd validator through `closeout`.
18
- 4. Run `scripts/archive.mjs --change <path> --date YYYY-MM-DD --json`.
21
+ 3. Run `node "<skills-root>/thoth-sdd/scripts/validate.mjs"` through `closeout`.
22
+ 4. Run `node "<skill-dir>/scripts/archive.mjs" --change <path> --date YYYY-MM-DD --json`.
19
23
  5. Return the dated archive path, updated capability specifications, and audit
20
24
  summary.
21
25
 
@@ -6,6 +6,9 @@ description: Create or explicitly amend the project constitution, choose its gov
6
6
  # Thoth Constitution
7
7
 
8
8
  The canonical project constitution is `openspec/memory/constitution.md`.
9
+ Resolve `<skill-dir>` as the directory containing this `SKILL.md`. Every bundled
10
+ validator or template path below is anchored to that installed skill root rather
11
+ than the project or current working directory.
9
12
 
10
13
  ## Routine SDD
11
14
 
@@ -36,10 +39,10 @@ a confirmed durable governance change.
36
39
  6. Remove unexplained placeholders and deferred TODOs, then run:
37
40
 
38
41
  ```bash
39
- node skills/thoth-constitution/scripts/validate.mjs \
42
+ node "<skill-dir>/scripts/validate.mjs" \
40
43
  --constitution openspec/memory/constitution.md --json
41
44
  ```
42
45
 
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.
46
+ Initialization copies `<skill-dir>/templates/constitution.md` only when the
47
+ project has no constitution, resolves its date placeholders, and never
48
+ overwrites a project-owned constitution.
@@ -1,30 +1,38 @@
1
1
  ---
2
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.
3
+ description: Initialize or synchronize the minimum project OpenSpec governance structure required by thoth-agents SDD flows.
4
4
  ---
5
5
 
6
6
  # Thoth Init
7
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:
8
+ Initialize or synchronize the current project's OpenSpec governance from this
9
+ installed skill bundle. Resolve `<skill-dir>` as the directory containing this
10
+ `SKILL.md`, then run the bundled script by absolute path:
11
11
 
12
12
  ```text
13
- node "<skill-dir>/scripts/init.mjs" --project <project-root> --harness <opencode|codex|claude> --json
13
+ node "<skill-dir>/scripts/init.mjs" --project <project-root> --json
14
14
  ```
15
15
 
16
- - OpenCode materializes the five 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.
16
+ The project root must already exist. The initializer preflights the complete
17
+ target structure before changing it, then ensures these minimum paths exist:
18
+
19
+ - `openspec/changes/archive/`
20
+ - `openspec/specs/`
21
+ - `openspec/memory/`
22
+ - `openspec/.thoth-agents.json`
23
+
24
+ The missing constitution is copied from the installed sibling
25
+ `thoth-constitution` skill. An existing constitution remains byte-for-byte
26
+ intact, while the thoth-managed manifest may be normalized to the current
27
+ contract. Any legacy `openspec/templates/` tree is outside the managed graph and
28
+ remains untouched. Inspect the JSON `created`, `managed`, and `preserved` arrays
29
+ when reporting the result.
30
+
31
+ The initializer never creates, copies, validates, reads, or synchronizes SDD
32
+ workflow templates. Those assets remain in the installed `thoth-sdd` skill and
33
+ are consumed directly from that bundle by the workflow phase contracts.
34
+
35
+ This operation is offline, idempotent, and harness-neutral. Every write stays
36
+ inside `openspec/`. It never installs or synchronizes skills, agents, plugins,
37
+ harness configuration, external dependencies, or global instruction files;
38
+ those are responsibilities of `npx thoth-agents install`.
@@ -1,12 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import {
4
- cpSync,
5
4
  existsSync,
5
+ lstatSync,
6
6
  mkdirSync,
7
- readdirSync,
8
7
  readFileSync,
9
- statSync,
10
8
  writeFileSync,
11
9
  } from 'node:fs';
12
10
  import { dirname, join, resolve } from 'node:path';
@@ -15,12 +13,12 @@ import { fileURLToPath } from 'node:url';
15
13
  const SCRIPT_PATH = fileURLToPath(import.meta.url);
16
14
  const SKILL_ROOT = dirname(dirname(SCRIPT_PATH));
17
15
  const BUNDLE_ROOT = dirname(SKILL_ROOT);
18
- const OWNED_SKILL_NAMES = [
19
- 'thoth-init',
20
- 'thoth-sdd',
21
- 'thoth-constitution',
22
- 'thoth-archive',
23
- 'plan-reviewer',
16
+ const OPEN_SPEC_DIRECTORIES = [
17
+ 'openspec',
18
+ join('openspec', 'changes'),
19
+ join('openspec', 'changes', 'archive'),
20
+ join('openspec', 'specs'),
21
+ join('openspec', 'memory'),
24
22
  ];
25
23
 
26
24
  function parseArgs(argv) {
@@ -29,110 +27,137 @@ function parseArgs(argv) {
29
27
  const argument = argv[index];
30
28
  if (argument === '--json') options.json = true;
31
29
  else if (argument === '--project') options.project = argv[++index];
32
- else if (argument === '--harness') options.harness = argv[++index];
33
30
  else throw new Error(`Unknown argument: ${argument}`);
34
31
  }
35
32
  if (!options.project) throw new Error('--project is required');
36
- if (!['opencode', 'codex', 'claude'].includes(options.harness)) {
37
- throw new Error('--harness must be opencode, codex, or claude');
38
- }
39
33
  return options;
40
34
  }
41
35
 
42
- function copyMissing(source, target, report) {
43
- if (!existsSync(source)) return;
44
- const sourceStat = statSync(source);
45
- if (sourceStat.isDirectory()) {
46
- mkdirSync(target, { recursive: true });
47
- for (const entry of readdirSync(source)) {
48
- copyMissing(join(source, entry), join(target, entry), report);
49
- }
50
- return;
36
+ function assertDirectory(path, label) {
37
+ if (!existsSync(path)) return;
38
+ const stat = lstatSync(path);
39
+ if (stat.isSymbolicLink() || !stat.isDirectory()) {
40
+ throw new Error(`${label} must be a directory: ${path}`);
51
41
  }
52
- if (existsSync(target)) {
53
- report.skipped.push(target);
54
- return;
55
- }
56
- mkdirSync(dirname(target), { recursive: true });
57
- cpSync(source, target, { errorOnExist: true });
58
- report.created.push(target);
59
42
  }
60
43
 
61
- function writeMissing(target, content, report) {
62
- if (existsSync(target)) {
63
- report.skipped.push(target);
64
- return;
44
+ function assertRegularFile(path, label) {
45
+ if (!existsSync(path)) return;
46
+ const stat = lstatSync(path);
47
+ if (stat.isSymbolicLink() || !stat.isFile()) {
48
+ throw new Error(`${label} must be a regular file: ${path}`);
65
49
  }
66
- mkdirSync(dirname(target), { recursive: true });
67
- writeFileSync(target, content);
68
- report.created.push(target);
69
50
  }
70
51
 
71
- function installConstitution(project, report) {
72
- const target = join(project, 'openspec', 'memory', 'constitution.md');
73
- const template = join(
52
+ function preflight(project) {
53
+ assertDirectory(project, 'Project root');
54
+ if (!existsSync(project)) {
55
+ throw new Error(
56
+ `--project must reference an existing project directory: ${project}`,
57
+ );
58
+ }
59
+
60
+ const constitutionSource = join(
74
61
  BUNDLE_ROOT,
75
62
  'thoth-constitution',
76
63
  'templates',
77
64
  'constitution.md',
78
65
  );
79
- if (!existsSync(template)) return;
80
- const today = new Date().toISOString().slice(0, 10);
81
- writeMissing(
82
- target,
83
- readFileSync(template, 'utf8').replaceAll('YYYY-MM-DD', today),
84
- report,
66
+ assertRegularFile(constitutionSource, 'Bundled constitution template');
67
+ if (!existsSync(constitutionSource)) {
68
+ throw new Error(
69
+ `Bundled constitution template is missing: ${constitutionSource}`,
70
+ );
71
+ }
72
+
73
+ for (const directory of OPEN_SPEC_DIRECTORIES) {
74
+ assertDirectory(join(project, directory), 'OpenSpec path');
75
+ }
76
+
77
+ const constitutionTarget = join(
78
+ project,
79
+ 'openspec',
80
+ 'memory',
81
+ 'constitution.md',
85
82
  );
83
+ const manifestTarget = join(project, 'openspec', '.thoth-agents.json');
84
+ assertRegularFile(constitutionTarget, 'OpenSpec constitution path');
85
+ assertRegularFile(manifestTarget, 'OpenSpec manifest path');
86
+
87
+ return {
88
+ constitutionSource,
89
+ constitutionTarget,
90
+ manifestTarget,
91
+ };
86
92
  }
87
93
 
88
- function installGovernance(project, report) {
89
- installConstitution(project, report);
90
- const templatesRoot = join(BUNDLE_ROOT, 'thoth-sdd', 'templates');
91
- if (existsSync(templatesRoot)) {
92
- for (const entry of readdirSync(templatesRoot)) {
93
- copyMissing(
94
- join(templatesRoot, entry),
95
- join(project, 'openspec', 'templates', entry),
96
- report,
97
- );
98
- }
94
+ function createDirectory(target, report) {
95
+ if (existsSync(target)) return;
96
+ mkdirSync(target);
97
+ report.created.push(target);
98
+ }
99
+
100
+ function writePreservingExisting(target, content, report) {
101
+ if (existsSync(target)) {
102
+ report.preserved.push(target);
103
+ return;
99
104
  }
100
- writeMissing(
101
- join(project, 'openspec', '.thoth-agents.json'),
102
- `${JSON.stringify({ version: 1, initializedBy: 'thoth-agents' }, null, 2)}\n`,
103
- report,
104
- );
105
+ writeFileSync(target, content);
106
+ report.created.push(target);
105
107
  }
106
108
 
107
- function installOpenCode(project, report) {
108
- for (const skillName of OWNED_SKILL_NAMES) {
109
- copyMissing(
110
- join(BUNDLE_ROOT, skillName),
111
- join(project, '.agents', 'skills', skillName),
112
- report,
113
- );
109
+ function synchronizeManagedFile(target, content, report) {
110
+ if (!existsSync(target)) {
111
+ writeFileSync(target, content);
112
+ report.created.push(target);
113
+ return;
114
+ }
115
+ if (readFileSync(target, 'utf8') === content) {
116
+ report.preserved.push(target);
117
+ return;
118
+ }
119
+ writeFileSync(target, content);
120
+ report.managed.push(target);
121
+ }
122
+
123
+ function synchronizeOpenSpec(project, assets, report) {
124
+ for (const directory of OPEN_SPEC_DIRECTORIES) {
125
+ createDirectory(join(project, directory), report);
114
126
  }
127
+
128
+ const today = new Date().toISOString().slice(0, 10);
129
+ writePreservingExisting(
130
+ assets.constitutionTarget,
131
+ readFileSync(assets.constitutionSource, 'utf8').replaceAll(
132
+ 'YYYY-MM-DD',
133
+ today,
134
+ ),
135
+ report,
136
+ );
137
+ synchronizeManagedFile(
138
+ assets.manifestTarget,
139
+ `${JSON.stringify({ version: 1, initializedBy: 'thoth-agents' }, null, 2)}\n`,
140
+ report,
141
+ );
115
142
  }
116
143
 
117
144
  try {
118
145
  const options = parseArgs(process.argv.slice(2));
119
146
  const project = resolve(options.project);
120
- mkdirSync(project, { recursive: true });
147
+ const assets = preflight(project);
121
148
  const report = {
122
149
  status: 'ready',
123
- harness: options.harness,
124
150
  project,
125
151
  created: [],
126
152
  managed: [],
127
- skipped: [],
153
+ preserved: [],
128
154
  };
129
155
 
130
- installGovernance(project, report);
131
- if (options.harness === 'opencode') installOpenCode(project, report);
156
+ synchronizeOpenSpec(project, assets, report);
132
157
 
133
158
  const output = options.json
134
159
  ? JSON.stringify(report)
135
- : `thoth-agents initialized ${project} for ${options.harness}`;
160
+ : `thoth-agents synchronized OpenSpec governance in ${project}`;
136
161
  process.stdout.write(`${output}\n`);
137
162
  } catch (error) {
138
163
  process.stderr.write(
@@ -37,6 +37,10 @@ Accelerated the minimum recommendation but does not force it.
37
37
 
38
38
  ## Progressive loading
39
39
 
40
+ Resolve `<skill-dir>` as the directory containing this `SKILL.md`, and resolve
41
+ `<skills-root>` as its parent directory. Every bundled path below is anchored to
42
+ one of those installed roots, never to the project or current working directory.
43
+
40
44
  Use only installed local contracts during the pipeline. Never invoke the
41
45
  thoth-agents CLI, `npx skills add`, or a network fetch to advance an SDD phase.
42
46
  If a required contract or external skill is missing, stop and report an
@@ -46,24 +50,24 @@ Read only the current phase contract:
46
50
 
47
51
  | Phase | Contract |
48
52
  | --- | --- |
49
- | explore | `references/phases/explore.md` |
50
- | specify | `references/phases/specify.md` |
51
- | clarify | `references/phases/clarify.md` |
52
- | plan | `references/phases/plan.md` |
53
- | checklist | `references/phases/checklist.md` |
54
- | tasks | `references/phases/tasks.md` |
55
- | plan-review | bundled `plan-reviewer` skill |
56
- | implement | `references/phases/implement.md` |
57
- | verify | `references/phases/verify.md` |
58
- | converge | `references/phases/converge.md` |
59
- | archive | bundled `thoth-archive` skill |
53
+ | explore | `<skill-dir>/references/phases/explore.md` |
54
+ | specify | `<skill-dir>/references/phases/specify.md` |
55
+ | clarify | `<skill-dir>/references/phases/clarify.md` |
56
+ | plan | `<skill-dir>/references/phases/plan.md` |
57
+ | checklist | `<skill-dir>/references/phases/checklist.md` |
58
+ | tasks | `<skill-dir>/references/phases/tasks.md` |
59
+ | plan-review | `<skills-root>/plan-reviewer/SKILL.md` |
60
+ | implement | `<skill-dir>/references/phases/implement.md` |
61
+ | verify | `<skill-dir>/references/phases/verify.md` |
62
+ | converge | `<skill-dir>/references/phases/converge.md` |
63
+ | archive | `<skills-root>/thoth-archive/SKILL.md` |
60
64
 
61
65
  ## Validation gates
62
66
 
63
- Run the validator from this skill directory:
67
+ Run the validator from its installed absolute path:
64
68
 
65
69
  ```text
66
- node scripts/validate.mjs --change openspec/changes/<feature> --route <accelerated|full> --through <specify|plan|tasks|checklist|ready|closeout> --json
70
+ node "<skill-dir>/scripts/validate.mjs" --change openspec/changes/<feature> --route <accelerated|full> --through <specify|plan|tasks|checklist|ready|closeout> --json
67
71
  ```
68
72
 
69
73
  - **Accelerated**: `specify`, then `ready` after the fast-forward planning pass,
@@ -5,6 +5,9 @@
5
5
  **Activation**: high contract/failure risk, compliance sensitivity, or
6
6
  ambiguity-prone scope
7
7
 
8
+ When activated, start from `<skill-dir>/templates/checklist.md`, where
9
+ `<skill-dir>` is the directory containing the installed `thoth-sdd/SKILL.md`.
10
+
8
11
  Record the concrete activation reason. Use sequential `CHK###` items to audit
9
12
  the requirements—not implementation—across the base taxonomy: Completeness,
10
13
  Clarity, Consistency, Measurability, and Coverage.
@@ -3,10 +3,14 @@
3
3
  **Owner**: root<br>
4
4
  **Output**: `openspec/changes/<feature>/plan.md`
5
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.
6
+ Start from `<skill-dir>/templates/plan.md`, where `<skill-dir>` is the directory
7
+ containing the installed `thoth-sdd/SKILL.md`. Read active constitution
8
+ principles and record evidence-backed pre-design and post-design Constitution
9
+ Checks. Extract the exact active numbered principle headings once, then reuse
10
+ that same ordered name set in both checks; only status and evidence may differ.
11
+ Routine SDD does not amend the constitution or run its lifecycle validator;
12
+ activate `thoth-constitution` only when an explicit constitution amendment is
13
+ in scope.
10
14
 
11
15
  Map each technical choice to FR/SC or a confirmed repository constraint. Name
12
16
  affected components, interfaces, exact paths, migrations, risks, rollback, and
@@ -3,7 +3,9 @@
3
3
  **Owner**: root<br>
4
4
  **Output**: `openspec/changes/<feature>/spec.md`
5
5
 
6
- Start from `templates/spec.md` and remain implementation-neutral.
6
+ Start from `<skill-dir>/templates/spec.md`, where `<skill-dir>` is the directory
7
+ containing the installed `thoth-sdd/SKILL.md`, and remain
8
+ implementation-neutral.
7
9
 
8
10
  - Record **Why**, **Impact**, and affected kebab-case capability slugs (or
9
11
  `None`).