genesis-compiler 1.2.24 → 1.2.26

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.
package/src/index/init.js CHANGED
@@ -6,6 +6,7 @@ import { BLUEPRINT_SKELETON_SOURCE } from './blueprint.js';
6
6
  import { installCodexHooks } from './codex-hooks.js';
7
7
  import { ENGINEERING_SKELETON_SOURCE } from './engineering.js';
8
8
  import { gitContext } from './git.js';
9
+ import { installOpenCodePlugin } from './opencode-plugin.js';
9
10
  import {
10
11
  BLUEPRINT_PATH,
11
12
  ENGINEERING_PATH,
@@ -44,22 +45,32 @@ export async function initializeProject({ projectRoot, stackPackages = [] } = {}
44
45
  await mkdir(path.join(root, PROGRAM_ROOT), { recursive: true });
45
46
  const stack = await readStack(root, { stackPackages });
46
47
  const skills = await syncProjectSkills({ projectRoot: root, stack });
47
- const hooks = await installCodexHooks({ projectRoot: root });
48
+ const [hooks, openCodePlugin] = await Promise.all([
49
+ installCodexHooks({ projectRoot: root }),
50
+ installOpenCodePlugin({ projectRoot: root }),
51
+ ]);
48
52
  const version = projectFormat.status === 'uninitialized'
49
53
  ? await createIfMissing(root, PROJECT_VERSION_PATH, CURRENT_PROJECT_FORMAT_SOURCE)
50
54
  : null;
51
- const changedFiles = [...created, ...hooks.changedFiles, ...skills.changedFiles, version]
55
+ const changedFiles = [
56
+ ...created,
57
+ ...hooks.changedFiles,
58
+ ...openCodePlugin.changedFiles,
59
+ ...skills.changedFiles,
60
+ version,
61
+ ]
52
62
  .filter(Boolean)
53
63
  .sort();
54
64
  return {
55
65
  status: changedFiles.length > 0 ? 'updated' : 'unchanged',
56
66
  summary: changedFiles.length > 0
57
- ? 'Initialized Genesis, Agent Skills, and project Codex hooks.'
58
- : 'Genesis, its Agent Skills, and project Codex hooks are already initialized.',
67
+ ? 'Initialized Genesis, Agent Skills, and project guidance for Codex and OpenCode.'
68
+ : 'Genesis, its Agent Skills, and project guidance for Codex and OpenCode are already initialized.',
59
69
  changedFiles,
60
70
  diagnostics: skills.diagnostics,
61
71
  guidance: [
62
- 'Open Codex and use /hooks to review and trust the project hooks.',
72
+ 'Open Codex and use /hooks to review and trust the project guidance hook.',
73
+ 'OpenCode loads the project guidance plugin automatically.',
63
74
  'Genesis workflow skills are available in .agents/skills/.',
64
75
  'Describe product intent in genesis/blueprint.md.',
65
76
  'Choose the project engineering approach with genesis engineering set <profile>.',
@@ -0,0 +1,28 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+
4
+ import { gitContext } from './git.js';
5
+ import { writeFileAtomic } from './utils.js';
6
+
7
+ const OPENCODE_PLUGIN_PATH = '.opencode/plugins/genesis-project-guidance.js';
8
+ const OPENCODE_PLUGIN_SOURCE = new URL('../../plugins/opencode/project-guidance.js', import.meta.url);
9
+
10
+ async function existingSource(location) {
11
+ try {
12
+ return await readFile(location, 'utf8');
13
+ } catch (error) {
14
+ if (['ENOENT', 'ENOTDIR'].includes(error?.code)) return null;
15
+ throw error;
16
+ }
17
+ }
18
+
19
+ export async function installOpenCodePlugin({ projectRoot } = {}) {
20
+ const root = (await gitContext(projectRoot)).repositoryRoot;
21
+ const location = path.join(root, OPENCODE_PLUGIN_PATH);
22
+ const source = await readFile(OPENCODE_PLUGIN_SOURCE, 'utf8');
23
+ if (await existingSource(location) === source) {
24
+ return { status: 'unchanged', changedFiles: [] };
25
+ }
26
+ await writeFileAtomic(location, source);
27
+ return { status: 'updated', changedFiles: [OPENCODE_PLUGIN_PATH] };
28
+ }
@@ -25,7 +25,7 @@ const DEFAULT_REQUEST = {
25
25
  start: 'Start a conversation about this project.',
26
26
  adopt: 'Import the existing project into a truthful Genesis project contract.',
27
27
  work: 'Implement the product intent expressed by the current Blueprint.',
28
- deslop: 'Simplify the current Git-visible work without making unrelated changes.',
28
+ deslop: 'Deslop the latest commit.',
29
29
  program: 'Refresh the complete useful Program for the code that exists now.',
30
30
  describe: 'Create or refresh the complete Blueprint and useful Program for the codebase that exists now.',
31
31
  review: 'Review the complete useful relationship between Blueprint, code, Program, and tests.',
@@ -107,6 +107,7 @@ function renderPrompt({
107
107
  skills = '',
108
108
  guidance = '',
109
109
  cleanup = '',
110
+ postChange = '',
110
111
  adoption = '',
111
112
  engineeringGuidance = '',
112
113
  }) {
@@ -126,6 +127,7 @@ function renderPrompt({
126
127
  ...(guidance ? ['', 'SELECTED STACK GUIDANCE', '', guidance] : []),
127
128
  ...(adoption ? ['', 'SELECTED STACK ADOPTION GUIDANCE', '', adoption] : []),
128
129
  ...(skills ? ['', 'AVAILABLE AGENT SKILLS', '', skills] : []),
130
+ ...(postChange ? ['', 'SELECTED STACK POST-CHANGE GUIDANCE', '', postChange] : []),
129
131
  ...(cleanup ? ['', 'SELECTED STACK CLEANUP GUIDANCE', '', cleanup] : []),
130
132
  '',
131
133
  ].join('\n');
@@ -451,6 +453,7 @@ export async function generateProjectPrompt({
451
453
  engineeringGuidance: engineering.guidance,
452
454
  guidance: stack.guidance,
453
455
  skills: renderAgentSkillCatalog(projectSkills.skills),
456
+ postChange: task === 'work' ? stack.postChange : '',
454
457
  cleanup: task === 'deslop' ? stack.deslop : '',
455
458
  });
456
459
  return {
@@ -0,0 +1,55 @@
1
+ import { readEngineering, readEngineeringBaseline } from './engineering.js';
2
+ import { gitContext } from './git.js';
3
+ import { readStack } from './stack.js';
4
+
5
+ async function optionalStack(projectRoot, stackPackages) {
6
+ try { return await readStack(projectRoot, { stackPackages }); } catch { return null; }
7
+ }
8
+
9
+ async function optionalEngineering(projectRoot) {
10
+ try {
11
+ return await readEngineering(projectRoot);
12
+ } catch {
13
+ return {
14
+ guidance: [
15
+ '## Universal complexity gate',
16
+ '',
17
+ await readEngineeringBaseline(),
18
+ '',
19
+ 'The project engineering profile is invalid. Do not infer a replacement; run the Genesis `check` operation and ask the user before implementation if the selected approach matters.',
20
+ ].join('\n'),
21
+ profile: null,
22
+ };
23
+ }
24
+ }
25
+
26
+ export async function projectSessionContext({ projectRoot, stackPackages = [] } = {}) {
27
+ const root = (await gitContext(projectRoot)).repositoryRoot;
28
+ const [stack, engineering] = await Promise.all([
29
+ optionalStack(root, stackPackages),
30
+ optionalEngineering(root),
31
+ ]);
32
+ const selected = stack?.components.map(({ id }) => id) || [];
33
+ const stackStatus = stack
34
+ ? (selected.length > 0 ? selected.join(', ') : 'none')
35
+ : 'unavailable; run the Genesis `check` operation';
36
+ return {
37
+ status: 'ready',
38
+ output: [
39
+ 'This is a Genesis-enriched project.',
40
+ '- Read `genesis/blueprint.md`, `genesis/engineering.md`, and `genesis/stack.md` for product intent, engineering approach, and selected technology.',
41
+ '- Use the relevant project Agent Skills below `.agents/skills/`.',
42
+ '- After locating source, run `genesis context <path...>`; before adding a helper or public operation, run `genesis index <name-or-path...>` and reuse an existing owner.',
43
+ '- Program is fallible explanation; code, tests, and runtime behavior remain evidence.',
44
+ '- Keep Blueprint and affected Program explanations aligned with intentional observable product behavior in the same implementation turn. Private restructuring may need only source citations or no explanatory change.',
45
+ '- Deslop only when explicitly requested. Genesis defines its behavior-preserving committed scope; selected Stack components may add technology-specific cleanup guidance.',
46
+ '- This guidance is loaded for a new session and refreshed after compaction. Continue the active request without restarting completed work.',
47
+ `Engineering profile: ${engineering.profile?.id || 'invalid; run the Genesis `check` operation'}.`,
48
+ `Selected Stack components: ${stackStatus}.`,
49
+ '',
50
+ 'ENGINEERING APPROACH',
51
+ '',
52
+ engineering.guidance,
53
+ ].join('\n'),
54
+ };
55
+ }
@@ -1,13 +0,0 @@
1
- For every repository listed in the task, read and follow that repository's
2
- `.agents/skills/genesis-program/SKILL.md` completely, operating in focused
3
- post-change reconciliation mode.
4
-
5
- Use the preceding implementation turn, listed changed paths, actual Git diff or
6
- history, and relevant tests. Update Blueprint only for intentional observable
7
- product behavior. Update only affected Program modules. Private restructuring
8
- may require only Sources or an informational Implementation map, and may require
9
- no explanatory edit at all.
10
-
11
- Do not simplify or edit implementation, tests, configuration, dependencies,
12
- Stack, or `.genesis/` during this turn. Do not run Deslop yet. Summarize every
13
- explanatory change and genuine ambiguity.