@t275005746/gse 0.1.0 → 0.1.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 (180) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.yml +42 -42
  2. package/.github/ISSUE_TEMPLATE/change_request.yml +50 -50
  3. package/.github/ISSUE_TEMPLATE/config.yml +5 -5
  4. package/.github/PULL_REQUEST_TEMPLATE.md +38 -38
  5. package/.github/workflows/validate-gse.yml +33 -33
  6. package/.gse/README.md +18 -18
  7. package/.gse/gse-development-protocol.md +50 -50
  8. package/.gse/project-profile.md +29 -29
  9. package/.gse/quality-gates.md +25 -25
  10. package/.gse/releases/public-registry-publication-npm.md +49 -0
  11. package/.gse/releases/public-release-owner-required.md +65 -65
  12. package/.gse/releases/public-security-contact-owner-required.md +45 -45
  13. package/.gse/state.json +3 -4
  14. package/CHANGELOG.md +24 -24
  15. package/CONTRIBUTING.md +64 -64
  16. package/LICENSE +21 -21
  17. package/README.md +1 -1
  18. package/README.zh-CN.md +1 -1
  19. package/SECURITY.md +41 -41
  20. package/SUPPORT.md +38 -38
  21. package/assets/marketplace/README.md +7 -7
  22. package/assets/marketplace/gse-listing.json +75 -75
  23. package/assets/templates/acceptance-execution-packet.md +73 -73
  24. package/assets/templates/adr.md +14 -14
  25. package/assets/templates/change-brief.md +16 -16
  26. package/assets/templates/design.md +18 -18
  27. package/assets/templates/dispatch-packet.md +104 -104
  28. package/assets/templates/evidence.md +14 -14
  29. package/assets/templates/execution-quality-pack.md +65 -65
  30. package/assets/templates/goal-map.md +21 -21
  31. package/assets/templates/host-adapter.md +48 -48
  32. package/assets/templates/host-ui-invocation-record.md +42 -42
  33. package/assets/templates/incident-review.md +60 -60
  34. package/assets/templates/public-channel-publication-record.md +49 -49
  35. package/assets/templates/public-ci-run-record.md +53 -53
  36. package/assets/templates/public-release-record.md +65 -65
  37. package/assets/templates/public-repository-settings-record.md +59 -59
  38. package/assets/templates/public-security-contact-record.md +45 -45
  39. package/assets/templates/release-trust-record.md +32 -32
  40. package/assets/templates/review.md +18 -18
  41. package/assets/templates/spec.md +16 -16
  42. package/assets/templates/target-adoption-evidence.md +29 -29
  43. package/assets/templates/tasks.md +17 -17
  44. package/assets/templates/update-release-acceptance-record.md +58 -58
  45. package/examples/README.md +22 -22
  46. package/examples/agent-runtime-host/.claude/gse-adapter.md +6 -6
  47. package/examples/agent-runtime-host/.codex/gse-adapter.md +7 -7
  48. package/examples/agent-runtime-host/.gse/goal-map.md +7 -7
  49. package/examples/agent-runtime-host/.gse/project-profile.md +27 -27
  50. package/examples/agent-runtime-host/.gse/tooling.md +5 -5
  51. package/examples/agent-runtime-host/.mcp.json +9 -9
  52. package/examples/agent-runtime-host/AGENTS.md +5 -5
  53. package/examples/agent-runtime-host/README.md +10 -10
  54. package/examples/agent-runtime-host/docs/model-routing.md +5 -5
  55. package/examples/cli-tool/.gse/project-profile.md +21 -21
  56. package/examples/cli-tool/AGENTS.md +5 -5
  57. package/examples/cli-tool/README.md +12 -12
  58. package/examples/cli-tool/package.json +21 -21
  59. package/examples/small-app/.env.example +2 -2
  60. package/examples/small-app/.github/workflows/ci.yml +8 -8
  61. package/examples/small-app/AGENTS.md +5 -5
  62. package/examples/small-app/README.md +12 -12
  63. package/examples/small-app/package.json +26 -26
  64. package/examples/small-app/playwright.config.ts +4 -4
  65. package/package.json +53 -53
  66. package/references/adoption-recipes.md +171 -171
  67. package/references/agent-roles.md +49 -49
  68. package/references/architecture-health.md +101 -101
  69. package/references/benchmark-audit.md +73 -73
  70. package/references/community-channels.md +46 -46
  71. package/references/compatibility.md +70 -70
  72. package/references/design-basis.md +38 -38
  73. package/references/domain-model.md +129 -129
  74. package/references/domain-quality-gates.md +75 -75
  75. package/references/drift-audit.md +81 -81
  76. package/references/evidence-taxonomy.md +123 -123
  77. package/references/file-ownership.md +107 -107
  78. package/references/final-readiness.md +84 -84
  79. package/references/forward-test.md +133 -133
  80. package/references/goal-map.md +36 -36
  81. package/references/host-adapters.md +119 -119
  82. package/references/learning-system.md +35 -35
  83. package/references/marketplace-discovery.md +46 -46
  84. package/references/model-routing.md +103 -103
  85. package/references/open-source-defaults.md +39 -39
  86. package/references/operating-model.md +52 -52
  87. package/references/packaging.md +277 -277
  88. package/references/project-agent-workspace.md +89 -89
  89. package/references/project-bootstrap.md +122 -122
  90. package/references/project-profile.md +57 -57
  91. package/references/public-release.md +174 -174
  92. package/references/quality-gates.md +100 -100
  93. package/references/recovery.md +176 -176
  94. package/references/release-trust.md +43 -43
  95. package/references/release.md +126 -126
  96. package/references/review.md +141 -141
  97. package/references/router.md +90 -90
  98. package/references/spec-workflow.md +66 -66
  99. package/references/task-levels.md +81 -81
  100. package/references/tool-adapters.md +73 -73
  101. package/scripts/audit-acceptance-execution-packet.mjs +133 -133
  102. package/scripts/audit-adoption-recipes.mjs +99 -99
  103. package/scripts/audit-change-lifecycle.mjs +77 -77
  104. package/scripts/audit-change-system.mjs +134 -134
  105. package/scripts/audit-ci-readiness.mjs +107 -107
  106. package/scripts/audit-close-gate.mjs +323 -323
  107. package/scripts/audit-command-adapters.mjs +91 -91
  108. package/scripts/audit-command-execution.mjs +210 -210
  109. package/scripts/audit-compatibility.mjs +149 -149
  110. package/scripts/audit-completion-readiness.mjs +292 -292
  111. package/scripts/audit-distribution.mjs +251 -251
  112. package/scripts/audit-domain-quality-gates.mjs +108 -108
  113. package/scripts/audit-evidence-placeholders.mjs +126 -126
  114. package/scripts/audit-final-readiness-promotion.mjs +255 -255
  115. package/scripts/audit-final-readiness.mjs +226 -226
  116. package/scripts/audit-fixtures.mjs +154 -154
  117. package/scripts/audit-fresh-session-readiness.mjs +177 -177
  118. package/scripts/audit-host-runtime-evidence-handoff.mjs +159 -159
  119. package/scripts/audit-host-runtime-invocation-drill.mjs +240 -240
  120. package/scripts/audit-host-runtime-invocations.mjs +254 -254
  121. package/scripts/audit-host-ui-invocation.mjs +132 -132
  122. package/scripts/audit-marketplace-discovery.mjs +122 -122
  123. package/scripts/audit-npm-package-metadata.mjs +155 -155
  124. package/scripts/audit-npm-publish-dry-run.mjs +191 -169
  125. package/scripts/audit-npm-tarball-install.mjs +191 -191
  126. package/scripts/audit-open-source-defaults.mjs +92 -92
  127. package/scripts/audit-open-source-readiness.mjs +97 -97
  128. package/scripts/audit-project.mjs +138 -138
  129. package/scripts/audit-public-acceptance-command-dry-run-drill.mjs +203 -203
  130. package/scripts/audit-public-acceptance-readiness.mjs +224 -224
  131. package/scripts/audit-public-channel-publication.mjs +248 -248
  132. package/scripts/audit-public-ci-run.mjs +184 -184
  133. package/scripts/audit-public-collaboration-templates.mjs +98 -98
  134. package/scripts/audit-public-external-gate-probe.mjs +206 -206
  135. package/scripts/audit-public-release-decision.mjs +201 -201
  136. package/scripts/audit-public-release-metadata.mjs +176 -176
  137. package/scripts/audit-public-repository-settings.mjs +237 -237
  138. package/scripts/audit-public-security-contact.mjs +171 -171
  139. package/scripts/audit-readme-docs.mjs +6 -4
  140. package/scripts/audit-recovery-readiness.mjs +98 -98
  141. package/scripts/audit-release-readiness.mjs +106 -106
  142. package/scripts/audit-release-trust.mjs +62 -62
  143. package/scripts/audit-remote-distribution.mjs +266 -266
  144. package/scripts/audit-roadmap-consistency.mjs +235 -235
  145. package/scripts/audit-signing.mjs +147 -147
  146. package/scripts/audit-state-freshness.mjs +14 -9
  147. package/scripts/audit-target-adoption-evidence.mjs +117 -117
  148. package/scripts/audit-target-project.mjs +507 -507
  149. package/scripts/audit-update-release-acceptance.mjs +136 -136
  150. package/scripts/audit-v1-target-validation.mjs +269 -269
  151. package/scripts/audit-validation-profiles.mjs +125 -125
  152. package/scripts/close-change.mjs +116 -116
  153. package/scripts/discover-project-profile.mjs +307 -307
  154. package/scripts/generate-command-adapter.mjs +231 -231
  155. package/scripts/generate-final-acceptance-packet.mjs +181 -181
  156. package/scripts/generate-final-form-progress-report.mjs +205 -205
  157. package/scripts/generate-host-runtime-evidence-handoff.mjs +206 -206
  158. package/scripts/generate-owner-external-gate-kit.mjs +295 -295
  159. package/scripts/generate-public-acceptance-handoff.mjs +168 -168
  160. package/scripts/generate-public-release-checklist.mjs +207 -207
  161. package/scripts/generate-release-bundle.mjs +505 -505
  162. package/scripts/generate-release-owner-action-plan.mjs +172 -172
  163. package/scripts/generate-release-status-manifest.mjs +200 -200
  164. package/scripts/generate-session-prompt.mjs +188 -188
  165. package/scripts/gse.mjs +67 -67
  166. package/scripts/init-change.mjs +265 -265
  167. package/scripts/init-project.mjs +785 -785
  168. package/scripts/install-gse.mjs +234 -234
  169. package/scripts/lib/evidence-placeholders.mjs +28 -28
  170. package/scripts/package-gse.mjs +174 -174
  171. package/scripts/probe-public-external-gates.mjs +167 -167
  172. package/scripts/record-host-invocation.mjs +151 -151
  173. package/scripts/record-public-channel-publication.mjs +178 -178
  174. package/scripts/record-public-ci-run.mjs +180 -180
  175. package/scripts/record-public-release.mjs +175 -175
  176. package/scripts/record-public-repository-settings.mjs +209 -209
  177. package/scripts/record-public-security-contact.mjs +157 -157
  178. package/scripts/sign-gse-package.mjs +83 -83
  179. package/scripts/update-project-state.mjs +223 -223
  180. package/scripts/verify-gse-package.mjs +85 -85
