Implement Forge repository foundation

This commit is contained in:
rob
2026-11-17 12:46:56 +00:00
parent 37720d775a
commit 1c1ed1f3aa
27 changed files with 345 additions and 1 deletions
+3
View File
@@ -0,0 +1,3 @@
__pycache__/
*.pyc
.test-worktrees/
+3
View File
@@ -0,0 +1,3 @@
# Forge repository instructions
Read `docs/PROJECT_OVERVIEW.md`, `CURRENT_STATE.md`, `DECISIONS.md`, `TASKS.md`, and `HANDOFF.md` before task work. Inspect Git status and relevant code. One accepted implementation task uses a dedicated branch and separate worktree. Preserve unrelated changes and legacy skills. Task IDs use `FORGE-F###`; record implementation, validation, limitations, and handoff. Only mark a task complete after human acceptance. Never commit secrets. Do not modify external projects, production infrastructure, or installed skills as part of foundation work.
+5 -1
View File
@@ -1 +1,5 @@
init # Bortstack Forge
Forge is a technology-agnostic foundation for project creation and development workflows. [Architecture](docs/ARCHITECTURE.md), [current state](docs/CURRENT_STATE.md), and [tasks](docs/TASKS.md) describe what exists and what is reserved.
The four canonical skill names are reserved; no skill is implemented yet. `python3 scripts/install-skills.py --list` shows their state. See [skill distribution](docs/specifications/skill-distribution.md) for installation and update procedures.
+5
View File
@@ -0,0 +1,5 @@
# Architecture
`forge/` reserves a framework-independent core. `templates/` contains independent stack-specific packages; `flask-react/` is a reservation only. `skills/` is the canonical source for four future skills. `profiles/` holds minimal business and personal defaults. `scripts/` provides portable user-level skill distribution. `docs/specifications/` defines interfaces; integrations are optional.
The context skill owns project records, tasks, worktrees, profiles, and design approvals. New delegates lifecycle setup to context. Contributor uses the context lifecycle with Captain/Commander authority and isolated testing. Design uses context for approvals and records. These are contracts, not active skill implementations.
+3
View File
@@ -0,0 +1,3 @@
# Current state
FORGE-F001 foundation is accepted for integration. The repo initially contained only a five-byte README on `main`; no prior local task or decision files existed. Four skill directories are reserved with README files, so no Forge skills are installable. The installer, validator, specifications, profiles, and automated tests are present. No generator, design integration, or active skill migration has been implemented. Linux tests passed locally; Windows has not been tested.
+18
View File
@@ -0,0 +1,18 @@
# Architecture decisions
All five decisions were supplied as approved planning inputs on 2026-11-17. No earlier Forge decision records existed. None supersedes an earlier decision.
## FORGE-001 — Technology-Agnostic Architecture
Status: Accepted. Date: 2026-11-17. Rationale: project lifecycle must apply across stacks. Consequences: Core has no Flask, React, React Native, or other framework dependency; templates own stack-specific behavior. Supersedes: none.
## FORGE-002 — Centralised Skill Management
Status: Accepted. Date: 2026-11-17. Rationale: one canonical source avoids divergent skill copies. Consequences: Forge will maintain `bortstack-context`, `bortstack-new`, `bortstack-contributor`, and `bortstack-design`; existing `roborto-*` skills remain until validated migration. Supersedes: none.
## FORGE-003 — Penpot Integration
Status: Accepted. Date: 2026-11-17. Rationale: Penpot is the selected visual design platform. Consequences: integration is optional and outside Core. Supersedes: none.
## FORGE-004 — Retrofittable Visual Design Workflow
Status: Accepted. Date: 2026-11-17. Rationale: new and existing projects need the same design lifecycle. Consequences: context owns design references and approvals; design owns Penpot operations and handoffs; implementation needs approved design or recorded override; PitchInvader is the initial pilot. Supersedes: none.
## FORGE-005 — Business/Personal Profiles
Status: Accepted. Date: 2026-11-17. Rationale: project settings vary by development context. Consequences: profile, ownership, branding, and contributor permissions are distinct; neither profile implies ownership. Supersedes: none.
+5
View File
@@ -0,0 +1,5 @@
# Handoff
Task: FORGE-F001. Worktree: `/tmp/bortstack-forge-f001`; branch: `codex-forge-f001`. Foundation implementation was accepted by the user for commit and merge into `main`. Run `python3 -m unittest discover -s tests -v`, `python3 scripts/validate-skills.py`, and `python3 scripts/install-skills.py --list`. No Forge skill can currently be installed. Do not migrate or replace existing `roborto-*` skills. Windows installer behavior remains unverified on Windows. Next: review this foundation, then separately authorize the first skill implementation.
No `testtask` or snapshot adapter was present in this new repository. The installed Roborto context skill normally provisions those for application repositories; Forge has no application runtime or Docker test environment yet. A separate task should resolve a Forge-specific manual-test adapter before treating this repository as enrolled in that full workflow.
+3
View File
@@ -0,0 +1,3 @@
# Project overview
Bortstack Forge will manage a framework-independent core, independently maintained application templates, four canonical Codex skills, project profiles, and optional integrations. This repository is the canonical source for future Forge skills. FORGE-F001 establishes contracts and distribution only. Flask/React code remains in its existing source repository. Penpot and repository-provider integrations are optional and absent.
+7
View File
@@ -0,0 +1,7 @@
# Tasks
## FORGE-F001 — Repository Foundation & Shared Skill Architecture
Status: Complete; human acceptance received 2026-11-17. Approved scope: structure, specifications, portable installer and validation. Acceptance: documented architecture and decisions; safe installer that ignores reserved skills; tests pass; legacy skills and external repositories remain untouched. Task branch/worktree: `codex-forge-f001` at `/tmp/bortstack-forge-f001`. Skill implementation and migration are excluded.
## Suggested next task
Implement `bortstack-context` as the first canonical skill, including compatibility checks against the existing `roborto-project-context`; authorize and scope separately.
@@ -0,0 +1,5 @@
# Integration and skill interfaces
`bortstack-context`: project overview/current state, decisions, tasks, handoffs, task-scoped branches/worktrees, design references/approvals, and profile interpretation for new and existing repositories. `bortstack-new`: template selection, generation orchestration, initial configuration and profile, optional Git repository configuration; delegates lifecycle conventions to context. `bortstack-contributor`: onboarding, permitted task creation and implementation, PR preparation, contributor tests and handoff; preserves JJ's task creation, Captain/Commander terminology, isolated branches, and disposable Docker test environments. Manual-testing containers remain available until the contributor is instructed to remove them. `bortstack-design`: visual design orchestration, optional Penpot/MCP operations, concepts, approved handoff, code guidance, and visual QA; delegates task status and approvals to context. Design-dependent implementation needs an approved design or an explicit recorded override.
Git providers and Penpot are optional adapters. A provider integration must declare authentication, supported operations, failure behavior, and local-only fallback; no provider is assumed. Penpot absence must not block context or non-design tasks. No MCP server or provider integration is configured in this task.
+3
View File
@@ -0,0 +1,3 @@
# Project profile contract
`profiles/business.yaml` and `profiles/personal.yaml` are flat records with `profile`, `development_context`, `ownership`, `branding`, `contributor_access`, `testing_expectations`, and `deployment_expectations`. The last five values are project-specific placeholders until explicit project configuration is recorded. Business does not imply Bortstack ownership. Profile selection is explicit for new or existing projects; existing repositories are never classified automatically. Profile, owner, brand, and contributor permissions are separate decisions. No inheritance or merge algorithm is defined.
+5
View File
@@ -0,0 +1,5 @@
# Skill package contract
An implemented package lives at `skills/<name>/SKILL.md`. Optional `references/`, `scripts/`, and `assets/` directories hold supporting content. The UTF-8 manifest starts with YAML front matter containing unique `name` and nonempty `description`; name must match the directory. A nonempty instruction body is required. The validator checks the minimum metadata and rejects symlinks or likely credential files; it is not a full YAML parser or secret scanner. Reserved directories contain README files only and are not discovered as packages.
Each skill has one clear responsibility and a distinct activation description. Shared lifecycle rules belong to context, with other skills referring to it rather than copying it. Document required skills and optional integrations in each future manifest. If a required skill is unavailable, report it; do not improvise. Use platform-neutral paths and commands or provide Linux and Windows variants. Repository providers are configurable; GitHub is not assumed. Framework behavior belongs only in a named template. Skills should operate outside Forge where their responsibility allows.
@@ -0,0 +1,9 @@
# Skill distribution and migration
Canonical source is `skills/` in this repository. Only directories with valid `SKILL.md` are installable. The current version identifier is the Forge Git commit or task branch revision; there is no independent package version yet. Record the source commit when installing or updating. Installer defaults to `$CODEX_HOME/skills` or `~/.codex/skills`, on Linux and Windows. It copies packages by default, requires no administrator rights for a writable user directory, and never overwrites an existing path. `--link` requests a development symlink and may fail where Windows symlink privileges are unavailable.
Linux: `python3 scripts/install-skills.py --list`, `--dry-run`, `--install NAME`, or `--all`; `sh scripts/install-skills.sh` forwards the same arguments. Windows PowerShell: `py -3 scripts/install-skills.py --list` or `./scripts/install-skills.ps1 --list`. Use `--dest "path with spaces"` for an isolated skills directory. `--dry-run` plans all implemented skills. Missing and invalid skills fail cleanly. An existing installation conflicts; no force switch exists.
Update procedure: identify and record the target Forge commit, validate and test that revision, inspect the installed package, move its destination to a user-controlled backup, install the selected new package, restart Codex if needed, test activation and compatibility, then delete the backup only after acceptance. On failure, remove the new package and restore the backup. The installer itself never removes old packages.
Migration plan: inventory actual installed `roborto-*` directories and internal references on each machine; map `roborto-project-context` to `bortstack-context`, `roborto-new-project` to `bortstack-new`, and `roborto-contributor` to `bortstack-contributor`. `bortstack-design` is new. Preserve context, task, handoff, snapshot, contributor permission, Captain/Commander, and Docker manual-testing behavior. Update internal cross-skill references only after matching implementations exist. Test legacy/new interaction in isolation before exposing both as active, then test Linux installation and JJ's Windows installation separately. Keep old installations until consumer references and user workflows pass; roll back by restoring backups and references. Retire old names only by separate accepted task. FORGE-F001 performs none of this migration.
+5
View File
@@ -0,0 +1,5 @@
# Template contract
A future template descriptor must identify template ID and version, supported project type, configuration variables, generation procedure, dependencies, development commands, validation/test commands, and optional capabilities. It must state platform requirements and how it produces initial context. No descriptor format or generation API is implemented yet.
The first migration source is the existing `flask-react-auth-base` repository. Its documented `scripts/create-project.sh` accepts a project name, destination, and optional `--git-init`, and refuses existing destinations. It remains external and unchanged. Migration of its code or generator is a separate task.
+3
View File
@@ -0,0 +1,3 @@
# Forge Core
Reserved for framework-independent orchestration. No generator or runtime code is implemented in FORGE-F001.
+7
View File
@@ -0,0 +1,7 @@
profile: business
development_context: business
ownership: project-specific
branding: project-specific
contributor_access: explicit-project-policy
testing_expectations: project-specific
deployment_expectations: project-specific
+7
View File
@@ -0,0 +1,7 @@
profile: personal
development_context: personal
ownership: project-specific
branding: project-specific
contributor_access: explicit-project-policy
testing_expectations: project-specific
deployment_expectations: project-specific
+3
View File
@@ -0,0 +1,3 @@
$ErrorActionPreference = 'Stop'
& py -3 (Join-Path $PSScriptRoot 'install-skills.py') @args
exit $LASTEXITCODE
+130
View File
@@ -0,0 +1,130 @@
#!/usr/bin/env python3
"""Install implemented Forge skills into a user-level Codex skills directory."""
import argparse
import os
from pathlib import Path
import re
import shutil
import sys
import tempfile
ROOT = Path(__file__).resolve().parent.parent
SKILLS = ROOT / 'skills'
RESERVED = {'bortstack-context', 'bortstack-new', 'bortstack-contributor', 'bortstack-design'}
NAME = re.compile(r'^[a-z][a-z0-9-]*$')
def manifest(path):
file = path / 'SKILL.md'
if not file.is_file() or file.is_symlink():
raise ValueError(f'{path.name}: missing SKILL.md')
lines = file.read_text(encoding='utf-8').splitlines()
if not lines or lines[0].strip() != '---':
raise ValueError(f'{path.name}: missing YAML front matter')
try:
end = lines.index('---', 1)
except ValueError:
raise ValueError(f'{path.name}: unclosed YAML front matter') from None
fields = {}
for line in lines[1:end]:
if not line.strip() or line.lstrip().startswith('#'):
continue
if ':' not in line:
raise ValueError(f'{path.name}: invalid metadata line')
key, value = line.split(':', 1)
if key.strip() in fields:
raise ValueError(f'{path.name}: duplicate {key.strip()}')
fields[key.strip()] = value.strip().strip('"\'')
if fields.get('name') != path.name or not NAME.fullmatch(path.name):
raise ValueError(f'{path.name}: name must match directory')
if not fields.get('description'):
raise ValueError(f'{path.name}: missing description')
if not any(line.strip() for line in lines[end + 1:]):
raise ValueError(f'{path.name}: empty skill body')
return fields
def discover():
return sorted(p for p in SKILLS.iterdir() if p.is_dir() and not p.is_symlink() and (p / 'SKILL.md').exists())
def destination():
codex_home = os.environ.get('CODEX_HOME')
return Path(codex_home).expanduser() / 'skills' if codex_home else Path.home() / '.codex' / 'skills'
def safe_source(path):
for entry in path.rglob('*'):
if entry.is_symlink():
raise ValueError(f'{path.name}: source contains symlink: {entry.relative_to(path)}')
if entry.is_file() and (entry.name.startswith('.env') or entry.suffix.lower() in {'.pem', '.key', '.p12', '.pfx'} or entry.name.lower() in {'id_rsa', 'id_ed25519'}):
raise ValueError(f'{path.name}: possible credential file: {entry.relative_to(path)}')
def main(argv=None):
parser = argparse.ArgumentParser(description=__doc__)
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--list', action='store_true')
group.add_argument('--dry-run', action='store_true')
group.add_argument('--install', action='append', metavar='NAME')
group.add_argument('--all', action='store_true')
parser.add_argument('--dest', type=Path, default=None, help='skills directory (default: CODEX_HOME/skills or ~/.codex/skills)')
parser.add_argument('--link', action='store_true', help='development symlinks instead of copies')
args = parser.parse_args(argv)
dest = (args.dest or destination()).expanduser()
found = discover()
valid = {}
errors = []
for path in found:
try:
manifest(path)
safe_source(path)
valid[path.name] = path
except (ValueError, UnicodeError) as exc:
errors.append(str(exc))
if args.list:
for name in sorted(RESERVED | set(valid)):
print(f'{name}: {"implemented" if name in valid else "reserved"} -> {dest / name}')
for error in errors:
print(f'INVALID: {error}', file=sys.stderr)
return 1 if errors else 0
requested = list(valid) if args.all or args.dry_run else args.install
problems = list(errors)
for name in requested:
if name not in valid:
problems.append(f'{name}: missing, reserved, or invalid skill')
if problems:
for problem in problems:
print(f'ERROR: {problem}', file=sys.stderr)
return 1
conflicts = [name for name in requested if (dest / name).exists() or (dest / name).is_symlink()]
for name in requested:
print(f'{"CONFLICT" if name in conflicts else "PLAN" if args.dry_run else "INSTALL"}: {name} -> {dest / name}')
if conflicts:
print('Existing installations are never overwritten. Remove or move a destination explicitly before retrying.', file=sys.stderr)
return 1
if args.dry_run:
return 0
dest.mkdir(parents=True, exist_ok=True)
for name in requested:
target = dest / name
if args.link:
try:
target.symlink_to(valid[name], target_is_directory=True)
except OSError as exc:
print(f'ERROR: symlink failed for {name}: {exc}', file=sys.stderr)
return 1
else:
temp = Path(tempfile.mkdtemp(prefix=f'.{name}-', dir=dest))
try:
shutil.copytree(valid[name], temp, dirs_exist_ok=True, symlinks=False)
temp.rename(target)
except OSError as exc:
shutil.rmtree(temp, ignore_errors=True)
print(f'ERROR: installation failed for {name}: {exc}', file=sys.stderr)
return 1
return 0
if __name__ == '__main__':
sys.exit(main())
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
set -eu
exec python3 "$(dirname "$0")/install-skills.py" "$@"
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env python3
"""Validate implemented canonical skill packages."""
from importlib.machinery import SourceFileLoader
from pathlib import Path
import sys
installer = SourceFileLoader('forge_installer', str(Path(__file__).with_name('install-skills.py'))).load_module()
errors = []
for path in installer.discover():
try:
installer.manifest(path)
installer.safe_source(path)
print(f'VALID: {path.name}')
except (ValueError, UnicodeError) as exc:
errors.append(str(exc))
for error in errors:
print(f'INVALID: {error}', file=sys.stderr)
print(f'{len(installer.discover()) - len(errors)} implemented skill(s); {len(installer.RESERVED - {p.name for p in installer.discover()})} reserved')
sys.exit(bool(errors))
+3
View File
@@ -0,0 +1,3 @@
# bortstack-context
Reserved for a separate implementation task. No SKILL.md is provided.
+3
View File
@@ -0,0 +1,3 @@
# bortstack-contributor
Reserved for a separate implementation task. No SKILL.md is provided.
+3
View File
@@ -0,0 +1,3 @@
# bortstack-design
Reserved for a separate implementation task. No SKILL.md is provided.
+3
View File
@@ -0,0 +1,3 @@
# bortstack-new
Reserved for a separate implementation task. No SKILL.md is provided.
+3
View File
@@ -0,0 +1,3 @@
# Flask/React template reservation
Initial migration source: `/home/rob/projects/flask-react-auth-base` in the current development environment. Its `scripts/create-project.sh` generates a clean project copy and optionally initializes Git. This source has not been moved, copied, or rewritten here. The path is discovery evidence, not a portable dependency. See the [template contract](../../docs/specifications/template-contract.md).
+79
View File
@@ -0,0 +1,79 @@
import os
from pathlib import Path
import shutil
import subprocess
import sys
import tempfile
import unittest
SCRIPT = Path(__file__).resolve().parents[1] / 'scripts' / 'install-skills.py'
class InstallerTests(unittest.TestCase):
def setUp(self):
self.tmp = tempfile.TemporaryDirectory(prefix='forge path with spaces ')
self.addCleanup(self.tmp.cleanup)
self.root = Path(self.tmp.name) / 'repo with spaces'
(self.root / 'scripts').mkdir(parents=True)
(self.root / 'skills').mkdir()
shutil.copy2(SCRIPT, self.root / 'scripts' / SCRIPT.name)
self.dest = Path(self.tmp.name) / 'Codex skills with spaces'
self.legacy = self.dest / 'roborto-project-context'
self.legacy.mkdir(parents=True)
(self.legacy / 'SKILL.md').write_text('legacy untouched')
def skill(self, name='bortstack-context', description='Context workflow'):
path = self.root / 'skills' / name
path.mkdir()
(path / 'SKILL.md').write_text(f'---\nname: {name}\ndescription: {description}\n---\n\n# Instructions\n', encoding='utf-8')
return path
def run_cli(self, *args):
return subprocess.run([sys.executable, str(self.root / 'scripts' / SCRIPT.name), *args, '--dest', str(self.dest)], capture_output=True, text=True)
def test_reserved_not_discovered(self):
(self.root / 'skills' / 'bortstack-design').mkdir()
(self.root / 'skills' / 'bortstack-design' / 'README.md').write_text('reserved')
result = self.run_cli('--list')
self.assertEqual(result.returncode, 0)
self.assertIn('bortstack-design: reserved', result.stdout)
self.assertNotIn('bortstack-design: implemented', result.stdout)
self.assertNotIn('roborto-project-context:', result.stdout)
def test_dry_run_and_copy_with_spaces_and_legacy_preserved(self):
self.skill()
dry = self.run_cli('--dry-run')
self.assertEqual(dry.returncode, 0, dry.stderr)
self.assertFalse((self.dest / 'bortstack-context').exists())
installed = self.run_cli('--install', 'bortstack-context')
self.assertEqual(installed.returncode, 0, installed.stderr)
self.assertTrue((self.dest / 'bortstack-context' / 'SKILL.md').exists())
self.assertEqual((self.legacy / 'SKILL.md').read_text(), 'legacy untouched')
def test_conflict_refuses_overwrite(self):
self.skill()
target = self.dest / 'bortstack-context'
target.mkdir()
(target / 'SKILL.md').write_text('existing')
result = self.run_cli('--install', 'bortstack-context')
self.assertNotEqual(result.returncode, 0)
self.assertIn('CONFLICT', result.stdout)
self.assertEqual((target / 'SKILL.md').read_text(), 'existing')
def test_missing_and_invalid_rejected(self):
self.assertNotEqual(self.run_cli('--install', 'bortstack-context').returncode, 0)
self.skill(description='')
invalid = self.run_cli('--install', 'bortstack-context')
self.assertNotEqual(invalid.returncode, 0)
self.assertIn('missing description', invalid.stderr)
def test_credential_rejected(self):
path = self.skill()
(path / '.env').write_text('SECRET=x')
result = self.run_cli('--dry-run')
self.assertNotEqual(result.returncode, 0)
self.assertIn('credential', result.stderr)
if __name__ == '__main__':
unittest.main()