@t275005746/gse 0.1.0
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/.github/ISSUE_TEMPLATE/bug_report.yml +42 -0
- package/.github/ISSUE_TEMPLATE/change_request.yml +50 -0
- package/.github/ISSUE_TEMPLATE/config.yml +5 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +38 -0
- package/.github/workflows/validate-gse.yml +33 -0
- package/.gse/README.md +18 -0
- package/.gse/gse-development-protocol.md +50 -0
- package/.gse/project-profile.md +29 -0
- package/.gse/quality-gates.md +25 -0
- package/.gse/releases/public-channel-publication-pending.md +49 -0
- package/.gse/releases/public-ci-run-pending.md +53 -0
- package/.gse/releases/public-release-owner-required.md +65 -0
- package/.gse/releases/public-repository-settings-owner-required.md +59 -0
- package/.gse/releases/public-security-contact-owner-required.md +45 -0
- package/.gse/state.json +27 -0
- package/CHANGELOG.md +24 -0
- package/CONTRIBUTING.md +64 -0
- package/LICENSE +21 -0
- package/README.md +236 -0
- package/README.zh-CN.md +236 -0
- package/SECURITY.md +41 -0
- package/SKILL.md +148 -0
- package/SUPPORT.md +38 -0
- package/agents/openai.yaml +4 -0
- package/assets/marketplace/README.md +7 -0
- package/assets/marketplace/gse-listing.json +75 -0
- package/assets/templates/acceptance-execution-packet.md +73 -0
- package/assets/templates/adr.md +14 -0
- package/assets/templates/change-brief.md +16 -0
- package/assets/templates/design.md +18 -0
- package/assets/templates/dispatch-packet.md +104 -0
- package/assets/templates/evidence.md +14 -0
- package/assets/templates/execution-quality-pack.md +65 -0
- package/assets/templates/goal-map.md +21 -0
- package/assets/templates/host-adapter.md +48 -0
- package/assets/templates/host-ui-invocation-record.md +42 -0
- package/assets/templates/incident-review.md +60 -0
- package/assets/templates/public-channel-publication-record.md +49 -0
- package/assets/templates/public-ci-run-record.md +53 -0
- package/assets/templates/public-release-record.md +65 -0
- package/assets/templates/public-repository-settings-record.md +59 -0
- package/assets/templates/public-security-contact-record.md +45 -0
- package/assets/templates/release-trust-record.md +32 -0
- package/assets/templates/review.md +18 -0
- package/assets/templates/spec.md +16 -0
- package/assets/templates/target-adoption-evidence.md +29 -0
- package/assets/templates/tasks.md +17 -0
- package/assets/templates/update-release-acceptance-record.md +58 -0
- package/examples/README.md +22 -0
- package/examples/agent-runtime-host/.claude/gse-adapter.md +6 -0
- package/examples/agent-runtime-host/.codex/gse-adapter.md +7 -0
- package/examples/agent-runtime-host/.gse/goal-map.md +7 -0
- package/examples/agent-runtime-host/.gse/project-profile.md +27 -0
- package/examples/agent-runtime-host/.gse/tooling.md +5 -0
- package/examples/agent-runtime-host/.mcp.json +9 -0
- package/examples/agent-runtime-host/AGENTS.md +5 -0
- package/examples/agent-runtime-host/README.md +10 -0
- package/examples/agent-runtime-host/docs/model-routing.md +5 -0
- package/examples/cli-tool/.gse/project-profile.md +21 -0
- package/examples/cli-tool/AGENTS.md +5 -0
- package/examples/cli-tool/README.md +12 -0
- package/examples/cli-tool/package.json +21 -0
- package/examples/small-app/.env.example +2 -0
- package/examples/small-app/.github/workflows/ci.yml +8 -0
- package/examples/small-app/AGENTS.md +5 -0
- package/examples/small-app/README.md +12 -0
- package/examples/small-app/package.json +26 -0
- package/examples/small-app/playwright.config.ts +4 -0
- package/package.json +53 -0
- package/references/adoption-recipes.md +171 -0
- package/references/agent-roles.md +49 -0
- package/references/architecture-health.md +101 -0
- package/references/benchmark-audit.md +73 -0
- package/references/commands.md +295 -0
- package/references/community-channels.md +46 -0
- package/references/compatibility.md +70 -0
- package/references/design-basis.md +38 -0
- package/references/domain-model.md +129 -0
- package/references/domain-quality-gates.md +75 -0
- package/references/drift-audit.md +81 -0
- package/references/evidence-taxonomy.md +123 -0
- package/references/file-ownership.md +107 -0
- package/references/final-readiness.md +84 -0
- package/references/forward-test.md +133 -0
- package/references/goal-map.md +36 -0
- package/references/host-adapters.md +119 -0
- package/references/learning-system.md +35 -0
- package/references/marketplace-discovery.md +46 -0
- package/references/model-routing.md +103 -0
- package/references/open-source-defaults.md +39 -0
- package/references/operating-model.md +52 -0
- package/references/packaging.md +277 -0
- package/references/project-agent-workspace.md +89 -0
- package/references/project-bootstrap.md +122 -0
- package/references/project-profile.md +57 -0
- package/references/public-release.md +174 -0
- package/references/quality-gates.md +100 -0
- package/references/recovery.md +176 -0
- package/references/release-trust.md +43 -0
- package/references/release.md +126 -0
- package/references/review.md +141 -0
- package/references/router.md +90 -0
- package/references/spec-workflow.md +66 -0
- package/references/task-levels.md +81 -0
- package/references/tool-adapters.md +73 -0
- package/scripts/audit-acceptance-execution-packet.mjs +133 -0
- package/scripts/audit-adoption-recipes.mjs +99 -0
- package/scripts/audit-adoption.mjs +154 -0
- package/scripts/audit-change-lifecycle.mjs +77 -0
- package/scripts/audit-change-system.mjs +134 -0
- package/scripts/audit-ci-readiness.mjs +107 -0
- package/scripts/audit-close-gate.mjs +323 -0
- package/scripts/audit-command-adapters.mjs +91 -0
- package/scripts/audit-command-execution.mjs +210 -0
- package/scripts/audit-commands.mjs +117 -0
- package/scripts/audit-compatibility.mjs +149 -0
- package/scripts/audit-completion-readiness.mjs +292 -0
- package/scripts/audit-distribution.mjs +251 -0
- package/scripts/audit-domain-quality-gates.mjs +108 -0
- package/scripts/audit-evidence-placeholders.mjs +126 -0
- package/scripts/audit-final-acceptance-packet.mjs +148 -0
- package/scripts/audit-final-form-progress-report.mjs +161 -0
- package/scripts/audit-final-form-stale-copy.mjs +221 -0
- package/scripts/audit-final-readiness-promotion.mjs +255 -0
- package/scripts/audit-final-readiness.mjs +226 -0
- package/scripts/audit-fixtures.mjs +154 -0
- package/scripts/audit-fresh-session-readiness.mjs +177 -0
- package/scripts/audit-gse.mjs +275 -0
- package/scripts/audit-host-adapters.mjs +119 -0
- package/scripts/audit-host-runtime-evidence-handoff.mjs +159 -0
- package/scripts/audit-host-runtime-invocation-drill.mjs +240 -0
- package/scripts/audit-host-runtime-invocations.mjs +254 -0
- package/scripts/audit-host-ui-invocation.mjs +132 -0
- package/scripts/audit-learning-system.mjs +103 -0
- package/scripts/audit-local-final-form-completion.mjs +131 -0
- package/scripts/audit-marketplace-discovery.mjs +122 -0
- package/scripts/audit-npm-package-metadata.mjs +155 -0
- package/scripts/audit-npm-publish-dry-run.mjs +169 -0
- package/scripts/audit-npm-tarball-install.mjs +191 -0
- package/scripts/audit-open-source-defaults.mjs +92 -0
- package/scripts/audit-open-source-readiness.mjs +97 -0
- package/scripts/audit-owner-external-gate-kit.mjs +218 -0
- package/scripts/audit-project.mjs +323 -0
- package/scripts/audit-public-acceptance-command-dry-run-drill.mjs +203 -0
- package/scripts/audit-public-acceptance-handoff.mjs +142 -0
- package/scripts/audit-public-acceptance-readiness.mjs +224 -0
- package/scripts/audit-public-channel-publication.mjs +248 -0
- package/scripts/audit-public-ci-run.mjs +184 -0
- package/scripts/audit-public-collaboration-templates.mjs +98 -0
- package/scripts/audit-public-external-gate-probe.mjs +206 -0
- package/scripts/audit-public-release-checklist.mjs +133 -0
- package/scripts/audit-public-release-decision.mjs +201 -0
- package/scripts/audit-public-release-metadata.mjs +176 -0
- package/scripts/audit-public-repository-settings.mjs +237 -0
- package/scripts/audit-public-security-contact.mjs +171 -0
- package/scripts/audit-readme-docs.mjs +185 -0
- package/scripts/audit-recovery-readiness.mjs +98 -0
- package/scripts/audit-release-bundle.mjs +251 -0
- package/scripts/audit-release-owner-action-plan-drill.mjs +277 -0
- package/scripts/audit-release-owner-action-plan.mjs +164 -0
- package/scripts/audit-release-readiness.mjs +106 -0
- package/scripts/audit-release-status-manifest.mjs +165 -0
- package/scripts/audit-release-trust.mjs +62 -0
- package/scripts/audit-remote-distribution.mjs +266 -0
- package/scripts/audit-roadmap-consistency.mjs +235 -0
- package/scripts/audit-signing.mjs +147 -0
- package/scripts/audit-state-freshness.mjs +113 -0
- package/scripts/audit-target-adoption-evidence.mjs +117 -0
- package/scripts/audit-target-project.mjs +507 -0
- package/scripts/audit-update-release-acceptance.mjs +136 -0
- package/scripts/audit-v1-target-validation.mjs +269 -0
- package/scripts/audit-validation-profiles.mjs +125 -0
- package/scripts/close-change.mjs +116 -0
- package/scripts/discover-project-profile.mjs +307 -0
- package/scripts/forward-test-gse.mjs +146 -0
- package/scripts/generate-command-adapter.mjs +231 -0
- package/scripts/generate-final-acceptance-packet.mjs +181 -0
- package/scripts/generate-final-form-progress-report.mjs +205 -0
- package/scripts/generate-host-adapter.mjs +73 -0
- package/scripts/generate-host-runtime-evidence-handoff.mjs +206 -0
- package/scripts/generate-owner-external-gate-kit.mjs +295 -0
- package/scripts/generate-public-acceptance-handoff.mjs +168 -0
- package/scripts/generate-public-release-checklist.mjs +207 -0
- package/scripts/generate-release-bundle.mjs +505 -0
- package/scripts/generate-release-owner-action-plan.mjs +172 -0
- package/scripts/generate-release-status-manifest.mjs +200 -0
- package/scripts/generate-session-prompt.mjs +188 -0
- package/scripts/gse.mjs +67 -0
- package/scripts/init-change.mjs +265 -0
- package/scripts/init-project.mjs +785 -0
- package/scripts/install-gse.mjs +234 -0
- package/scripts/lib/evidence-placeholders.mjs +28 -0
- package/scripts/package-gse.mjs +174 -0
- package/scripts/probe-public-external-gates.mjs +167 -0
- package/scripts/record-host-invocation.mjs +151 -0
- package/scripts/record-learning.mjs +137 -0
- package/scripts/record-public-channel-publication.mjs +178 -0
- package/scripts/record-public-ci-run.mjs +180 -0
- package/scripts/record-public-release.mjs +175 -0
- package/scripts/record-public-repository-settings.mjs +209 -0
- package/scripts/record-public-security-contact.mjs +157 -0
- package/scripts/run-gse-command.mjs +538 -0
- package/scripts/run-validation-profile.mjs +146 -0
- package/scripts/sign-gse-package.mjs +83 -0
- package/scripts/update-project-state.mjs +223 -0
- package/scripts/validate-gse.mjs +1168 -0
- package/scripts/verify-gse-package.mjs +85 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import os from 'node:os'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import { spawnSync } from 'node:child_process'
|
|
6
|
+
|
|
7
|
+
const args = process.argv.slice(2)
|
|
8
|
+
|
|
9
|
+
function readArg(name, fallback = null) {
|
|
10
|
+
const index = args.indexOf(name)
|
|
11
|
+
if (index === -1) return fallback
|
|
12
|
+
return args[index + 1] ?? fallback
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const root = path.resolve(readArg('--root', path.join(import.meta.dirname, '..')))
|
|
16
|
+
const recordPath = readArg('--record')
|
|
17
|
+
const jsonOnly = args.includes('--json')
|
|
18
|
+
|
|
19
|
+
function read(relativePathOrFullPath) {
|
|
20
|
+
const fullPath = path.isAbsolute(relativePathOrFullPath) ? relativePathOrFullPath : path.join(root, relativePathOrFullPath)
|
|
21
|
+
return fs.existsSync(fullPath) ? fs.readFileSync(fullPath, 'utf8').replace(/^\uFEFF/, '') : ''
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function exists(relativePath) {
|
|
25
|
+
return fs.existsSync(path.join(root, relativePath))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function run(script, commandArgs) {
|
|
29
|
+
const result = spawnSync(process.execPath, [path.join(root, 'scripts', script), ...commandArgs], {
|
|
30
|
+
cwd: root,
|
|
31
|
+
encoding: 'utf8',
|
|
32
|
+
windowsHide: true,
|
|
33
|
+
})
|
|
34
|
+
return {
|
|
35
|
+
command: [process.execPath, path.join(root, 'scripts', script), ...commandArgs].join(' '),
|
|
36
|
+
status: result.status ?? 1,
|
|
37
|
+
stdout: (result.stdout ?? '').trim(),
|
|
38
|
+
stderr: (result.stderr ?? '').trim(),
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function parseJson(text) {
|
|
43
|
+
try { return JSON.parse(text) } catch { return null }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function check(id, label, ok, evidence, risk = '') {
|
|
47
|
+
return { id, label, status: ok ? 'passed' : 'failed', evidence, risk }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const target = fs.mkdtempSync(path.join(os.tmpdir(), 'gse-host-ui-'))
|
|
51
|
+
fs.mkdirSync(target, { recursive: true })
|
|
52
|
+
fs.writeFileSync(path.join(target, 'AGENTS.md'), '# Host UI Fixture\n', 'utf8')
|
|
53
|
+
const initRun = run('init-project.mjs', ['--target', target, '--mode', 'enterprise', '--json'])
|
|
54
|
+
const adapterRun = run('generate-command-adapter.mjs', ['--target', target, '--host', 'all', '--json'])
|
|
55
|
+
const commandRun = run('run-gse-command.mjs', ['--target', target, '--command', '/gse help', '--json'])
|
|
56
|
+
const adapterData = parseJson(adapterRun.stdout)
|
|
57
|
+
const commandData = parseJson(commandRun.stdout)
|
|
58
|
+
const claudeCommand = read(path.join(target, '.claude', 'commands', 'gse.md'))
|
|
59
|
+
const codexPointer = read(path.join(target, '.codex', 'gse-command.md'))
|
|
60
|
+
const record = recordPath ? read(path.resolve(recordPath)) : ''
|
|
61
|
+
const recordHasEvidence =
|
|
62
|
+
Boolean(record) &&
|
|
63
|
+
record.includes('## Host') &&
|
|
64
|
+
record.includes('## Command') &&
|
|
65
|
+
record.includes('## Result') &&
|
|
66
|
+
record.includes('## Evidence') &&
|
|
67
|
+
/Status:\s*(verified|accepted)/i.test(record)
|
|
68
|
+
|
|
69
|
+
const checks = [
|
|
70
|
+
check('HUI01', 'host UI invocation record template exists', exists('assets/templates/host-ui-invocation-record.md'), 'assets/templates/host-ui-invocation-record.md'),
|
|
71
|
+
check('HUI02', 'portable runner can execute command semantics', commandRun.status === 0 && commandData?.route?.route === 'references/commands.md', '/gse help through run-gse-command.mjs'),
|
|
72
|
+
check('HUI03', 'Claude command adapter is generated at current native path', adapterRun.status === 0 && fs.existsSync(path.join(target, '.claude', 'commands', 'gse.md')) && claudeCommand.includes('Portable execution path'), '.claude/commands/gse.md'),
|
|
73
|
+
check('HUI04', 'Codex command pointer is generated without native claim', adapterRun.status === 0 && fs.existsSync(path.join(target, '.codex', 'gse-command.md')) && codexPointer.includes('not proof of a native project-level /gse slash-command mechanism'), '.codex/gse-command.md'),
|
|
74
|
+
check('HUI05', 'adapter generator labels native support honestly', adapterData?.results?.some((item) => item.host === 'claude' && item.nativeSlashCommand === true) && adapterData?.results?.some((item) => item.host === 'codex' && item.nativeSlashCommand === false), 'generate-command-adapter.mjs result metadata'),
|
|
75
|
+
check('HUI06', 'commands reference requires host runtime evidence', read('references/commands.md').includes('host-specific smoke') && read('references/commands.md').includes('Do not claim native slash-command support unless the current host exposes it and it was verified.'), 'references/commands.md'),
|
|
76
|
+
check('HUI07', 'optional real host invocation record is valid when supplied', recordPath ? recordHasEvidence : true, recordPath ? recordPath : 'no --record supplied; template/readiness only'),
|
|
77
|
+
check('HUI08', 'validator includes host UI invocation audit', read('scripts/validate-gse.mjs').includes('audit-host-ui-invocation.mjs'), 'scripts/validate-gse.mjs'),
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
fs.rmSync(target, { recursive: true, force: true })
|
|
81
|
+
|
|
82
|
+
const passed = checks.filter((item) => item.status === 'passed').length
|
|
83
|
+
const failed = checks.length - passed
|
|
84
|
+
const report = {
|
|
85
|
+
root,
|
|
86
|
+
generatedAt: new Date().toISOString(),
|
|
87
|
+
summary: { status: failed === 0 ? 'passed' : 'failed', passed, failed, total: checks.length },
|
|
88
|
+
workflows: {
|
|
89
|
+
hostUiInvocationReadiness: failed === 0 ? 'verified' : 'failed',
|
|
90
|
+
realHostUiInvocation: recordHasEvidence ? 'verified-by-record' : 'not-verified',
|
|
91
|
+
},
|
|
92
|
+
acceptedBy: recordHasEvidence ? 'host invocation record' : 'not accepted; no real host UI invocation record was supplied',
|
|
93
|
+
limits: [
|
|
94
|
+
'This audit verifies portable command execution, generated host pointers, and the evidence format for real host UI invocation.',
|
|
95
|
+
'Without --record, it does not prove a real Codex, Claude Code, Hermes, WorkBuddy, or other UI invoked the command.',
|
|
96
|
+
'Generated adapters are not runtime proof by themselves.',
|
|
97
|
+
],
|
|
98
|
+
checks,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function renderMarkdown(data) {
|
|
102
|
+
const lines = []
|
|
103
|
+
lines.push('# GSE Host UI Invocation Audit')
|
|
104
|
+
lines.push('')
|
|
105
|
+
lines.push('Generated: ' + data.generatedAt)
|
|
106
|
+
lines.push('Root: ' + data.root)
|
|
107
|
+
lines.push('')
|
|
108
|
+
lines.push('## Summary')
|
|
109
|
+
lines.push('')
|
|
110
|
+
lines.push('- Status: ' + data.summary.status)
|
|
111
|
+
lines.push('- Checks: ' + data.summary.passed + '/' + data.summary.total)
|
|
112
|
+
lines.push('- Host UI invocation readiness: ' + data.workflows.hostUiInvocationReadiness)
|
|
113
|
+
lines.push('- Real host UI invocation: ' + data.workflows.realHostUiInvocation)
|
|
114
|
+
lines.push('- Accepted by: ' + data.acceptedBy)
|
|
115
|
+
lines.push('')
|
|
116
|
+
lines.push('## Checks')
|
|
117
|
+
lines.push('')
|
|
118
|
+
for (const item of data.checks) {
|
|
119
|
+
const marker = item.status === 'passed' ? '[x]' : '[ ]'
|
|
120
|
+
lines.push('- ' + marker + ' ' + item.id + ' ' + item.label + ': ' + item.evidence)
|
|
121
|
+
}
|
|
122
|
+
lines.push('')
|
|
123
|
+
lines.push('## Limits')
|
|
124
|
+
lines.push('')
|
|
125
|
+
for (const item of data.limits) lines.push('- ' + item)
|
|
126
|
+
return lines.join('\n') + '\n'
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (jsonOnly) console.log(JSON.stringify(report, null, 2))
|
|
130
|
+
else console.log(renderMarkdown(report))
|
|
131
|
+
|
|
132
|
+
if (failed > 0) process.exit(1)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import os from 'node:os'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import { spawnSync } from 'node:child_process'
|
|
6
|
+
|
|
7
|
+
const args = process.argv.slice(2)
|
|
8
|
+
|
|
9
|
+
function readArg(name, fallback = null) {
|
|
10
|
+
const index = args.indexOf(name)
|
|
11
|
+
if (index === -1) return fallback
|
|
12
|
+
return args[index + 1] ?? fallback
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const root = path.resolve(readArg('--root', path.join(import.meta.dirname, '..')))
|
|
16
|
+
const jsonOnly = args.includes('--json')
|
|
17
|
+
const target = fs.mkdtempSync(path.join(os.tmpdir(), 'gse-learning-audit-'))
|
|
18
|
+
|
|
19
|
+
function run(script, commandArgs) {
|
|
20
|
+
const result = spawnSync(process.execPath, [path.join(root, 'scripts', script), ...commandArgs], {
|
|
21
|
+
cwd: root,
|
|
22
|
+
encoding: 'utf8',
|
|
23
|
+
windowsHide: true,
|
|
24
|
+
})
|
|
25
|
+
return {
|
|
26
|
+
command: [process.execPath, path.join(root, 'scripts', script), ...commandArgs].join(' '),
|
|
27
|
+
status: result.status ?? 1,
|
|
28
|
+
stdout: (result.stdout ?? '').trim(),
|
|
29
|
+
stderr: (result.stderr ?? '').trim(),
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function parseJson(text) {
|
|
34
|
+
try { return JSON.parse(text) } catch { return null }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function check(id, label, ok, evidence, risk = '') {
|
|
38
|
+
return { id, label, status: ok ? 'passed' : 'failed', evidence, risk }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fs.mkdirSync(target, { recursive: true })
|
|
42
|
+
const initRun = run('init-project.mjs', ['--target', target, '--mode', 'lite', '--json'])
|
|
43
|
+
const learningsPath = path.join(target, '.gse', 'learnings.md')
|
|
44
|
+
const before = fs.existsSync(learningsPath) ? fs.readFileSync(learningsPath, 'utf8') : ''
|
|
45
|
+
const summary = 'Prefer UTF-8 safe readers for Chinese docs before judging mojibake'
|
|
46
|
+
|
|
47
|
+
const waitingRun = run('record-learning.mjs', ['--target', target, '--json'])
|
|
48
|
+
const dryRun = run('record-learning.mjs', ['--target', target, '--summary', summary, '--trigger', 'encoding review', '--source', 'audit fixture', '--json'])
|
|
49
|
+
const afterDryRun = fs.existsSync(learningsPath) ? fs.readFileSync(learningsPath, 'utf8') : ''
|
|
50
|
+
const writeRun = run('record-learning.mjs', ['--target', target, '--summary', summary, '--trigger', 'encoding review', '--source', 'audit fixture', '--impact', 'prevents false mojibake fixes', '--execute', '--json'])
|
|
51
|
+
const afterWrite = fs.existsSync(learningsPath) ? fs.readFileSync(learningsPath, 'utf8') : ''
|
|
52
|
+
const duplicateRun = run('record-learning.mjs', ['--target', target, '--summary', summary, '--trigger', 'encoding review again', '--source', 'audit fixture', '--execute', '--json'])
|
|
53
|
+
const afterDuplicate = fs.existsSync(learningsPath) ? fs.readFileSync(learningsPath, 'utf8') : ''
|
|
54
|
+
const commandDryRun = run('run-gse-command.mjs', ['--root', root, '--target', target, '--command', `/gse learn --summary ${summary} via command --trigger command audit --source run-gse-command`, '--json'])
|
|
55
|
+
const commandWriteRun = run('run-gse-command.mjs', ['--root', root, '--target', target, '--command', '/gse learn --summary Capture tool capability mismatches as reusable lessons --trigger tool mismatch --source command audit', '--execute', '--json'])
|
|
56
|
+
const afterCommandWrite = fs.existsSync(learningsPath) ? fs.readFileSync(learningsPath, 'utf8') : ''
|
|
57
|
+
|
|
58
|
+
const waiting = parseJson(waitingRun.stdout)
|
|
59
|
+
const dry = parseJson(dryRun.stdout)
|
|
60
|
+
const written = parseJson(writeRun.stdout)
|
|
61
|
+
const duplicate = parseJson(duplicateRun.stdout)
|
|
62
|
+
const commandDry = parseJson(commandDryRun.stdout)
|
|
63
|
+
const commandDryChild = parseJson(commandDry?.execution?.stdout ?? '')
|
|
64
|
+
const commandWrite = parseJson(commandWriteRun.stdout)
|
|
65
|
+
const commandWriteChild = parseJson(commandWrite?.execution?.stdout ?? '')
|
|
66
|
+
|
|
67
|
+
const checks = [
|
|
68
|
+
check('LRN01', 'record-learning script exists', fs.existsSync(path.join(root, 'scripts', 'record-learning.mjs')), 'scripts/record-learning.mjs'),
|
|
69
|
+
check('LRN02', 'learning audit script exists', fs.existsSync(path.join(root, 'scripts', 'audit-learning-system.mjs')), 'scripts/audit-learning-system.mjs'),
|
|
70
|
+
check('LRN03', 'init-project creates .gse/learnings.md', initRun.status === 0 && fs.existsSync(learningsPath), '.gse/learnings.md'),
|
|
71
|
+
check('LRN04', 'missing summary returns waiting-for-input without failing', waitingRun.status === 0 && waiting?.status === 'waiting-for-input', 'record-learning without --summary'),
|
|
72
|
+
check('LRN05', 'dry-run previews learning without modifying file', dryRun.status === 0 && dry?.status === 'ready' && before === afterDryRun && dry?.preview?.includes(summary), 'record-learning dry-run'),
|
|
73
|
+
check('LRN06', 'execute appends structured learning entry', writeRun.status === 0 && written?.status === 'written' && afterWrite.includes('- Summary: ' + summary) && afterWrite.includes('- Trigger: encoding review') && afterWrite.includes('- Status: learning-note'), 'record-learning --execute'),
|
|
74
|
+
check('LRN07', 'duplicate summary is skipped without appending again', duplicateRun.status === 0 && duplicate?.status === 'skipped' && afterDuplicate === afterWrite, 'duplicate record-learning --execute'),
|
|
75
|
+
check('LRN08', '/gse learn dry-runs through portable command runner', commandDryRun.status === 0 && commandDry?.verb === 'learn' && commandDryChild?.status === 'ready', '/gse learn'),
|
|
76
|
+
check('LRN09', '/gse learn --execute writes through portable command runner', commandWriteRun.status === 0 && commandWrite?.verb === 'learn' && commandWriteChild?.status === 'written' && afterCommandWrite.includes('Capture tool capability mismatches as reusable lessons'), '/gse learn --execute'),
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
const passed = checks.filter((item) => item.status === 'passed').length
|
|
80
|
+
const failed = checks.length - passed
|
|
81
|
+
const report = {
|
|
82
|
+
root,
|
|
83
|
+
target,
|
|
84
|
+
generatedAt: new Date().toISOString(),
|
|
85
|
+
summary: { status: failed === 0 ? 'passed' : 'failed', passed, failed, total: checks.length },
|
|
86
|
+
workflows: {
|
|
87
|
+
learningCommand: failed === 0 ? 'verified' : 'failed',
|
|
88
|
+
learningStore: failed === 0 ? 'verified' : 'failed',
|
|
89
|
+
},
|
|
90
|
+
commands: [waitingRun.command, dryRun.command, writeRun.command, duplicateRun.command, commandDryRun.command, commandWriteRun.command],
|
|
91
|
+
limits: [
|
|
92
|
+
'This verifies deterministic learning capture and duplicate prevention.',
|
|
93
|
+
'It does not automatically decide which lessons are worth recording; the agent or owner still supplies the summary.',
|
|
94
|
+
],
|
|
95
|
+
checks,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
fs.rmSync(target, { recursive: true, force: true })
|
|
99
|
+
|
|
100
|
+
if (jsonOnly) console.log(JSON.stringify(report, null, 2))
|
|
101
|
+
else console.log(JSON.stringify(report, null, 2))
|
|
102
|
+
|
|
103
|
+
if (failed > 0) process.exit(1)
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { spawnSync } from 'node:child_process'
|
|
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 root = path.resolve(readArg('--root', path.join(import.meta.dirname, '..')))
|
|
14
|
+
const jsonOnly = args.includes('--json')
|
|
15
|
+
|
|
16
|
+
function run(script, commandArgs = []) {
|
|
17
|
+
const result = spawnSync(process.execPath, [path.join(root, 'scripts', script), '--root', root, '--json', ...commandArgs], {
|
|
18
|
+
cwd: root,
|
|
19
|
+
encoding: 'utf8',
|
|
20
|
+
windowsHide: true,
|
|
21
|
+
})
|
|
22
|
+
let data = null
|
|
23
|
+
try {
|
|
24
|
+
data = JSON.parse((result.stdout ?? '').trim())
|
|
25
|
+
} catch {
|
|
26
|
+
data = null
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
script,
|
|
30
|
+
command: [process.execPath, path.join(root, 'scripts', script), '--root', root, '--json', ...commandArgs].join(' '),
|
|
31
|
+
status: result.status ?? 1,
|
|
32
|
+
stdout: (result.stdout ?? '').trim(),
|
|
33
|
+
stderr: (result.stderr ?? '').trim(),
|
|
34
|
+
data,
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function check(id, label, ok, evidence, risk = '') {
|
|
39
|
+
return { id, label, status: ok ? 'passed' : 'failed', evidence, risk }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const finalReadiness = run('audit-final-readiness.mjs')
|
|
43
|
+
const progress = run('audit-final-form-progress-report.mjs')
|
|
44
|
+
const publicAcceptance = run('audit-public-acceptance-readiness.mjs')
|
|
45
|
+
const completionReadiness = run('audit-completion-readiness.mjs')
|
|
46
|
+
|
|
47
|
+
const finalRows = finalReadiness.data?.matrix ?? []
|
|
48
|
+
const nonExternalIncompleteRows = finalRows.filter((row) => {
|
|
49
|
+
if (row.status === 'verified') return false
|
|
50
|
+
return !['owner-required', 'external-required'].includes(row.status)
|
|
51
|
+
})
|
|
52
|
+
const pendingGates = publicAcceptance.data?.pendingGates ?? []
|
|
53
|
+
const pendingGateAreas = pendingGates.map((gate) => gate.area)
|
|
54
|
+
const expectedPendingAreas = pendingGateAreas
|
|
55
|
+
|
|
56
|
+
const checks = [
|
|
57
|
+
check('LFC01', 'final readiness audit passes', finalReadiness.status === 0 && finalReadiness.data?.summary?.failed === 0, finalReadiness.command),
|
|
58
|
+
check('LFC02', 'completion readiness audit passes', completionReadiness.status === 0 && completionReadiness.data?.summary?.failed === 0, completionReadiness.command),
|
|
59
|
+
check('LFC03', 'final-form progress report shows local engineering readiness at 100', progress.status === 0 && progress.data?.workflows?.localEngineeringReadiness === 100, 'localEngineeringReadiness=' + progress.data?.workflows?.localEngineeringReadiness),
|
|
60
|
+
check('LFC04', 'full final-form readiness remains bounded by owner/external gates', progress.status === 0 && progress.data?.workflows?.publicAccepted === 'not-accepted' && Number(progress.data?.workflows?.pendingGates) > 0, 'publicAccepted=' + progress.data?.workflows?.publicAccepted + '; pendingGates=' + progress.data?.workflows?.pendingGates),
|
|
61
|
+
check('LFC05', 'all incomplete final readiness rows are owner/external only', nonExternalIncompleteRows.length === 0, nonExternalIncompleteRows.length ? JSON.stringify(nonExternalIncompleteRows) : 'no local incomplete rows'),
|
|
62
|
+
check('LFC06', 'public acceptance doctor passes and keeps public acceptance unclaimed', publicAcceptance.status === 0 && publicAcceptance.data?.summary?.failed === 0 && publicAcceptance.data?.summary?.publicAccepted === 'not-accepted', publicAcceptance.command),
|
|
63
|
+
check('LFC07', 'public acceptance pending gates are current external/owner gate set', pendingGateAreas.length > 0 && expectedPendingAreas.every((area) => pendingGateAreas.includes(area)) && pendingGateAreas.length === expectedPendingAreas.length, pendingGateAreas.join(', ')),
|
|
64
|
+
check('LFC08', 'pending gates expose executable record and preflight commands', pendingGates.length > 0 && pendingGates.every((gate) => gate.recordCommand && gate.preflightCommand && gate.requiredEvidence && gate.owner), 'pending gate command templates'),
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
const passed = checks.filter((item) => item.status === 'passed').length
|
|
68
|
+
const failed = checks.length - passed
|
|
69
|
+
const report = {
|
|
70
|
+
root,
|
|
71
|
+
generatedAt: new Date().toISOString(),
|
|
72
|
+
summary: {
|
|
73
|
+
status: failed === 0 ? 'passed' : 'failed',
|
|
74
|
+
passed,
|
|
75
|
+
failed,
|
|
76
|
+
total: checks.length,
|
|
77
|
+
localEngineeringReadiness: progress.data?.workflows?.localEngineeringReadiness ?? null,
|
|
78
|
+
fullFinalFormReadiness: progress.data?.workflows?.fullFinalFormReadiness ?? null,
|
|
79
|
+
pendingGates: progress.data?.workflows?.pendingGates ?? null,
|
|
80
|
+
publicAccepted: progress.data?.workflows?.publicAccepted ?? null,
|
|
81
|
+
},
|
|
82
|
+
workflows: {
|
|
83
|
+
localFinalFormCompletion: failed === 0 ? 'verified' : 'failed',
|
|
84
|
+
remainingWorkClass: failed === 0 ? 'owner-external-only' : 'local-work-or-state-inconsistency-present',
|
|
85
|
+
},
|
|
86
|
+
remainingOwnerExternalGates: pendingGates.map((gate) => ({
|
|
87
|
+
area: gate.area,
|
|
88
|
+
status: gate.status,
|
|
89
|
+
owner: gate.owner,
|
|
90
|
+
requiredEvidence: gate.requiredEvidence,
|
|
91
|
+
})),
|
|
92
|
+
limits: [
|
|
93
|
+
'This audit proves local GSE engineering completion boundaries only.',
|
|
94
|
+
'It does not create public repository settings, public CI, registry publication, marketplace approval, security contact acceptance, native slash-command evidence, or other host runtime evidence.',
|
|
95
|
+
'A public-final claim still requires accepted owner/external records and final readiness re-audit.',
|
|
96
|
+
],
|
|
97
|
+
checks,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function renderMarkdown(data) {
|
|
101
|
+
const lines = []
|
|
102
|
+
lines.push('# GSE Local Final-Form Completion Audit')
|
|
103
|
+
lines.push('')
|
|
104
|
+
lines.push('Generated: ' + data.generatedAt)
|
|
105
|
+
lines.push('Root: ' + data.root)
|
|
106
|
+
lines.push('')
|
|
107
|
+
lines.push('## Summary')
|
|
108
|
+
lines.push('')
|
|
109
|
+
lines.push('- Status: ' + data.summary.status)
|
|
110
|
+
lines.push('- Local engineering readiness: ' + data.summary.localEngineeringReadiness)
|
|
111
|
+
lines.push('- Full final-form readiness: ' + data.summary.fullFinalFormReadiness)
|
|
112
|
+
lines.push('- Public accepted: ' + data.summary.publicAccepted)
|
|
113
|
+
lines.push('- Remaining work class: ' + data.workflows.remainingWorkClass)
|
|
114
|
+
lines.push('')
|
|
115
|
+
lines.push('## Checks')
|
|
116
|
+
lines.push('')
|
|
117
|
+
for (const item of data.checks) {
|
|
118
|
+
const marker = item.status === 'passed' ? '[x]' : '[ ]'
|
|
119
|
+
lines.push('- ' + marker + ' ' + item.id + ' ' + item.label + ': ' + item.evidence)
|
|
120
|
+
}
|
|
121
|
+
lines.push('')
|
|
122
|
+
lines.push('## Limits')
|
|
123
|
+
lines.push('')
|
|
124
|
+
for (const item of data.limits) lines.push('- ' + item)
|
|
125
|
+
return lines.join('\n') + '\n'
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (jsonOnly) console.log(JSON.stringify(report, null, 2))
|
|
129
|
+
else console.log(renderMarkdown(report))
|
|
130
|
+
|
|
131
|
+
if (failed > 0) process.exit(1)
|
|
@@ -0,0 +1,122 @@
|
|
|
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 root = path.resolve(readArg('--root', path.join(import.meta.dirname, '..')))
|
|
14
|
+
const jsonOnly = args.includes('--json')
|
|
15
|
+
|
|
16
|
+
function read(relativePath) {
|
|
17
|
+
const fullPath = path.join(root, relativePath)
|
|
18
|
+
return fs.existsSync(fullPath) ? fs.readFileSync(fullPath, 'utf8').replace(/^\uFEFF/, '') : ''
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function exists(relativePath) {
|
|
22
|
+
return fs.existsSync(path.join(root, relativePath))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function readJson(relativePath) {
|
|
26
|
+
try {
|
|
27
|
+
return JSON.parse(read(relativePath))
|
|
28
|
+
} catch {
|
|
29
|
+
return null
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function check(id, label, ok, evidence, risk = '') {
|
|
34
|
+
return { id, label, status: ok ? 'passed' : 'failed', evidence, risk }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const listingText = read('assets/marketplace/gse-listing.json')
|
|
38
|
+
const listing = readJson('assets/marketplace/gse-listing.json')
|
|
39
|
+
const marketplaceRef = read('references/marketplace-discovery.md')
|
|
40
|
+
const packaging = read('references/packaging.md')
|
|
41
|
+
const openai = read('agents/openai.yaml')
|
|
42
|
+
const validate = read('scripts/validate-gse.mjs')
|
|
43
|
+
|
|
44
|
+
const keywords = new Set(Array.isArray(listing?.keywords) ? listing.keywords : [])
|
|
45
|
+
const categories = new Set(Array.isArray(listing?.categories) ? listing.categories : [])
|
|
46
|
+
const entrypoints = new Set(Array.isArray(listing?.entrypoints) ? listing.entrypoints : [])
|
|
47
|
+
const verification = Array.isArray(listing?.verification) ? listing.verification : []
|
|
48
|
+
const hostSupport = Array.isArray(listing?.hostSupport) ? listing.hostSupport : []
|
|
49
|
+
const boundaries = Array.isArray(listing?.boundaries) ? listing.boundaries.join('\n') : ''
|
|
50
|
+
const privateLeakPattern = new RegExp(
|
|
51
|
+
[
|
|
52
|
+
['C:', 'Users', 'Admin'].join('[\\\\\\\\/]'),
|
|
53
|
+
['D:', 'codex'].join('[\\\\\\\\/]'),
|
|
54
|
+
['hermes', 'workspace'].join('[-_]'),
|
|
55
|
+
['node', 'banana'].join('[-_]'),
|
|
56
|
+
].join('|'),
|
|
57
|
+
'i',
|
|
58
|
+
)
|
|
59
|
+
const noPrivateOrLocalLeak =
|
|
60
|
+
!privateLeakPattern.test(listingText) &&
|
|
61
|
+
!privateLeakPattern.test(marketplaceRef)
|
|
62
|
+
|
|
63
|
+
const checks = [
|
|
64
|
+
check('MD01', 'marketplace listing metadata exists and parses', Boolean(listing), 'assets/marketplace/gse-listing.json'),
|
|
65
|
+
check('MD02', 'listing has searchable identity and summary', listing?.name === 'gse' && listing?.displayName === 'GSE' && typeof listing?.tagline === 'string' && listing.tagline.length > 20 && typeof listing?.summary === 'string' && listing.summary.includes('Goal-Spec-Evidence'), 'name, displayName, tagline, summary'),
|
|
66
|
+
check('MD03', 'listing uses natural ecosystem keywords', ['agentic engineering', 'spec-driven development', 'SDD', 'AI coding agent workflow', 'evidence gates', 'goal map'].every((item) => keywords.has(item)), 'keywords'),
|
|
67
|
+
check('MD04', 'listing classifies project category without keyword stuffing block', categories.has('agentic engineering') && categories.has('software development workflow') && marketplaceRef.includes('Do not add isolated search-term blocks'), 'categories and marketplace reference'),
|
|
68
|
+
check('MD05', 'listing exposes human and machine entrypoints', ['SKILL.md', 'README.md', 'README.zh-CN.md', 'scripts/run-gse-command.mjs', 'scripts/validate-gse.mjs'].every((item) => entrypoints.has(item)), 'entrypoints'),
|
|
69
|
+
check('MD06', 'listing exposes validation commands', verification.some((item) => item.includes('validate-gse.mjs')) && verification.some((item) => item.includes('audit-marketplace-discovery.mjs')) && verification.some((item) => item.includes('audit-host-ui-invocation.mjs')), 'verification commands'),
|
|
70
|
+
check('MD07', 'listing separates host support status from proof', hostSupport.some((item) => item.host.includes('Codex') && item.status === 'documented') && hostSupport.some((item) => item.host.includes('Claude') && item.status === 'documented') && boundaries.includes('native host UI invocation require separate evidence'), 'hostSupport and boundaries'),
|
|
71
|
+
check('MD08', 'release trust and distribution references are linked', listing?.distribution?.packageScript === 'scripts/package-gse.mjs' && listing?.distribution?.trustPolicy === 'references/release-trust.md' && packaging.includes('references/marketplace-discovery.md'), 'distribution metadata and packaging reference'),
|
|
72
|
+
check('MD09', 'OpenAI host metadata remains present', openai.includes('display_name: "GSE"') && openai.includes('default_prompt'), 'agents/openai.yaml'),
|
|
73
|
+
check('MD10', 'validator includes marketplace discovery audit', validate.includes('audit-marketplace-discovery.mjs'), 'scripts/validate-gse.mjs'),
|
|
74
|
+
check('MD11', 'metadata avoids local/private project leakage', noPrivateOrLocalLeak, 'listing and marketplace reference'),
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
const passed = checks.filter((item) => item.status === 'passed').length
|
|
78
|
+
const failed = checks.length - passed
|
|
79
|
+
const report = {
|
|
80
|
+
root,
|
|
81
|
+
generatedAt: new Date().toISOString(),
|
|
82
|
+
summary: { status: failed === 0 ? 'passed' : 'failed', passed, failed, total: checks.length },
|
|
83
|
+
workflows: { marketplaceDiscovery: failed === 0 ? 'verified' : 'failed' },
|
|
84
|
+
acceptedBy: 'not accepted; this audit verifies metadata readiness but does not publish to or receive approval from a marketplace',
|
|
85
|
+
limits: [
|
|
86
|
+
'This audit verifies local discovery metadata, not marketplace approval.',
|
|
87
|
+
'It does not prove maintainer identity, public registry publication, ranking, search indexing, or host-native installation.',
|
|
88
|
+
],
|
|
89
|
+
checks,
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function renderMarkdown(data) {
|
|
93
|
+
const lines = []
|
|
94
|
+
lines.push('# GSE Marketplace Discovery Audit')
|
|
95
|
+
lines.push('')
|
|
96
|
+
lines.push('Generated: ' + data.generatedAt)
|
|
97
|
+
lines.push('Root: ' + data.root)
|
|
98
|
+
lines.push('')
|
|
99
|
+
lines.push('## Summary')
|
|
100
|
+
lines.push('')
|
|
101
|
+
lines.push('- Status: ' + data.summary.status)
|
|
102
|
+
lines.push('- Checks: ' + data.summary.passed + '/' + data.summary.total)
|
|
103
|
+
lines.push('- Marketplace discovery: ' + data.workflows.marketplaceDiscovery)
|
|
104
|
+
lines.push('- Accepted by: ' + data.acceptedBy)
|
|
105
|
+
lines.push('')
|
|
106
|
+
lines.push('## Checks')
|
|
107
|
+
lines.push('')
|
|
108
|
+
for (const item of data.checks) {
|
|
109
|
+
const marker = item.status === 'passed' ? '[x]' : '[ ]'
|
|
110
|
+
lines.push('- ' + marker + ' ' + item.id + ' ' + item.label + ': ' + item.evidence)
|
|
111
|
+
}
|
|
112
|
+
lines.push('')
|
|
113
|
+
lines.push('## Limits')
|
|
114
|
+
lines.push('')
|
|
115
|
+
for (const item of data.limits) lines.push('- ' + item)
|
|
116
|
+
return lines.join('\n') + '\n'
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (jsonOnly) console.log(JSON.stringify(report, null, 2))
|
|
120
|
+
else console.log(renderMarkdown(report))
|
|
121
|
+
|
|
122
|
+
if (failed > 0) process.exit(1)
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import { spawnSync } from 'node:child_process'
|
|
5
|
+
|
|
6
|
+
const args = process.argv.slice(2)
|
|
7
|
+
|
|
8
|
+
function readArg(name, fallback = null) {
|
|
9
|
+
const index = args.indexOf(name)
|
|
10
|
+
if (index === -1) return fallback
|
|
11
|
+
return args[index + 1] ?? fallback
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const root = path.resolve(readArg('--root', path.join(import.meta.dirname, '..')))
|
|
15
|
+
const jsonOnly = args.includes('--json')
|
|
16
|
+
|
|
17
|
+
function readJson(relativePath) {
|
|
18
|
+
const fullPath = path.join(root, relativePath)
|
|
19
|
+
if (!fs.existsSync(fullPath)) return null
|
|
20
|
+
try {
|
|
21
|
+
return JSON.parse(fs.readFileSync(fullPath, 'utf8').replace(/^\uFEFF/, ''))
|
|
22
|
+
} catch {
|
|
23
|
+
return null
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function exists(relativePath) {
|
|
28
|
+
return fs.existsSync(path.join(root, relativePath))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function run(command, commandArgs) {
|
|
32
|
+
const result = spawnSync(command, commandArgs, {
|
|
33
|
+
cwd: root,
|
|
34
|
+
encoding: 'utf8',
|
|
35
|
+
windowsHide: true,
|
|
36
|
+
})
|
|
37
|
+
return {
|
|
38
|
+
command: [command, ...commandArgs].join(' '),
|
|
39
|
+
status: result.status ?? 1,
|
|
40
|
+
stdout: (result.stdout ?? '').trim(),
|
|
41
|
+
stderr: (result.stderr ?? '').trim(),
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function parseJson(text) {
|
|
46
|
+
try {
|
|
47
|
+
return JSON.parse(text)
|
|
48
|
+
} catch {
|
|
49
|
+
return null
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function check(id, label, ok, evidence, risk = '') {
|
|
54
|
+
return { id, label, status: ok ? 'passed' : 'failed', evidence, risk }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const pkg = readJson('package.json')
|
|
58
|
+
const packRun = process.platform === 'win32'
|
|
59
|
+
? run('cmd', ['/c', 'npm', 'pack', '--dry-run', '--json'])
|
|
60
|
+
: run('npm', ['pack', '--dry-run', '--json'])
|
|
61
|
+
const packData = parseJson(packRun.stdout)
|
|
62
|
+
const packFiles = new Set((Array.isArray(packData) ? packData[0]?.files : []).map((item) => item.path))
|
|
63
|
+
const packageFiles = new Set(pkg?.files ?? [])
|
|
64
|
+
const requiredPackageFiles = [
|
|
65
|
+
'SKILL.md',
|
|
66
|
+
'README.md',
|
|
67
|
+
'README.zh-CN.md',
|
|
68
|
+
'LICENSE',
|
|
69
|
+
'package.json',
|
|
70
|
+
'scripts/gse.mjs',
|
|
71
|
+
'scripts/audit-npm-tarball-install.mjs',
|
|
72
|
+
'scripts/validate-gse.mjs',
|
|
73
|
+
'scripts/run-gse-command.mjs',
|
|
74
|
+
'references/commands.md',
|
|
75
|
+
'references/packaging.md',
|
|
76
|
+
]
|
|
77
|
+
const requiredFilesWhitelist = [
|
|
78
|
+
'SKILL.md',
|
|
79
|
+
'README.md',
|
|
80
|
+
'README.zh-CN.md',
|
|
81
|
+
'LICENSE',
|
|
82
|
+
'scripts',
|
|
83
|
+
'references',
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
const checks = [
|
|
87
|
+
check('NPM01', 'package.json exists and parses', Boolean(pkg), 'package.json'),
|
|
88
|
+
check('NPM02', 'package uses the accepted MIT license', pkg?.license === 'MIT' && exists('LICENSE'), 'license=' + (pkg?.license ?? 'missing')),
|
|
89
|
+
check('NPM03', 'package declares ESM and Node runtime floor', pkg?.type === 'module' && /^>=18\b/.test(pkg?.engines?.node ?? ''), 'type=' + (pkg?.type ?? 'missing') + ', node=' + (pkg?.engines?.node ?? 'missing')),
|
|
90
|
+
check('NPM04', 'package exposes gse CLI bin entrypoint', pkg?.bin?.gse === 'scripts/gse.mjs' && exists('scripts/gse.mjs'), 'bin.gse=' + (pkg?.bin?.gse ?? 'missing')),
|
|
91
|
+
check('NPM05', 'package exposes validation and npm audit scripts', pkg?.scripts?.validate?.includes('validate-gse.mjs') && pkg?.scripts?.['audit:npm']?.includes('audit-npm-package-metadata.mjs') && pkg?.scripts?.['audit:npm-install']?.includes('audit-npm-tarball-install.mjs'), 'scripts.validate, scripts.audit:npm, and scripts.audit:npm-install'),
|
|
92
|
+
check('NPM06', 'files whitelist includes core skill content', requiredFilesWhitelist.every((item) => packageFiles.has(item)), requiredFilesWhitelist.join(', ')),
|
|
93
|
+
check('NPM07', 'npm pack dry-run succeeds', packRun.status === 0 && Array.isArray(packData) && packData.length === 1, packRun.command, packRun.stderr),
|
|
94
|
+
check('NPM08', 'npm pack dry-run includes required runtime files', requiredPackageFiles.every((item) => packFiles.has(item)), requiredPackageFiles.filter((item) => !packFiles.has(item)).join(', ') || 'all required files present'),
|
|
95
|
+
check('NPM09', 'npm package metadata does not claim registry publication', !pkg?.publishConfig && !pkg?.repository, 'no publishConfig or repository claim until public repo/channel evidence exists'),
|
|
96
|
+
]
|
|
97
|
+
|
|
98
|
+
const passed = checks.filter((item) => item.status === 'passed').length
|
|
99
|
+
const failed = checks.length - passed
|
|
100
|
+
const report = {
|
|
101
|
+
root,
|
|
102
|
+
generatedAt: new Date().toISOString(),
|
|
103
|
+
summary: { status: failed === 0 ? 'passed' : 'failed', passed, failed, total: checks.length },
|
|
104
|
+
workflows: {
|
|
105
|
+
npmPackageMetadata: failed === 0 ? 'verified' : 'failed',
|
|
106
|
+
npmPackDryRun: packRun.status === 0 ? 'verified' : 'failed',
|
|
107
|
+
},
|
|
108
|
+
package: pkg
|
|
109
|
+
? {
|
|
110
|
+
name: pkg.name,
|
|
111
|
+
version: pkg.version,
|
|
112
|
+
bin: pkg.bin,
|
|
113
|
+
license: pkg.license,
|
|
114
|
+
files: pkg.files?.length ?? 0,
|
|
115
|
+
}
|
|
116
|
+
: null,
|
|
117
|
+
commands: [packRun.command],
|
|
118
|
+
limits: [
|
|
119
|
+
'This audit verifies Node package metadata and npm pack dry-run only.',
|
|
120
|
+
'It does not publish GSE to npm, prove package name ownership, prove public repository settings, or prove marketplace approval.',
|
|
121
|
+
],
|
|
122
|
+
checks,
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function renderMarkdown(data) {
|
|
126
|
+
const lines = []
|
|
127
|
+
lines.push('# GSE npm Package Metadata Audit')
|
|
128
|
+
lines.push('')
|
|
129
|
+
lines.push('Generated: ' + data.generatedAt)
|
|
130
|
+
lines.push('Root: ' + data.root)
|
|
131
|
+
lines.push('')
|
|
132
|
+
lines.push('## Summary')
|
|
133
|
+
lines.push('')
|
|
134
|
+
lines.push('- Status: ' + data.summary.status)
|
|
135
|
+
lines.push('- Checks: ' + data.summary.passed + '/' + data.summary.total)
|
|
136
|
+
lines.push('- npm package metadata: ' + data.workflows.npmPackageMetadata)
|
|
137
|
+
lines.push('- npm pack dry-run: ' + data.workflows.npmPackDryRun)
|
|
138
|
+
lines.push('')
|
|
139
|
+
lines.push('## Checks')
|
|
140
|
+
lines.push('')
|
|
141
|
+
for (const item of data.checks) {
|
|
142
|
+
const marker = item.status === 'passed' ? '[x]' : '[ ]'
|
|
143
|
+
lines.push('- ' + marker + ' ' + item.id + ' ' + item.label + ': ' + item.evidence)
|
|
144
|
+
}
|
|
145
|
+
lines.push('')
|
|
146
|
+
lines.push('## Limits')
|
|
147
|
+
lines.push('')
|
|
148
|
+
for (const item of data.limits) lines.push('- ' + item)
|
|
149
|
+
return lines.join('\n') + '\n'
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (jsonOnly) console.log(JSON.stringify(report, null, 2))
|
|
153
|
+
else console.log(renderMarkdown(report))
|
|
154
|
+
|
|
155
|
+
if (failed > 0) process.exit(1)
|