@@ -1,785 +1,785 @@
1
- #!/usr/bin/env node
2
- import fs from 'node:fs'
3
- import path from 'node:path'
4
-
5
- const args = process.argv.slice(2)
6
-
7
- function readArg(name, fallback = null) {
8
- const index = args.indexOf(name)
9
- if (index === -1) return fallback
10
- return args[index + 1] ?? fallback
11
- }
12
-
13
- const target = path.resolve(readArg('--target', process.cwd()))
14
- const force = args.includes('--force')
15
- const requestedMode = readArg('--mode', 'auto')
16
- const hostAdaptersArg = readArg('--host-adapters', 'auto')
17
- const validModes = new Set(['auto', 'lite', 'standard', 'enterprise'])
18
- const validHostAdapters = new Set(['auto', 'all', 'none'])
19
-
20
- if (!validModes.has(requestedMode)) {
21
- console.error(`Invalid --mode "${requestedMode}". Expected one of: auto, lite, standard, enterprise.`)
22
- process.exit(1)
23
- }
24
-
25
- if (!validHostAdapters.has(hostAdaptersArg) && !hostAdaptersArg.split(',').every((item) => ['codex', 'claude'].includes(item.trim()))) {
26
- console.error(`Invalid --host-adapters "${hostAdaptersArg}". Expected auto, all, none, codex, claude, or codex,claude.`)
27
- process.exit(1)
28
- }
29
-
30
- const gseDir = path.join(target, '.gse')
31
- const date = new Date().toISOString().slice(0, 10)
32
-
33
- function exists(relativePath) {
34
- return fs.existsSync(path.join(target, relativePath))
35
- }
36
-
37
- function safeJson(relativePath) {
38
- const fullPath = path.join(target, relativePath)
39
- if (!fs.existsSync(fullPath)) return null
40
- try {
41
- return JSON.parse(fs.readFileSync(fullPath, 'utf8').replace(/^\uFEFF/, ''))
42
- } catch {
43
- return null
44
- }
45
- }
46
-
47
- function listTopLevelDirs() {
48
- if (!fs.existsSync(target)) return []
49
- return fs
50
- .readdirSync(target, { withFileTypes: true })
51
- .filter((entry) => entry.isDirectory())
52
- .map((entry) => entry.name)
53
- }
54
-
55
- function detectMode() {
56
- const pkg = safeJson('package.json')
57
- const scripts = pkg?.scripts ?? {}
58
- const deps = { ...(pkg?.dependencies ?? {}), ...(pkg?.devDependencies ?? {}) }
59
- const topLevelDirs = listTopLevelDirs()
60
- const reasons = []
61
-
62
- const enterpriseSignals = [
63
- ['.mcp.json', exists('.mcp.json')],
64
- ['.claude/', exists('.claude')],
65
- ['.codex/', exists('.codex')],
66
- ['.agents/', exists('.agents')],
67
- ['hooks/', exists('hooks') || exists('.gse/hooks')],
68
- ['plugins/', exists('plugins') || exists('.gse/plugins')],
69
- ['release workflow', exists('release.md') || exists('CHANGELOG.md') || Boolean(scripts.release || scripts.deploy || scripts['release:dry-run'])],
70
- ['multiple app/package directories', topLevelDirs.filter((name) => ['apps', 'packages', 'services', 'workers'].includes(name)).length >= 2],
71
- ].filter(([, ok]) => ok)
72
-
73
- if (enterpriseSignals.length > 0) {
74
- reasons.push(...enterpriseSignals.map(([label]) => label))
75
- return { mode: 'enterprise', reasons }
76
- }
77
-
78
- const standardSignals = [
79
- ['package.json', Boolean(pkg)],
80
- ['project rules', exists('AGENTS.md') || exists('CLAUDE.md') || exists('README.md')],
81
- ['CI workflow', exists('.github/workflows') || exists('.gitlab-ci.yml')],
82
- ['browser/test config', exists('playwright.config.ts') || exists('playwright.config.js') || exists('vitest.config.ts') || exists('jest.config.js')],
83
- ['TypeScript', exists('tsconfig.json') || Boolean(deps.typescript)],
84
- ['test/build scripts', Boolean(scripts.test || scripts.build || scripts.typecheck || scripts.lint)],
85
- ['docs directory', exists('docs')],
86
- ].filter(([, ok]) => ok)
87
-
88
- if (standardSignals.length >= 2) {
89
- reasons.push(...standardSignals.map(([label]) => label))
90
- return { mode: 'standard', reasons }
91
- }
92
-
93
- if (standardSignals.length === 1) reasons.push(...standardSignals.map(([label]) => label))
94
- if (reasons.length === 0) reasons.push('empty or minimal project')
95
- return { mode: 'lite', reasons }
96
- }
97
-
98
- const autoSelection = requestedMode === 'auto' ? detectMode() : { mode: requestedMode, reasons: ['explicit --mode ' + requestedMode] }
99
- const mode = autoSelection.mode
100
-
101
- function renderJson(value) {
102
- return JSON.stringify(value, null, 2) + '\n'
103
- }
104
-
105
- function writeIfMissing(relativePath, content) {
106
- const filePath = path.join(gseDir, relativePath)
107
- fs.mkdirSync(path.dirname(filePath), { recursive: true })
108
- if (!force && fs.existsSync(filePath)) {
109
- return { relativePath, status: 'skipped' }
110
- }
111
- fs.writeFileSync(filePath, content.trimStart().replace(/\n/g, '\r\n'), 'utf8')
112
- return { relativePath, status: 'written' }
113
- }
114
-
115
- function writeProjectFileIfMissing(relativePath, content) {
116
- const filePath = path.join(target, relativePath)
117
- fs.mkdirSync(path.dirname(filePath), { recursive: true })
118
- if (!force && fs.existsSync(filePath)) return { relativePath, status: 'skipped' }
119
- fs.writeFileSync(filePath, content.trimStart().replace(/\n/g, '\r\n'), 'utf8')
120
- return { relativePath, status: 'written' }
121
- }
122
-
123
- const hostAdapterConfigs = {
124
- codex: {
125
- path: '.codex/gse-adapter.md',
126
- title: 'Codex Adapter',
127
- bullets: [
128
- 'Start meaningful work from `.gse/project-profile.md`, `.gse/goal-map.md`, and `.gse/quality-gates.md`.',
129
- 'Use `.gse/goals/` for module-level goal details when the root goal map becomes too large.',
130
- 'Record current-session evidence before marking subagents, MCP, browser, LSP, or model routing as verified.',
131
- ],
132
- },
133
- claude: {
134
- path: '.claude/gse-adapter.md',
135
- title: 'Claude Code Adapter',
136
- bullets: [
137
- 'Commands, agents, hooks, and skills should point back to `.gse/` for goals, evidence, quality gates, and learning rules.',
138
- 'Keep host-specific prompts short; keep reusable workflow policy in `.gse/`.',
139
- 'Use `.gse/goals/` for module-level goal details when the root goal map becomes too large.',
140
- ],
141
- },
142
- }
143
-
144
- function selectedHostAdapters() {
145
- if (mode !== 'enterprise') return []
146
- if (hostAdaptersArg === 'none') return []
147
- if (hostAdaptersArg === 'all') return Object.keys(hostAdapterConfigs)
148
- if (hostAdaptersArg !== 'auto') return hostAdaptersArg.split(',').map((item) => item.trim()).filter(Boolean)
149
- return Object.keys(hostAdapterConfigs).filter((host) => exists(host === 'codex' ? '.codex' : '.claude'))
150
- }
151
-
152
- function renderHostAdapter(config) {
153
- return `# ${config.title}
154
-
155
- Source of truth: \`.gse/\`.
156
-
157
- ${config.bullets.map((item) => '- ' + item).join('\n')}
158
-
159
- Capability status vocabulary: \`verified\`, \`documented\`, \`unknown\`, \`unavailable\`.
160
- `
161
- }
162
-
163
- fs.mkdirSync(gseDir, { recursive: true })
164
- fs.mkdirSync(path.join(gseDir, 'changes'), { recursive: true })
165
- fs.mkdirSync(path.join(gseDir, 'evidence'), { recursive: true })
166
- fs.mkdirSync(path.join(gseDir, 'templates'), { recursive: true })
167
- fs.mkdirSync(path.join(gseDir, 'goals'), { recursive: true })
168
-
169
- if (mode === 'standard' || mode === 'enterprise') {
170
- for (const dir of ['agents', 'skills', 'lsp']) {
171
- fs.mkdirSync(path.join(gseDir, dir), { recursive: true })
172
- }
173
- }
174
-
175
- if (mode === 'enterprise') {
176
- for (const dir of ['hooks', 'mcp', 'plugins']) {
177
- fs.mkdirSync(path.join(gseDir, dir), { recursive: true })
178
- }
179
- }
180
-
181
- const results = [
182
- writeIfMissing(
183
- 'state.json',
184
- renderJson({
185
- schemaVersion: 1,
186
- projectName: path.basename(target),
187
- mode,
188
- canonicalPlan: '',
189
- phase: 'adopt',
190
- currentSlice: {
191
- id: '',
192
- outcome: '',
193
- status: 'planned',
194
- nextAction: 'Fill .gse/goal-map.md and choose the next verifiable slice.',
195
- },
196
- toolStatuses: {
197
- browser: 'unknown',
198
- lsp: 'unknown',
199
- mcp: 'unknown',
200
- subagents: 'unknown',
201
- ci: 'unknown',
202
- },
203
- lastEvidence: '.gse/evidence/index.jsonl',
204
- residualRisks: [
205
- 'Project commands and host tools are unknown until verified in this repository.',
206
- ],
207
- }),
208
- ),
209
- writeIfMissing(
210
- 'evidence/index.jsonl',
211
- JSON.stringify({
212
- date,
213
- recordType: 'adoption',
214
- status: 'result',
215
- summary: `Initialized GSE ${mode} scaffold.`,
216
- evidenceFile: `.gse/evidence/${date}.md`,
217
- commands: [`node <gse-skill>/scripts/init-project.mjs --target <project-root> --mode ${requestedMode}`],
218
- nextAction: 'Record project-specific profile, canonical plan, quality gates, and first verified slice.',
219
- }) + '\n',
220
- ),
221
- writeIfMissing(
222
- 'README.md',
223
- `# GSE Workflow
224
-
225
- This project uses GSE: Goal-Spec-Evidence Engineering.
226
-
227
- Start meaningful work by reading:
228
-
229
- 1. Project agent rules, such as AGENTS.md or CLAUDE.md.
230
- 2. .gse/state.json.
231
- 3. .gse/project-profile.md.
232
- 4. .gse/goal-map.md.
233
- 5. .gse/quality-gates.md.
234
- 6. The relevant change folder under .gse/changes/ when one exists.
235
-
236
- Core loop:
237
-
238
- \`\`\`text
239
- Goal -> Spec -> Execute -> Evidence -> Learn
240
- \`\`\`
241
-
242
- Keep the workflow as light as the task allows and as rigorous as the risk requires.
243
-
244
- Bootstrap mode: ${mode}
245
- Mode selection: ${requestedMode === 'auto' ? 'auto' : 'manual'}
246
- Selection reasons: ${autoSelection.reasons.join(', ')}
247
- `,
248
- ),
249
- writeIfMissing(
250
- 'project-profile.md',
251
- `# Project Profile
252
-
253
- Keep this file short and factual. Project-specific rules override generic GSE defaults.
254
-
255
- ## Identity
256
-
257
- - Product/system name:
258
- - Repository type:
259
- - Main languages/frameworks:
260
-
261
- ## Development Commands
262
-
263
- - Install:
264
- - Dev server:
265
- - Focused test:
266
- - Typecheck/lint/build:
267
- - Encoding or generated-file checks:
268
-
269
- ## Standards
270
-
271
- - Coding standards:
272
- - Formatting:
273
- - Testing expectations:
274
- - Documentation expectations:
275
-
276
- ## Tool Connections
277
-
278
- | Tool | Purpose | Command/config | Status |
279
- |---|---|---|---|
280
- | rg | Search files/text | rg / rg --files | recommended |
281
- | LSP/index | Symbol navigation | - | unknown |
282
- | Browser/Playwright | UI smoke | - | unknown |
283
- | MCP | External tools/data | - | unknown |
284
- | CI | Automated gates | - | unknown |
285
- | Deploy | Release path | - | unknown |
286
-
287
- ## Agent Host Adapters
288
-
289
- - Codex:
290
- - Claude Code:
291
- - Hermes/AION-style runtime:
292
- - WorkBuddy/other:
293
-
294
- ## Security And Permissions
295
-
296
- - Secrets handling:
297
- - Write-capable tools:
298
- - Destructive commands:
299
- - External services:
300
-
301
- ## Release And Rollback
302
-
303
- - Release command/process:
304
- - Rollback:
305
- - Smoke checks:
306
-
307
- ## Known Gotchas
308
-
309
- - Add recurring project-specific issues here.
310
- `,
311
- ),
312
- writeIfMissing(
313
- 'goal-map.md',
314
- `# Goal Map
315
-
316
- Updated: ${date}
317
-
318
- ## North Star
319
-
320
- Describe the durable project outcome here.
321
-
322
- ## Current Focus
323
-
324
- - Priority: P0
325
- - Active slice: Define the next verifiable slice.
326
- - Next action: Fill this in before implementation starts.
327
-
328
- ## Goal Nodes
329
-
330
- | ID | Goal | Status | Priority | Evidence | Next Slice |
331
- |---|---|---|---|---|---|
332
- | G-001 | Establish project workflow | planned | P1 | - | Initialize GSE and bind first real task |
333
-
334
- ## Risks
335
-
336
- - Add project-specific risks here.
337
- `,
338
- ),
339
- writeIfMissing(
340
- 'quality-gates.md',
341
- `# Quality Gates
342
-
343
- ## Universal
344
-
345
- - Outcome, scope, acceptance, evidence, and next action are explicit.
346
- - Verification matches the task risk.
347
- - No unrelated files are staged or committed.
348
-
349
- ## Code
350
-
351
- - Run focused tests for changed behavior.
352
- - Run typecheck, lint, or build when relevant.
353
-
354
- ## UI
355
-
356
- - Use browser, Playwright, component tests, or screenshots for visible behavior.
357
-
358
- ## Release
359
-
360
- - Record migration, rollback, and known risks for release-impacting work.
361
-
362
- ## Learning
363
-
364
- - Capture reusable lessons and promote recurring issues into gates.
365
- `,
366
- ),
367
- writeIfMissing(
368
- 'tooling.md',
369
- `# Tooling
370
-
371
- Minimum tools: git, shell, and project test/build commands.
372
-
373
- Recommended tools:
374
-
375
- - rg / rg --files for fast search.
376
- - LSP or code index for large projects.
377
- - Browser or Playwright for UI verification.
378
- - OpenSpec for capability specs.
379
- - Comet for change lifecycle when available.
380
- - Self-improvement or learnings files for durable lessons.
381
-
382
- Do not claim a tool was used when it was not available.
383
- `,
384
- ),
385
- writeIfMissing(
386
- 'learnings.md',
387
- `# Learnings
388
-
389
- Record only reusable lessons.
390
-
391
- ## Template
392
-
393
- ### YYYY-MM-DD - Short title
394
-
395
- - Trigger:
396
- - Lesson:
397
- - Prevention:
398
- - Promotion target:
399
- `,
400
- ),
401
- writeIfMissing(
402
- 'templates/change-brief.md',
403
- `# Change Brief
404
-
405
- ## Outcome
406
-
407
- ## Scope
408
-
409
- ## Non-goals
410
-
411
- ## Acceptance
412
-
413
- ## Evidence Plan
414
-
415
- ## Risks
416
-
417
- ## Next Action
418
- `,
419
- ),
420
- writeIfMissing(
421
- 'templates/evidence.md',
422
- `# Evidence
423
-
424
- ## Commands
425
-
426
- ## Results
427
-
428
- ## Files Changed
429
-
430
- ## Residual Risk
431
-
432
- ## Follow-up
433
- `,
434
- ),
435
- writeIfMissing(
436
- 'templates/spec.md',
437
- `# Spec
438
-
439
- ## User Outcome
440
-
441
- ## Behavior
442
-
443
- ## State / Data Flow
444
-
445
- ## Error and Recovery
446
-
447
- ## Permissions and Privacy
448
-
449
- ## Acceptance Criteria
450
-
451
- ## Non-goals
452
- `,
453
- ),
454
- writeIfMissing(
455
- 'templates/design.md',
456
- `# Design
457
-
458
- ## Approach
459
-
460
- ## State / Data Flow
461
-
462
- ## Interfaces And Contracts
463
-
464
- ## Permissions And Privacy
465
-
466
- ## Error And Recovery
467
-
468
- ## Alternatives Considered
469
-
470
- ## Rollback
471
-
472
- ## Open Questions
473
- `,
474
- ),
475
- writeIfMissing(
476
- 'templates/tasks.md',
477
- `# Tasks
478
-
479
- ## Slice Plan
480
-
481
- - [ ] Define outcome, scope, acceptance, evidence, risk, and next action.
482
- - [ ] Locate existing patterns and ownership boundaries.
483
- - [ ] Implement the smallest verifiable change.
484
- - [ ] Run focused verification.
485
- - [ ] Record evidence and residual risk.
486
- - [ ] Update state, goal map, and handoff notes when relevant.
487
-
488
- ## Non-Goals
489
-
490
- ## Dependencies
491
-
492
- ## Stop Conditions
493
- `,
494
- ),
495
- writeIfMissing(
496
- 'templates/review.md',
497
- `# Review
498
-
499
- ## Spec Compliance
500
-
501
- ## Code Quality
502
-
503
- ## Architecture / Ownership
504
-
505
- ## Security / Privacy
506
-
507
- ## Regression Risk
508
-
509
- ## Evidence Review
510
-
511
- ## Findings
512
-
513
- ## Closure
514
- `,
515
- ),
516
- writeIfMissing(
517
- 'templates/execution-quality-pack.md',
518
- `# Execution Quality Pack
519
-
520
- ## Task Profile
521
-
522
- - Level: lite | standard | enterprise
523
- - Change type:
524
- - User-visible impact:
525
- - Data/security/release impact:
526
-
527
- ## Required Skills Or Roles
528
-
529
- | Role / Skill | Purpose | Required | Evidence |
530
- |---|---|---|---|
531
- | Coordinator | Scope, final judgment, integration | yes | plan/state/evidence |
532
- | Code Locator | Files, symbols, existing tests | when code changes | search/LSP notes |
533
- | Builder | Bounded implementation | when files change | diff + focused check |
534
- | QA / Verification | Focused proof | yes | command/browser/API smoke |
535
- | Reviewer | Spec, quality, architecture, security | risk-based | review notes |
536
-
537
- ## Tool Routing
538
-
539
- ## Quality Gates Selected
540
-
541
- ## Evidence Plan
542
-
543
- ## Review And Closure
544
- `,
545
- ),
546
- writeIfMissing(
547
- 'goals/README.md',
548
- `# Goal Details
549
-
550
- Use this folder for module-level or stream-level goal details when \`.gse/goal-map.md\` becomes too large.
551
-
552
- Keep \`.gse/goal-map.md\` as the short index:
553
-
554
- - North Star
555
- - Current focus
556
- - Top goal nodes
557
- - Risks
558
- - Next slices
559
-
560
- Put detailed module goals here, for example:
561
-
562
- - \`frontend.md\`
563
- - \`backend.md\`
564
- - \`memory.md\`
565
- - \`worker.md\`
566
- - \`release.md\`
567
- `,
568
- ),
569
- ]
570
-
571
- if (mode === 'standard' || mode === 'enterprise') {
572
- results.push(
573
- writeIfMissing(
574
- 'agent-workspace.md',
575
- `# Agent Workspace
576
-
577
- This project keeps portable agent workflow files under .gse/.
578
-
579
- Host-specific folders such as .codex/, .claude/, .agents/, or runtime-specific directories may point back here, but .gse/ is the source of truth.
580
-
581
- ## Local Map
582
-
583
- - Goal map: .gse/goal-map.md
584
- - Quality gates: .gse/quality-gates.md
585
- - Agent roles: .gse/agents/roles.md
586
- - Dispatch rules: .gse/agents/dispatch.md
587
- - Project skills: .gse/skills/README.md
588
- - LSP/index notes: .gse/lsp/README.md
589
-
590
- ## Adapter Rule
591
-
592
- Do not duplicate the whole workflow into a host-specific folder. Add a short pointer from that host folder back to .gse/ when needed.
593
- `,
594
- ),
595
- writeIfMissing(
596
- 'agents/roles.md',
597
- `# Agent Roles
598
-
599
- Use these roles as boundaries, whether they are executed by real subagents or sequentially by one agent.
600
-
601
- | Role | Responsibility | Write Access |
602
- |---|---|---|
603
- | Coordinator | Scope, context, final judgment, integration | yes |
604
- | Product Analyst | Outcome, user pain, priority, non-goals | docs only |
605
- | Architect | Contracts, data flow, risks, rollback | docs/code by assignment |
606
- | Code Locator | Files, symbols, call chains, existing tests | no |
607
- | Builder | Bounded implementation slice | assigned files only |
608
- | Reviewer | Diff review, regressions, missing tests | no |
609
- | QA | Focused verification and evidence | test/evidence only |
610
- | Docs/Evidence | Slice log, ADR links, learning entries | docs only |
611
- `,
612
- ),
613
- writeIfMissing(
614
- 'agents/dispatch.md',
615
- `# Agent Dispatch
616
-
617
- Use real subagent tools only when the host exposes them.
618
-
619
- ## Dispatch Packet
620
-
621
- - Role:
622
- - Objective:
623
- - Allowed files:
624
- - Forbidden actions:
625
- - Expected output:
626
- - Verification:
627
-
628
- ## Rules
629
-
630
- - Do not delegate final judgment.
631
- - Avoid parallel writes to the same file.
632
- - Say explicitly when subagent tools are unavailable and execute roles sequentially.
633
- - Keep prompts free of expected answers when using agents for validation.
634
- `,
635
- ),
636
- writeIfMissing(
637
- 'skills/README.md',
638
- `# Project Skills
639
-
640
- Record project-local skills and reusable workflows here.
641
-
642
- ## Inventory
643
-
644
- | Skill | Host | Purpose | Source | Status |
645
- |---|---|---|---|---|
646
-
647
- ## Rules
648
-
649
- - Prefer portable instructions under .gse/ when a workflow is useful across hosts.
650
- - Keep host-specific skills small and point back to .gse/ for project policy.
651
- - Do not claim a skill exists unless it is installed or documented here.
652
- `,
653
- ),
654
- writeIfMissing(
655
- 'lsp/README.md',
656
- `# LSP And Indexing
657
-
658
- Record code navigation tools for this project.
659
-
660
- ## Commands
661
-
662
- - Search files: rg --files
663
- - Search text: rg "pattern"
664
- - LSP/index command:
665
-
666
- ## Notes
667
-
668
- - Prefer symbol navigation for large projects when available.
669
- - Fall back to rg and existing tests when LSP is unavailable.
670
- `,
671
- ),
672
- )
673
- }
674
-
675
- if (mode === 'enterprise') {
676
- results.push(
677
- writeIfMissing(
678
- 'hooks/README.md',
679
- `# Hooks
680
-
681
- Record host-specific automation hooks here.
682
-
683
- ## Hook Inventory
684
-
685
- | Hook | Host | Trigger | Command | Risk |
686
- |---|---|---|---|---|
687
-
688
- ## Rules
689
-
690
- - Hooks must be explicit, reversible, and safe for the project.
691
- - Keep secrets out of hook files.
692
- - Document any destructive or networked behavior before enabling it.
693
- `,
694
- ),
695
- writeIfMissing(
696
- 'mcp/README.md',
697
- `# MCP
698
-
699
- Record MCP servers, permissions, and setup notes here.
700
-
701
- ## Servers
702
-
703
- | Server | Purpose | Permissions | Setup | Owner |
704
- |---|---|---|---|---|
705
-
706
- ## Rules
707
-
708
- - Keep real secrets out of source control.
709
- - Document write-capable tools and approval expectations.
710
- `,
711
- ),
712
- writeIfMissing(
713
- 'plugins/README.md',
714
- `# Plugins
715
-
716
- Record optional host plugins and runtime adapters here.
717
-
718
- ## Inventory
719
-
720
- | Plugin | Host | Purpose | Required | Notes |
721
- |---|---|---|---|---|
722
-
723
- ## Rules
724
-
725
- - Plugins are optional accelerators unless the project explicitly requires them.
726
- - Provide a markdown fallback when a plugin is unavailable.
727
- `,
728
- ),
729
- writeIfMissing(
730
- 'release.md',
731
- `# Release
732
-
733
- ## Checklist
734
-
735
- - Version or deployment target:
736
- - Migration:
737
- - Rollback:
738
- - Smoke test:
739
- - Known risks:
740
- `,
741
- ),
742
- writeIfMissing(
743
- 'incident-review.md',
744
- `# Incident Review
745
-
746
- ## Summary
747
-
748
- ## Impact
749
-
750
- ## Timeline
751
-
752
- ## Root Cause
753
-
754
- ## Fix
755
-
756
- ## Prevention
757
- `,
758
- ),
759
- writeIfMissing(
760
- 'audit.md',
761
- `# GSE Audit
762
-
763
- ## Coverage
764
-
765
- - Goal map:
766
- - Specs:
767
- - Evidence:
768
- - Quality gates:
769
- - Tooling:
770
- - Learning loop:
771
-
772
- ## Gaps
773
-
774
- ## Next Improvements
775
- `,
776
- ),
777
- )
778
- }
779
-
780
- for (const host of selectedHostAdapters()) {
781
- const config = hostAdapterConfigs[host]
782
- results.push(writeProjectFileIfMissing(config.path, renderHostAdapter(config)))
783
- }
784
-
785
- console.log(JSON.stringify({ target, gseDir, force, requestedMode, mode, selectionReasons: autoSelection.reasons, hostAdapters: selectedHostAdapters(), results }, null, 2))
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs'
3
+ import path from 'node:path'
4
+
5
+ const args = process.argv.slice(2)
6
+
7
+ function readArg(name, fallback = null) {
8
+ const index = args.indexOf(name)
9
+ if (index === -1) return fallback
10
+ return args[index + 1] ?? fallback
11
+ }
12
+
13
+ const target = path.resolve(readArg('--target', process.cwd()))
14
+ const force = args.includes('--force')
15
+ const requestedMode = readArg('--mode', 'auto')
16
+ const hostAdaptersArg = readArg('--host-adapters', 'auto')
17
+ const validModes = new Set(['auto', 'lite', 'standard', 'enterprise'])
18
+ const validHostAdapters = new Set(['auto', 'all', 'none'])
19
+
20
+ if (!validModes.has(requestedMode)) {
21
+ console.error(`Invalid --mode "${requestedMode}". Expected one of: auto, lite, standard, enterprise.`)
22
+ process.exit(1)
23
+ }
24
+
25
+ if (!validHostAdapters.has(hostAdaptersArg) && !hostAdaptersArg.split(',').every((item) => ['codex', 'claude'].includes(item.trim()))) {
26
+ console.error(`Invalid --host-adapters "${hostAdaptersArg}". Expected auto, all, none, codex, claude, or codex,claude.`)
27
+ process.exit(1)
28
+ }
29
+
30
+ const gseDir = path.join(target, '.gse')
31
+ const date = new Date().toISOString().slice(0, 10)
32
+
33
+ function exists(relativePath) {
34
+ return fs.existsSync(path.join(target, relativePath))
35
+ }
36
+
37
+ function safeJson(relativePath) {
38
+ const fullPath = path.join(target, relativePath)
39
+ if (!fs.existsSync(fullPath)) return null
40
+ try {
41
+ return JSON.parse(fs.readFileSync(fullPath, 'utf8').replace(/^\uFEFF/, ''))
42
+ } catch {
43
+ return null
44
+ }
45
+ }
46
+
47
+ function listTopLevelDirs() {
48
+ if (!fs.existsSync(target)) return []
49
+ return fs
50
+ .readdirSync(target, { withFileTypes: true })
51
+ .filter((entry) => entry.isDirectory())
52
+ .map((entry) => entry.name)
53
+ }
54
+
55
+ function detectMode() {
56
+ const pkg = safeJson('package.json')
57
+ const scripts = pkg?.scripts ?? {}
58
+ const deps = { ...(pkg?.dependencies ?? {}), ...(pkg?.devDependencies ?? {}) }
59
+ const topLevelDirs = listTopLevelDirs()
60
+ const reasons = []
61
+
62
+ const enterpriseSignals = [
63
+ ['.mcp.json', exists('.mcp.json')],
64
+ ['.claude/', exists('.claude')],
65
+ ['.codex/', exists('.codex')],
66
+ ['.agents/', exists('.agents')],
67
+ ['hooks/', exists('hooks') || exists('.gse/hooks')],
68
+ ['plugins/', exists('plugins') || exists('.gse/plugins')],
69
+ ['release workflow', exists('release.md') || exists('CHANGELOG.md') || Boolean(scripts.release || scripts.deploy || scripts['release:dry-run'])],
70
+ ['multiple app/package directories', topLevelDirs.filter((name) => ['apps', 'packages', 'services', 'workers'].includes(name)).length >= 2],
71
+ ].filter(([, ok]) => ok)
72
+
73
+ if (enterpriseSignals.length > 0) {
74
+ reasons.push(...enterpriseSignals.map(([label]) => label))
75
+ return { mode: 'enterprise', reasons }
76
+ }
77
+
78
+ const standardSignals = [
79
+ ['package.json', Boolean(pkg)],
80
+ ['project rules', exists('AGENTS.md') || exists('CLAUDE.md') || exists('README.md')],
81
+ ['CI workflow', exists('.github/workflows') || exists('.gitlab-ci.yml')],
82
+ ['browser/test config', exists('playwright.config.ts') || exists('playwright.config.js') || exists('vitest.config.ts') || exists('jest.config.js')],
83
+ ['TypeScript', exists('tsconfig.json') || Boolean(deps.typescript)],
84
+ ['test/build scripts', Boolean(scripts.test || scripts.build || scripts.typecheck || scripts.lint)],
85
+ ['docs directory', exists('docs')],
86
+ ].filter(([, ok]) => ok)
87
+
88
+ if (standardSignals.length >= 2) {
89
+ reasons.push(...standardSignals.map(([label]) => label))
90
+ return { mode: 'standard', reasons }
91
+ }
92
+
93
+ if (standardSignals.length === 1) reasons.push(...standardSignals.map(([label]) => label))
94
+ if (reasons.length === 0) reasons.push('empty or minimal project')
95
+ return { mode: 'lite', reasons }
96
+ }
97
+
98
+ const autoSelection = requestedMode === 'auto' ? detectMode() : { mode: requestedMode, reasons: ['explicit --mode ' + requestedMode] }
99
+ const mode = autoSelection.mode
100
+
101
+ function renderJson(value) {
102
+ return JSON.stringify(value, null, 2) + '\n'
103
+ }
104
+
105
+ function writeIfMissing(relativePath, content) {
106
+ const filePath = path.join(gseDir, relativePath)
107
+ fs.mkdirSync(path.dirname(filePath), { recursive: true })
108
+ if (!force && fs.existsSync(filePath)) {
109
+ return { relativePath, status: 'skipped' }
110
+ }
111
+ fs.writeFileSync(filePath, content.trimStart().replace(/\n/g, '\r\n'), 'utf8')
112
+ return { relativePath, status: 'written' }
113
+ }
114
+
115
+ function writeProjectFileIfMissing(relativePath, content) {
116
+ const filePath = path.join(target, relativePath)
117
+ fs.mkdirSync(path.dirname(filePath), { recursive: true })
118
+ if (!force && fs.existsSync(filePath)) return { relativePath, status: 'skipped' }
119
+ fs.writeFileSync(filePath, content.trimStart().replace(/\n/g, '\r\n'), 'utf8')
120
+ return { relativePath, status: 'written' }
121
+ }
122
+
123
+ const hostAdapterConfigs = {
124
+ codex: {
125
+ path: '.codex/gse-adapter.md',
126
+ title: 'Codex Adapter',
127
+ bullets: [
128
+ 'Start meaningful work from `.gse/project-profile.md`, `.gse/goal-map.md`, and `.gse/quality-gates.md`.',
129
+ 'Use `.gse/goals/` for module-level goal details when the root goal map becomes too large.',
130
+ 'Record current-session evidence before marking subagents, MCP, browser, LSP, or model routing as verified.',
131
+ ],
132
+ },
133
+ claude: {
134
+ path: '.claude/gse-adapter.md',
135
+ title: 'Claude Code Adapter',
136
+ bullets: [
137
+ 'Commands, agents, hooks, and skills should point back to `.gse/` for goals, evidence, quality gates, and learning rules.',
138
+ 'Keep host-specific prompts short; keep reusable workflow policy in `.gse/`.',
139
+ 'Use `.gse/goals/` for module-level goal details when the root goal map becomes too large.',
140
+ ],
141
+ },
142
+ }
143
+
144
+ function selectedHostAdapters() {
145
+ if (mode !== 'enterprise') return []
146
+ if (hostAdaptersArg === 'none') return []
147
+ if (hostAdaptersArg === 'all') return Object.keys(hostAdapterConfigs)
148
+ if (hostAdaptersArg !== 'auto') return hostAdaptersArg.split(',').map((item) => item.trim()).filter(Boolean)
149
+ return Object.keys(hostAdapterConfigs).filter((host) => exists(host === 'codex' ? '.codex' : '.claude'))
150
+ }
151
+
152
+ function renderHostAdapter(config) {
153
+ return `# ${config.title}
154
+
155
+ Source of truth: \`.gse/\`.
156
+
157
+ ${config.bullets.map((item) => '- ' + item).join('\n')}
158
+
159
+ Capability status vocabulary: \`verified\`, \`documented\`, \`unknown\`, \`unavailable\`.
160
+ `
161
+ }
162
+
163
+ fs.mkdirSync(gseDir, { recursive: true })
164
+ fs.mkdirSync(path.join(gseDir, 'changes'), { recursive: true })
165
+ fs.mkdirSync(path.join(gseDir, 'evidence'), { recursive: true })
166
+ fs.mkdirSync(path.join(gseDir, 'templates'), { recursive: true })
167
+ fs.mkdirSync(path.join(gseDir, 'goals'), { recursive: true })
168
+
169
+ if (mode === 'standard' || mode === 'enterprise') {
170
+ for (const dir of ['agents', 'skills', 'lsp']) {
171
+ fs.mkdirSync(path.join(gseDir, dir), { recursive: true })
172
+ }
173
+ }
174
+
175
+ if (mode === 'enterprise') {
176
+ for (const dir of ['hooks', 'mcp', 'plugins']) {
177
+ fs.mkdirSync(path.join(gseDir, dir), { recursive: true })
178
+ }
179
+ }
180
+
181
+ const results = [
182
+ writeIfMissing(
183
+ 'state.json',
184
+ renderJson({
185
+ schemaVersion: 1,
186
+ projectName: path.basename(target),
187
+ mode,
188
+ canonicalPlan: '',
189
+ phase: 'adopt',
190
+ currentSlice: {
191
+ id: '',
192
+ outcome: '',
193
+ status: 'planned',
194
+ nextAction: 'Fill .gse/goal-map.md and choose the next verifiable slice.',
195
+ },
196
+ toolStatuses: {
197
+ browser: 'unknown',
198
+ lsp: 'unknown',
199
+ mcp: 'unknown',
200
+ subagents: 'unknown',
201
+ ci: 'unknown',
202
+ },
203
+ lastEvidence: '.gse/evidence/index.jsonl',
204
+ residualRisks: [
205
+ 'Project commands and host tools are unknown until verified in this repository.',
206
+ ],
207
+ }),
208
+ ),
209
+ writeIfMissing(
210
+ 'evidence/index.jsonl',
211
+ JSON.stringify({
212
+ date,
213
+ recordType: 'adoption',
214
+ status: 'result',
215
+ summary: `Initialized GSE ${mode} scaffold.`,
216
+ evidenceFile: `.gse/evidence/${date}.md`,
217
+ commands: [`node <gse-skill>/scripts/init-project.mjs --target <project-root> --mode ${requestedMode}`],
218
+ nextAction: 'Record project-specific profile, canonical plan, quality gates, and first verified slice.',
219
+ }) + '\n',
220
+ ),
221
+ writeIfMissing(
222
+ 'README.md',
223
+ `# GSE Workflow
224
+
225
+ This project uses GSE: Goal-Spec-Evidence Engineering.
226
+
227
+ Start meaningful work by reading:
228
+
229
+ 1. Project agent rules, such as AGENTS.md or CLAUDE.md.
230
+ 2. .gse/state.json.
231
+ 3. .gse/project-profile.md.
232
+ 4. .gse/goal-map.md.
233
+ 5. .gse/quality-gates.md.
234
+ 6. The relevant change folder under .gse/changes/ when one exists.
235
+
236
+ Core loop:
237
+
238
+ \`\`\`text
239
+ Goal -> Spec -> Execute -> Evidence -> Learn
240
+ \`\`\`
241
+
242
+ Keep the workflow as light as the task allows and as rigorous as the risk requires.
243
+
244
+ Bootstrap mode: ${mode}
245
+ Mode selection: ${requestedMode === 'auto' ? 'auto' : 'manual'}
246
+ Selection reasons: ${autoSelection.reasons.join(', ')}
247
+ `,
248
+ ),
249
+ writeIfMissing(
250
+ 'project-profile.md',
251
+ `# Project Profile
252
+
253
+ Keep this file short and factual. Project-specific rules override generic GSE defaults.
254
+
255
+ ## Identity
256
+
257
+ - Product/system name:
258
+ - Repository type:
259
+ - Main languages/frameworks:
260
+
261
+ ## Development Commands
262
+
263
+ - Install:
264
+ - Dev server:
265
+ - Focused test:
266
+ - Typecheck/lint/build:
267
+ - Encoding or generated-file checks:
268
+
269
+ ## Standards
270
+
271
+ - Coding standards:
272
+ - Formatting:
273
+ - Testing expectations:
274
+ - Documentation expectations:
275
+
276
+ ## Tool Connections
277
+
278
+ | Tool | Purpose | Command/config | Status |
279
+ |---|---|---|---|
280
+ | rg | Search files/text | rg / rg --files | recommended |
281
+ | LSP/index | Symbol navigation | - | unknown |
282
+ | Browser/Playwright | UI smoke | - | unknown |
283
+ | MCP | External tools/data | - | unknown |
284
+ | CI | Automated gates | - | unknown |
285
+ | Deploy | Release path | - | unknown |
286
+
287
+ ## Agent Host Adapters
288
+
289
+ - Codex:
290
+ - Claude Code:
291
+ - Hermes/AION-style runtime:
292
+ - WorkBuddy/other:
293
+
294
+ ## Security And Permissions
295
+
296
+ - Secrets handling:
297
+ - Write-capable tools:
298
+ - Destructive commands:
299
+ - External services:
300
+
301
+ ## Release And Rollback
302
+
303
+ - Release command/process:
304
+ - Rollback:
305
+ - Smoke checks:
306
+
307
+ ## Known Gotchas
308
+
309
+ - Add recurring project-specific issues here.
310
+ `,
311
+ ),
312
+ writeIfMissing(
313
+ 'goal-map.md',
314
+ `# Goal Map
315
+
316
+ Updated: ${date}
317
+
318
+ ## North Star
319
+
320
+ Describe the durable project outcome here.
321
+
322
+ ## Current Focus
323
+
324
+ - Priority: P0
325
+ - Active slice: Define the next verifiable slice.
326
+ - Next action: Fill this in before implementation starts.
327
+
328
+ ## Goal Nodes
329
+
330
+ | ID | Goal | Status | Priority | Evidence | Next Slice |
331
+ |---|---|---|---|---|---|
332
+ | G-001 | Establish project workflow | planned | P1 | - | Initialize GSE and bind first real task |
333
+
334
+ ## Risks
335
+
336
+ - Add project-specific risks here.
337
+ `,
338
+ ),
339
+ writeIfMissing(
340
+ 'quality-gates.md',
341
+ `# Quality Gates
342
+
343
+ ## Universal
344
+
345
+ - Outcome, scope, acceptance, evidence, and next action are explicit.
346
+ - Verification matches the task risk.
347
+ - No unrelated files are staged or committed.
348
+
349
+ ## Code
350
+
351
+ - Run focused tests for changed behavior.
352
+ - Run typecheck, lint, or build when relevant.
353
+
354
+ ## UI
355
+
356
+ - Use browser, Playwright, component tests, or screenshots for visible behavior.
357
+
358
+ ## Release
359
+
360
+ - Record migration, rollback, and known risks for release-impacting work.
361
+
362
+ ## Learning
363
+
364
+ - Capture reusable lessons and promote recurring issues into gates.
365
+ `,
366
+ ),
367
+ writeIfMissing(
368
+ 'tooling.md',
369
+ `# Tooling
370
+
371
+ Minimum tools: git, shell, and project test/build commands.
372
+
373
+ Recommended tools:
374
+
375
+ - rg / rg --files for fast search.
376
+ - LSP or code index for large projects.
377
+ - Browser or Playwright for UI verification.
378
+ - OpenSpec for capability specs.
379
+ - Comet for change lifecycle when available.
380
+ - Self-improvement or learnings files for durable lessons.
381
+
382
+ Do not claim a tool was used when it was not available.
383
+ `,
384
+ ),
385
+ writeIfMissing(
386
+ 'learnings.md',
387
+ `# Learnings
388
+
389
+ Record only reusable lessons.
390
+
391
+ ## Template
392
+
393
+ ### YYYY-MM-DD - Short title
394
+
395
+ - Trigger:
396
+ - Lesson:
397
+ - Prevention:
398
+ - Promotion target:
399
+ `,
400
+ ),
401
+ writeIfMissing(
402
+ 'templates/change-brief.md',
403
+ `# Change Brief
404
+
405
+ ## Outcome
406
+
407
+ ## Scope
408
+
409
+ ## Non-goals
410
+
411
+ ## Acceptance
412
+
413
+ ## Evidence Plan
414
+
415
+ ## Risks
416
+
417
+ ## Next Action
418
+ `,
419
+ ),
420
+ writeIfMissing(
421
+ 'templates/evidence.md',
422
+ `# Evidence
423
+
424
+ ## Commands
425
+
426
+ ## Results
427
+
428
+ ## Files Changed
429
+
430
+ ## Residual Risk
431
+
432
+ ## Follow-up
433
+ `,
434
+ ),
435
+ writeIfMissing(
436
+ 'templates/spec.md',
437
+ `# Spec
438
+
439
+ ## User Outcome
440
+
441
+ ## Behavior
442
+
443
+ ## State / Data Flow
444
+
445
+ ## Error and Recovery
446
+
447
+ ## Permissions and Privacy
448
+
449
+ ## Acceptance Criteria
450
+
451
+ ## Non-goals
452
+ `,
453
+ ),
454
+ writeIfMissing(
455
+ 'templates/design.md',
456
+ `# Design
457
+
458
+ ## Approach
459
+
460
+ ## State / Data Flow
461
+
462
+ ## Interfaces And Contracts
463
+
464
+ ## Permissions And Privacy
465
+
466
+ ## Error And Recovery
467
+
468
+ ## Alternatives Considered
469
+
470
+ ## Rollback
471
+
472
+ ## Open Questions
473
+ `,
474
+ ),
475
+ writeIfMissing(
476
+ 'templates/tasks.md',
477
+ `# Tasks
478
+
479
+ ## Slice Plan
480
+
481
+ - [ ] Define outcome, scope, acceptance, evidence, risk, and next action.
482
+ - [ ] Locate existing patterns and ownership boundaries.
483
+ - [ ] Implement the smallest verifiable change.
484
+ - [ ] Run focused verification.
485
+ - [ ] Record evidence and residual risk.
486
+ - [ ] Update state, goal map, and handoff notes when relevant.
487
+
488
+ ## Non-Goals
489
+
490
+ ## Dependencies
491
+
492
+ ## Stop Conditions
493
+ `,
494
+ ),
495
+ writeIfMissing(
496
+ 'templates/review.md',
497
+ `# Review
498
+
499
+ ## Spec Compliance
500
+
501
+ ## Code Quality
502
+
503
+ ## Architecture / Ownership
504
+
505
+ ## Security / Privacy
506
+
507
+ ## Regression Risk
508
+
509
+ ## Evidence Review
510
+
511
+ ## Findings
512
+
513
+ ## Closure
514
+ `,
515
+ ),
516
+ writeIfMissing(
517
+ 'templates/execution-quality-pack.md',
518
+ `# Execution Quality Pack
519
+
520
+ ## Task Profile
521
+
522
+ - Level: lite | standard | enterprise
523
+ - Change type:
524
+ - User-visible impact:
525
+ - Data/security/release impact:
526
+
527
+ ## Required Skills Or Roles
528
+
529
+ | Role / Skill | Purpose | Required | Evidence |
530
+ |---|---|---|---|
531
+ | Coordinator | Scope, final judgment, integration | yes | plan/state/evidence |
532
+ | Code Locator | Files, symbols, existing tests | when code changes | search/LSP notes |
533
+ | Builder | Bounded implementation | when files change | diff + focused check |
534
+ | QA / Verification | Focused proof | yes | command/browser/API smoke |
535
+ | Reviewer | Spec, quality, architecture, security | risk-based | review notes |
536
+
537
+ ## Tool Routing
538
+
539
+ ## Quality Gates Selected
540
+
541
+ ## Evidence Plan
542
+
543
+ ## Review And Closure
544
+ `,
545
+ ),
546
+ writeIfMissing(
547
+ 'goals/README.md',
548
+ `# Goal Details
549
+
550
+ Use this folder for module-level or stream-level goal details when \`.gse/goal-map.md\` becomes too large.
551
+
552
+ Keep \`.gse/goal-map.md\` as the short index:
553
+
554
+ - North Star
555
+ - Current focus
556
+ - Top goal nodes
557
+ - Risks
558
+ - Next slices
559
+
560
+ Put detailed module goals here, for example:
561
+
562
+ - \`frontend.md\`
563
+ - \`backend.md\`
564
+ - \`memory.md\`
565
+ - \`worker.md\`
566
+ - \`release.md\`
567
+ `,
568
+ ),
569
+ ]
570
+
571
+ if (mode === 'standard' || mode === 'enterprise') {
572
+ results.push(
573
+ writeIfMissing(
574
+ 'agent-workspace.md',
575
+ `# Agent Workspace
576
+
577
+ This project keeps portable agent workflow files under .gse/.
578
+
579
+ Host-specific folders such as .codex/, .claude/, .agents/, or runtime-specific directories may point back here, but .gse/ is the source of truth.
580
+
581
+ ## Local Map
582
+
583
+ - Goal map: .gse/goal-map.md
584
+ - Quality gates: .gse/quality-gates.md
585
+ - Agent roles: .gse/agents/roles.md
586
+ - Dispatch rules: .gse/agents/dispatch.md
587
+ - Project skills: .gse/skills/README.md
588
+ - LSP/index notes: .gse/lsp/README.md
589
+
590
+ ## Adapter Rule
591
+
592
+ Do not duplicate the whole workflow into a host-specific folder. Add a short pointer from that host folder back to .gse/ when needed.
593
+ `,
594
+ ),
595
+ writeIfMissing(
596
+ 'agents/roles.md',
597
+ `# Agent Roles
598
+
599
+ Use these roles as boundaries, whether they are executed by real subagents or sequentially by one agent.
600
+
601
+ | Role | Responsibility | Write Access |
602
+ |---|---|---|
603
+ | Coordinator | Scope, context, final judgment, integration | yes |
604
+ | Product Analyst | Outcome, user pain, priority, non-goals | docs only |
605
+ | Architect | Contracts, data flow, risks, rollback | docs/code by assignment |
606
+ | Code Locator | Files, symbols, call chains, existing tests | no |
607
+ | Builder | Bounded implementation slice | assigned files only |
608
+ | Reviewer | Diff review, regressions, missing tests | no |
609
+ | QA | Focused verification and evidence | test/evidence only |
610
+ | Docs/Evidence | Slice log, ADR links, learning entries | docs only |
611
+ `,
612
+ ),
613
+ writeIfMissing(
614
+ 'agents/dispatch.md',
615
+ `# Agent Dispatch
616
+
617
+ Use real subagent tools only when the host exposes them.
618
+
619
+ ## Dispatch Packet
620
+
621
+ - Role:
622
+ - Objective:
623
+ - Allowed files:
624
+ - Forbidden actions:
625
+ - Expected output:
626
+ - Verification:
627
+
628
+ ## Rules
629
+
630
+ - Do not delegate final judgment.
631
+ - Avoid parallel writes to the same file.
632
+ - Say explicitly when subagent tools are unavailable and execute roles sequentially.
633
+ - Keep prompts free of expected answers when using agents for validation.
634
+ `,
635
+ ),
636
+ writeIfMissing(
637
+ 'skills/README.md',
638
+ `# Project Skills
639
+
640
+ Record project-local skills and reusable workflows here.
641
+
642
+ ## Inventory
643
+
644
+ | Skill | Host | Purpose | Source | Status |
645
+ |---|---|---|---|---|
646
+
647
+ ## Rules
648
+
649
+ - Prefer portable instructions under .gse/ when a workflow is useful across hosts.
650
+ - Keep host-specific skills small and point back to .gse/ for project policy.
651
+ - Do not claim a skill exists unless it is installed or documented here.
652
+ `,
653
+ ),
654
+ writeIfMissing(
655
+ 'lsp/README.md',
656
+ `# LSP And Indexing
657
+
658
+ Record code navigation tools for this project.
659
+
660
+ ## Commands
661
+
662
+ - Search files: rg --files
663
+ - Search text: rg "pattern"
664
+ - LSP/index command:
665
+
666
+ ## Notes
667
+
668
+ - Prefer symbol navigation for large projects when available.
669
+ - Fall back to rg and existing tests when LSP is unavailable.
670
+ `,
671
+ ),
672
+ )
673
+ }
674
+
675
+ if (mode === 'enterprise') {
676
+ results.push(
677
+ writeIfMissing(
678
+ 'hooks/README.md',
679
+ `# Hooks
680
+
681
+ Record host-specific automation hooks here.
682
+
683
+ ## Hook Inventory
684
+
685
+ | Hook | Host | Trigger | Command | Risk |
686
+ |---|---|---|---|---|
687
+
688
+ ## Rules
689
+
690
+ - Hooks must be explicit, reversible, and safe for the project.
691
+ - Keep secrets out of hook files.
692
+ - Document any destructive or networked behavior before enabling it.
693
+ `,
694
+ ),
695
+ writeIfMissing(
696
+ 'mcp/README.md',
697
+ `# MCP
698
+
699
+ Record MCP servers, permissions, and setup notes here.
700
+
701
+ ## Servers
702
+
703
+ | Server | Purpose | Permissions | Setup | Owner |
704
+ |---|---|---|---|---|
705
+
706
+ ## Rules
707
+
708
+ - Keep real secrets out of source control.
709
+ - Document write-capable tools and approval expectations.
710
+ `,
711
+ ),
712
+ writeIfMissing(
713
+ 'plugins/README.md',
714
+ `# Plugins
715
+
716
+ Record optional host plugins and runtime adapters here.
717
+
718
+ ## Inventory
719
+
720
+ | Plugin | Host | Purpose | Required | Notes |
721
+ |---|---|---|---|---|
722
+
723
+ ## Rules
724
+
725
+ - Plugins are optional accelerators unless the project explicitly requires them.
726
+ - Provide a markdown fallback when a plugin is unavailable.
727
+ `,
728
+ ),
729
+ writeIfMissing(
730
+ 'release.md',
731
+ `# Release
732
+
733
+ ## Checklist
734
+
735
+ - Version or deployment target:
736
+ - Migration:
737
+ - Rollback:
738
+ - Smoke test:
739
+ - Known risks:
740
+ `,
741
+ ),
742
+ writeIfMissing(
743
+ 'incident-review.md',
744
+ `# Incident Review
745
+
746
+ ## Summary
747
+
748
+ ## Impact
749
+
750
+ ## Timeline
751
+
752
+ ## Root Cause
753
+
754
+ ## Fix
755
+
756
+ ## Prevention
757
+ `,
758
+ ),
759
+ writeIfMissing(
760
+ 'audit.md',
761
+ `# GSE Audit
762
+
763
+ ## Coverage
764
+
765
+ - Goal map:
766
+ - Specs:
767
+ - Evidence:
768
+ - Quality gates:
769
+ - Tooling:
770
+ - Learning loop:
771
+
772
+ ## Gaps
773
+
774
+ ## Next Improvements
775
+ `,
776
+ ),
777
+ )
778
+ }
779
+
780
+ for (const host of selectedHostAdapters()) {
781
+ const config = hostAdapterConfigs[host]
782
+ results.push(writeProjectFileIfMissing(config.path, renderHostAdapter(config)))
783
+ }
784
+
785
+ console.log(JSON.stringify({ target, gseDir, force, requestedMode, mode, selectionReasons: autoSelection.reasons, hostAdapters: selectedHostAdapters(), results }, null, 2))