crypts-and-commits 0.2.0__tar.gz
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.
- crypts_and_commits-0.2.0/PKG-INFO +44 -0
- crypts_and_commits-0.2.0/README.md +29 -0
- crypts_and_commits-0.2.0/pyproject.toml +33 -0
- crypts_and_commits-0.2.0/src/cac/__init__.py +0 -0
- crypts_and_commits-0.2.0/src/cac/cli/__init__.py +0 -0
- crypts_and_commits-0.2.0/src/cac/cli/app.py +33 -0
- crypts_and_commits-0.2.0/src/cac/cli/bootstrap.py +114 -0
- crypts_and_commits-0.2.0/src/cac/cli/campaign.py +225 -0
- crypts_and_commits-0.2.0/src/cac/cli/common.py +34 -0
- crypts_and_commits-0.2.0/src/cac/cli/docs.py +51 -0
- crypts_and_commits-0.2.0/src/cac/cli/encounter.py +385 -0
- crypts_and_commits-0.2.0/src/cac/cli/index.py +91 -0
- crypts_and_commits-0.2.0/src/cac/cli/lore.py +230 -0
- crypts_and_commits-0.2.0/src/cac/cli/prime.py +107 -0
- crypts_and_commits-0.2.0/src/cac/cli/region.py +163 -0
- crypts_and_commits-0.2.0/src/cac/cli/world.py +65 -0
- crypts_and_commits-0.2.0/src/cac/core/__init__.py +0 -0
- crypts_and_commits-0.2.0/src/cac/core/bootstrap.py +184 -0
- crypts_and_commits-0.2.0/src/cac/core/budget.py +75 -0
- crypts_and_commits-0.2.0/src/cac/core/campaign.py +393 -0
- crypts_and_commits-0.2.0/src/cac/core/config.py +58 -0
- crypts_and_commits-0.2.0/src/cac/core/docs.py +70 -0
- crypts_and_commits-0.2.0/src/cac/core/encounter.py +595 -0
- crypts_and_commits-0.2.0/src/cac/core/frontmatter_utils.py +100 -0
- crypts_and_commits-0.2.0/src/cac/core/git_utils.py +28 -0
- crypts_and_commits-0.2.0/src/cac/core/lore.py +185 -0
- crypts_and_commits-0.2.0/src/cac/core/paths.py +44 -0
- crypts_and_commits-0.2.0/src/cac/core/prime.py +97 -0
- crypts_and_commits-0.2.0/src/cac/core/region.py +198 -0
- crypts_and_commits-0.2.0/src/cac/core/search_index.py +409 -0
- crypts_and_commits-0.2.0/src/cac/core/skills.py +32 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/__init__.py +5 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/codex/__init__.py +1 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/codex/sourcebook_guard.py +41 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/docs/__init__.py +0 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/docs/migration-guide.md +88 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/docs/workflow.md +544 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/skills/__init__.py +0 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/skills/claude/__init__.py +0 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/skills/claude/campaign_manager/SKILL.md +173 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/skills/claude/campaign_manager/__init__.py +0 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/skills/claude/world_manager/SKILL.md +84 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/skills/claude/world_manager/__init__.py +0 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/skills/codex/__init__.py +0 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/skills/codex/campaign_manager/SKILL.md +176 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/skills/codex/campaign_manager/__init__.py +0 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/skills/codex/world_manager/SKILL.md +87 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/skills/codex/world_manager/__init__.py +0 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/sourcebook/__init__.py +0 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/sourcebook/campaign.md +9 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/sourcebook/encounter.md +27 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/sourcebook/encounter_unscripted.md +19 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/sourcebook/lore.md +10 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/sourcebook/region.md +8 -0
- crypts_and_commits-0.2.0/src/cac/core/templates/sourcebook/world.md +8 -0
- crypts_and_commits-0.2.0/src/cac/core/world.py +126 -0
- crypts_and_commits-0.2.0/src/cac/mcp/__init__.py +0 -0
- crypts_and_commits-0.2.0/src/cac/mcp/campaign.py +99 -0
- crypts_and_commits-0.2.0/src/cac/mcp/docs.py +29 -0
- crypts_and_commits-0.2.0/src/cac/mcp/encounter.py +154 -0
- crypts_and_commits-0.2.0/src/cac/mcp/index.py +57 -0
- crypts_and_commits-0.2.0/src/cac/mcp/instance.py +3 -0
- crypts_and_commits-0.2.0/src/cac/mcp/lore.py +103 -0
- crypts_and_commits-0.2.0/src/cac/mcp/prime.py +45 -0
- crypts_and_commits-0.2.0/src/cac/mcp/region.py +69 -0
- crypts_and_commits-0.2.0/src/cac/mcp/server.py +12 -0
- crypts_and_commits-0.2.0/src/cac/mcp/world.py +27 -0
- crypts_and_commits-0.2.0/tests/cli/conftest.py +58 -0
- crypts_and_commits-0.2.0/tests/cli/test_app.py +37 -0
- crypts_and_commits-0.2.0/tests/cli/test_bootstrap.py +197 -0
- crypts_and_commits-0.2.0/tests/cli/test_campaign.py +474 -0
- crypts_and_commits-0.2.0/tests/cli/test_common.py +35 -0
- crypts_and_commits-0.2.0/tests/cli/test_docs.py +44 -0
- crypts_and_commits-0.2.0/tests/cli/test_encounter.py +760 -0
- crypts_and_commits-0.2.0/tests/cli/test_index.py +209 -0
- crypts_and_commits-0.2.0/tests/cli/test_lore.py +473 -0
- crypts_and_commits-0.2.0/tests/cli/test_prime.py +243 -0
- crypts_and_commits-0.2.0/tests/cli/test_region.py +327 -0
- crypts_and_commits-0.2.0/tests/cli/test_world.py +140 -0
- crypts_and_commits-0.2.0/tests/conftest.py +27 -0
- crypts_and_commits-0.2.0/tests/core/test_bootstrap.py +246 -0
- crypts_and_commits-0.2.0/tests/core/test_budget.py +146 -0
- crypts_and_commits-0.2.0/tests/core/test_campaign.py +611 -0
- crypts_and_commits-0.2.0/tests/core/test_config.py +9 -0
- crypts_and_commits-0.2.0/tests/core/test_docs.py +62 -0
- crypts_and_commits-0.2.0/tests/core/test_encounter.py +1006 -0
- crypts_and_commits-0.2.0/tests/core/test_frontmatter_utils.py +159 -0
- crypts_and_commits-0.2.0/tests/core/test_git_utils.py +51 -0
- crypts_and_commits-0.2.0/tests/core/test_lore.py +449 -0
- crypts_and_commits-0.2.0/tests/core/test_paths.py +34 -0
- crypts_and_commits-0.2.0/tests/core/test_prime.py +174 -0
- crypts_and_commits-0.2.0/tests/core/test_region.py +414 -0
- crypts_and_commits-0.2.0/tests/core/test_search_index.py +613 -0
- crypts_and_commits-0.2.0/tests/core/test_skills.py +41 -0
- crypts_and_commits-0.2.0/tests/core/test_templates.py +7 -0
- crypts_and_commits-0.2.0/tests/core/test_world.py +312 -0
- crypts_and_commits-0.2.0/tests/mcp/test_campaign.py +144 -0
- crypts_and_commits-0.2.0/tests/mcp/test_docs.py +41 -0
- crypts_and_commits-0.2.0/tests/mcp/test_encounter.py +186 -0
- crypts_and_commits-0.2.0/tests/mcp/test_index.py +112 -0
- crypts_and_commits-0.2.0/tests/mcp/test_lore.py +96 -0
- crypts_and_commits-0.2.0/tests/mcp/test_prime.py +71 -0
- crypts_and_commits-0.2.0/tests/mcp/test_region.py +71 -0
- crypts_and_commits-0.2.0/tests/mcp/test_server.py +65 -0
- crypts_and_commits-0.2.0/tests/mcp/test_world.py +51 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: crypts-and-commits
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A Coding Assistant Continuity Framework. Crypts and Commits uses a tabletop-gaming metaphor to describe collaboration between a developer and an AI coding assistant. The developer acts as the Game Master: establishing context, making decisions, and retaining final authority.
|
|
5
|
+
Author-Email: John Hoff <john.hoff@braindonor.net>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Requires-Dist: typer
|
|
9
|
+
Requires-Dist: rich
|
|
10
|
+
Requires-Dist: click
|
|
11
|
+
Requires-Dist: python-frontmatter
|
|
12
|
+
Requires-Dist: mcp>=2.0.0
|
|
13
|
+
Requires-Dist: tomlkit>=0.15.1
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# crypts-and-commits
|
|
17
|
+
|
|
18
|
+
A Coding Assistant Continuity Framework. Crypts and Commits ("CAC") uses a tabletop-gaming metaphor to describe collaboration between a developer and an AI coding assistant: the developer plays Game Master, establishing context, making decisions, and retaining final authority; the assistant plays through that context to get work done. The `cac` CLI and its `cac-mcp` MCP server are how an assistant records project context and tracks its own work across sessions, so continuity survives context resets instead of being rebuilt from scratch every time.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install crypts-and-commits
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
This installs the `cac` CLI and the `cac-mcp` MCP server console script.
|
|
27
|
+
|
|
28
|
+
## Quickstart
|
|
29
|
+
|
|
30
|
+
From your project's root directory, run `cac bootstrap init`. This one-time, developer-run command sets up everything an agent needs: it creates a `.sourcebook/` directory, registers the `crypts-and-commits` MCP server, and deploys the `world-manager` and `campaign-manager` agent skills.
|
|
31
|
+
|
|
32
|
+
For the full walkthrough, see the [Quickstart guide](https://github.com/theBraindonor/crypts-and-commits/blob/main/docs/QUICKSTART.md).
|
|
33
|
+
|
|
34
|
+
## What's inside
|
|
35
|
+
|
|
36
|
+
`.sourcebook/` content is organized around a small domain model: **world** (project-level summary), **lore** (standards and conventions), **region** (a documented path within the repository), **campaign** (a long-running initiative), and **encounter** (a concrete unit of work within a campaign). An agent typically drives this content through the `cac-mcp` MCP server; the `cac` CLI covers the same operations as a fallback for sessions where the MCP server isn't available.
|
|
37
|
+
|
|
38
|
+
## Documentation
|
|
39
|
+
|
|
40
|
+
This package is one part of the `crypts-and-commits` development workspace — see the [project repository](https://github.com/theBraindonor/crypts-and-commits) for the full workspace. Deeper framework reference docs (e.g. the workflow guide) are available on demand via the `docs` CLI/MCP tools once your project is bootstrapped.
|
|
41
|
+
|
|
42
|
+
## License
|
|
43
|
+
|
|
44
|
+
Apache License 2.0 — see [LICENSE](https://github.com/theBraindonor/crypts-and-commits/blob/main/LICENSE).
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# crypts-and-commits
|
|
2
|
+
|
|
3
|
+
A Coding Assistant Continuity Framework. Crypts and Commits ("CAC") uses a tabletop-gaming metaphor to describe collaboration between a developer and an AI coding assistant: the developer plays Game Master, establishing context, making decisions, and retaining final authority; the assistant plays through that context to get work done. The `cac` CLI and its `cac-mcp` MCP server are how an assistant records project context and tracks its own work across sessions, so continuity survives context resets instead of being rebuilt from scratch every time.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install crypts-and-commits
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
This installs the `cac` CLI and the `cac-mcp` MCP server console script.
|
|
12
|
+
|
|
13
|
+
## Quickstart
|
|
14
|
+
|
|
15
|
+
From your project's root directory, run `cac bootstrap init`. This one-time, developer-run command sets up everything an agent needs: it creates a `.sourcebook/` directory, registers the `crypts-and-commits` MCP server, and deploys the `world-manager` and `campaign-manager` agent skills.
|
|
16
|
+
|
|
17
|
+
For the full walkthrough, see the [Quickstart guide](https://github.com/theBraindonor/crypts-and-commits/blob/main/docs/QUICKSTART.md).
|
|
18
|
+
|
|
19
|
+
## What's inside
|
|
20
|
+
|
|
21
|
+
`.sourcebook/` content is organized around a small domain model: **world** (project-level summary), **lore** (standards and conventions), **region** (a documented path within the repository), **campaign** (a long-running initiative), and **encounter** (a concrete unit of work within a campaign). An agent typically drives this content through the `cac-mcp` MCP server; the `cac` CLI covers the same operations as a fallback for sessions where the MCP server isn't available.
|
|
22
|
+
|
|
23
|
+
## Documentation
|
|
24
|
+
|
|
25
|
+
This package is one part of the `crypts-and-commits` development workspace — see the [project repository](https://github.com/theBraindonor/crypts-and-commits) for the full workspace. Deeper framework reference docs (e.g. the workflow guide) are available on demand via the `docs` CLI/MCP tools once your project is bootstrapped.
|
|
26
|
+
|
|
27
|
+
## License
|
|
28
|
+
|
|
29
|
+
Apache License 2.0 — see [LICENSE](https://github.com/theBraindonor/crypts-and-commits/blob/main/LICENSE).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "crypts-and-commits"
|
|
3
|
+
version = "0.2.0"
|
|
4
|
+
description = "A Coding Assistant Continuity Framework. Crypts and Commits uses a tabletop-gaming metaphor to describe collaboration between a developer and an AI coding assistant. The developer acts as the Game Master: establishing context, making decisions, and retaining final authority."
|
|
5
|
+
authors = [
|
|
6
|
+
{ name = "John Hoff", email = "john.hoff@braindonor.net" },
|
|
7
|
+
]
|
|
8
|
+
dependencies = [
|
|
9
|
+
"typer",
|
|
10
|
+
"rich",
|
|
11
|
+
"click",
|
|
12
|
+
"python-frontmatter",
|
|
13
|
+
"mcp>=2.0.0",
|
|
14
|
+
"tomlkit>=0.15.1",
|
|
15
|
+
]
|
|
16
|
+
requires-python = ">=3.11"
|
|
17
|
+
readme = "README.md"
|
|
18
|
+
|
|
19
|
+
[project.license]
|
|
20
|
+
text = "Apache-2.0"
|
|
21
|
+
|
|
22
|
+
[project.scripts]
|
|
23
|
+
cac = "cac.cli.app:app"
|
|
24
|
+
cac-mcp = "cac.mcp.server:main"
|
|
25
|
+
|
|
26
|
+
[build-system]
|
|
27
|
+
requires = [
|
|
28
|
+
"pdm-backend",
|
|
29
|
+
]
|
|
30
|
+
build-backend = "pdm.backend"
|
|
31
|
+
|
|
32
|
+
[tool.pdm]
|
|
33
|
+
distribution = true
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
|
|
3
|
+
from cac.cli.bootstrap import app as bootstrap_app
|
|
4
|
+
from cac.cli.campaign import app as campaign_app
|
|
5
|
+
from cac.cli.common import configure_output_encoding
|
|
6
|
+
from cac.cli.docs import app as docs_app
|
|
7
|
+
from cac.cli.encounter import app as encounter_app
|
|
8
|
+
from cac.cli.index import app as index_app
|
|
9
|
+
from cac.cli.lore import app as lore_app
|
|
10
|
+
from cac.cli.prime import app as prime_app
|
|
11
|
+
from cac.cli.region import app as region_app
|
|
12
|
+
from cac.cli.world import app as world_app
|
|
13
|
+
|
|
14
|
+
app = typer.Typer(
|
|
15
|
+
name="cac",
|
|
16
|
+
help="Crypts and Commits CLI.",
|
|
17
|
+
context_settings={"help_option_names": ["-h", "--help"]},
|
|
18
|
+
)
|
|
19
|
+
app.add_typer(bootstrap_app, name="bootstrap")
|
|
20
|
+
app.add_typer(campaign_app, name="campaign")
|
|
21
|
+
app.add_typer(docs_app, name="docs")
|
|
22
|
+
app.add_typer(encounter_app, name="encounter")
|
|
23
|
+
app.add_typer(index_app, name="index")
|
|
24
|
+
app.add_typer(lore_app, name="lore")
|
|
25
|
+
app.add_typer(prime_app, name="prime")
|
|
26
|
+
app.add_typer(region_app, name="region")
|
|
27
|
+
app.add_typer(world_app, name="world")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@app.callback()
|
|
31
|
+
def main() -> None:
|
|
32
|
+
"""Crypts and Commits - a Coding Assistant Continuity Framework."""
|
|
33
|
+
configure_output_encoding()
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
from rich.console import Console, Group
|
|
5
|
+
from rich.panel import Panel
|
|
6
|
+
from rich.text import Text
|
|
7
|
+
|
|
8
|
+
from cac.cli.common import fail
|
|
9
|
+
from cac.core import bootstrap as bootstrap_core
|
|
10
|
+
from cac.core import skills as skills_core
|
|
11
|
+
from cac.core import world as world_core
|
|
12
|
+
from cac.core.git_utils import GitIdentityError
|
|
13
|
+
|
|
14
|
+
TITLE = "Crypts And Commits"
|
|
15
|
+
SUBTITLE = "A Code Assistant Continuity Framework"
|
|
16
|
+
|
|
17
|
+
app = typer.Typer(help="Bootstrap a repository for Crypts and Commits.")
|
|
18
|
+
console = Console()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@app.command()
|
|
22
|
+
def init() -> None:
|
|
23
|
+
"""Create the .sourcebook directory and world file in the current repository."""
|
|
24
|
+
_show_splash()
|
|
25
|
+
root = Path.cwd()
|
|
26
|
+
|
|
27
|
+
sourcebook_dir, sourcebook_created = bootstrap_core.initialize(root)
|
|
28
|
+
_report(sourcebook_dir, sourcebook_created)
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
world_path, world_created = world_core.initialize_world(root)
|
|
32
|
+
except GitIdentityError as exc:
|
|
33
|
+
fail(console, str(exc))
|
|
34
|
+
_report(world_path, world_created)
|
|
35
|
+
if not world_created:
|
|
36
|
+
_report_schema_version(world_core.check_schema_version(root))
|
|
37
|
+
|
|
38
|
+
mcp_config_path, mcp_config_changed = bootstrap_core.initialize_mcp_config(root)
|
|
39
|
+
_report_mcp_config(mcp_config_path, mcp_config_changed)
|
|
40
|
+
|
|
41
|
+
claude_settings_path, claude_settings_changed = bootstrap_core.initialize_claude_settings(root)
|
|
42
|
+
_report_claude_settings(claude_settings_path, claude_settings_changed)
|
|
43
|
+
|
|
44
|
+
codex_config_path, codex_config_changed = bootstrap_core.initialize_codex_config(root)
|
|
45
|
+
_report_codex_config(codex_config_path, codex_config_changed)
|
|
46
|
+
|
|
47
|
+
codex_hook_path, codex_hook_changed = bootstrap_core.initialize_codex_guard_hook(root)
|
|
48
|
+
_report_codex_guard_hook(codex_hook_path, codex_hook_changed)
|
|
49
|
+
|
|
50
|
+
for skill_path, skill_changed in skills_core.deploy_skills(root):
|
|
51
|
+
_report_skill(skill_path, skill_changed)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _report(path: Path, created: bool) -> None:
|
|
55
|
+
if created:
|
|
56
|
+
console.print(f"Created [bold green]{path}[/bold green]")
|
|
57
|
+
else:
|
|
58
|
+
console.print(f"[bold yellow]{path}[/bold yellow] already exists")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _report_schema_version(status: world_core.SchemaVersionStatus) -> None:
|
|
62
|
+
if status.outcome == world_core.SCHEMA_VERSION_OUTCOME_BEHIND:
|
|
63
|
+
console.print(
|
|
64
|
+
f"[bold red]This sourcebook is on schema version {status.stored}[/bold red], behind the "
|
|
65
|
+
f"current version {status.current}. Ask your coding assistant to use the [bold]world-manager[/bold] "
|
|
66
|
+
'skill to migrate it - it consults the migration-guide doc (docs_get("migration-guide") / '
|
|
67
|
+
"cac docs get migration-guide) for the exact steps."
|
|
68
|
+
)
|
|
69
|
+
elif status.outcome == world_core.SCHEMA_VERSION_OUTCOME_AHEAD:
|
|
70
|
+
console.print(
|
|
71
|
+
f"[bold red]This sourcebook is on schema version {status.stored}[/bold red], ahead of the "
|
|
72
|
+
f"installed cac's version {status.current}. Upgrade your installed cac package."
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _report_mcp_config(path: Path, changed: bool) -> None:
|
|
77
|
+
if changed:
|
|
78
|
+
console.print(f"Registered the crypts-and-commits MCP server in [bold green]{path}[/bold green]")
|
|
79
|
+
else:
|
|
80
|
+
console.print(f"[bold yellow]{path}[/bold yellow] already registers the crypts-and-commits MCP server")
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _report_claude_settings(path: Path, changed: bool) -> None:
|
|
84
|
+
if changed:
|
|
85
|
+
console.print(f"Updated permissions in [bold green]{path}[/bold green]")
|
|
86
|
+
else:
|
|
87
|
+
console.print(f"[bold yellow]{path}[/bold yellow] already has the required permissions")
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _report_codex_config(path: Path, changed: bool) -> None:
|
|
91
|
+
if changed:
|
|
92
|
+
console.print(f"Registered the crypts-and-commits MCP server in [bold green]{path}[/bold green]")
|
|
93
|
+
else:
|
|
94
|
+
console.print(f"[bold yellow]{path}[/bold yellow] already registers the crypts-and-commits MCP server")
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _report_codex_guard_hook(path: Path, changed: bool) -> None:
|
|
98
|
+
if changed:
|
|
99
|
+
console.print(f"Deployed Codex sourcebook guard hook in [bold green]{path}[/bold green]")
|
|
100
|
+
else:
|
|
101
|
+
console.print(f"[bold yellow]{path}[/bold yellow] already has the current Codex sourcebook guard hook")
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def _report_skill(path: Path, changed: bool) -> None:
|
|
105
|
+
if changed:
|
|
106
|
+
console.print(f"Deployed [bold green]{path}[/bold green]")
|
|
107
|
+
else:
|
|
108
|
+
console.print(f"[bold yellow]{path}[/bold yellow] already up to date")
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _show_splash() -> None:
|
|
112
|
+
title = Text(TITLE, style="bold magenta", justify="center")
|
|
113
|
+
subtitle = Text(SUBTITLE, style="italic cyan", justify="center")
|
|
114
|
+
console.print(Panel(Group(title, subtitle), border_style="magenta", padding=(1, 4)))
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
from rich.console import Console
|
|
3
|
+
|
|
4
|
+
from cac.cli.common import edit_markdown, fail
|
|
5
|
+
from cac.core import budget as budget_core
|
|
6
|
+
from cac.core import campaign as campaign_core
|
|
7
|
+
from cac.core.git_utils import GitIdentityError
|
|
8
|
+
from cac.core.paths import resolve_project_root
|
|
9
|
+
|
|
10
|
+
app = typer.Typer(
|
|
11
|
+
help=(
|
|
12
|
+
"Manage campaign entries - long-running initiatives on the project, similar to an "
|
|
13
|
+
"'Epic' in Jira-style work tracking. A campaign is expected to require many "
|
|
14
|
+
"encounters, completed over time, before it is considered complete. Examples "
|
|
15
|
+
"include 'Create the MVP', 'Add Payment Processing', or a version increment. A "
|
|
16
|
+
"campaign moves through a fixed lifecycle: 'draft' (just created) -> 'open' (via "
|
|
17
|
+
"'open'; only one campaign may be open at a time) -> 'paused' (via 'pause') or back "
|
|
18
|
+
"to 'open' again -> 'completed' (via 'complete', from 'open' or 'paused'). It may "
|
|
19
|
+
"instead be 'abandoned' (via 'abandon') from 'draft', 'open', or 'paused' - but not "
|
|
20
|
+
"once 'completed'. 'pause', 'complete', and 'abandon' all fail while the campaign "
|
|
21
|
+
"still has an open encounter. 'complete' and 'abandon' each require a --message - a "
|
|
22
|
+
"postmortem recorded as a dated, attributed log entry on the campaign body. Once "
|
|
23
|
+
"'completed' or 'abandoned', the campaign's body is locked: 'update' fails, since the "
|
|
24
|
+
"postmortem is meant to be that campaign's closing record. Once a campaign and every one "
|
|
25
|
+
"of its encounters are 'completed'/'abandoned', it may be 'archive'd - moved into "
|
|
26
|
+
".sourcebook/archive/, out of the way of active work, without changing its status."
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
console = Console()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@app.command("get")
|
|
33
|
+
def get_campaign(
|
|
34
|
+
name: str = typer.Argument(..., help="Campaign name to show."),
|
|
35
|
+
) -> None:
|
|
36
|
+
"""Show a campaign file's frontmatter and body."""
|
|
37
|
+
try:
|
|
38
|
+
metadata, body = campaign_core.read_metadata(resolve_project_root(), name)
|
|
39
|
+
except campaign_core.CampaignNotFoundError as exc:
|
|
40
|
+
fail(console, str(exc))
|
|
41
|
+
|
|
42
|
+
for key, value in metadata.items():
|
|
43
|
+
console.print(f"[bold]{key}[/bold]: {value}")
|
|
44
|
+
console.print()
|
|
45
|
+
body = budget_core.truncate_body(body, campaign_core.campaign_path(resolve_project_root(), name))
|
|
46
|
+
console.print(body, markup=False, soft_wrap=True)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@app.command("list")
|
|
50
|
+
def list_campaigns(
|
|
51
|
+
cursor: str | None = typer.Option(None, "--cursor", help="Resume from a previous page's cursor."),
|
|
52
|
+
) -> None:
|
|
53
|
+
"""List the campaign files in .sourcebook/campaigns, with their current status, paged under
|
|
54
|
+
the response budget."""
|
|
55
|
+
entries = campaign_core.list_campaigns_with_status(resolve_project_root())
|
|
56
|
+
if not entries:
|
|
57
|
+
console.print("No campaign files found.")
|
|
58
|
+
return
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
page = budget_core.paginate(entries, cursor, render=lambda entry: f"{entry[0]} ({entry[1]})")
|
|
62
|
+
except budget_core.InvalidCursorError as exc:
|
|
63
|
+
fail(console, str(exc))
|
|
64
|
+
|
|
65
|
+
for name, status in page.items:
|
|
66
|
+
console.print(f"{name} ({status})")
|
|
67
|
+
if page.next_cursor is not None:
|
|
68
|
+
console.print(f"[dim]More results - pass --cursor {page.next_cursor} to continue.[/dim]")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@app.command("create")
|
|
72
|
+
def create_campaign(
|
|
73
|
+
name: str = typer.Argument(..., help="Campaign name (letters, numbers, underscores, hyphens, periods)."),
|
|
74
|
+
body: str | None = typer.Option(None, "--body", "-b", help="Markdown body. Opens an editor if omitted."),
|
|
75
|
+
) -> None:
|
|
76
|
+
"""Create a new campaign file."""
|
|
77
|
+
content = body if body is not None else edit_markdown(campaign_core.template_body())
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
path = campaign_core.create_campaign(resolve_project_root(), name, content)
|
|
81
|
+
except (campaign_core.InvalidCampaignNameError, campaign_core.CampaignAlreadyExistsError, GitIdentityError) as exc:
|
|
82
|
+
fail(console, str(exc))
|
|
83
|
+
|
|
84
|
+
console.print(f"Created [bold green]{path}[/bold green]")
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@app.command("update")
|
|
88
|
+
def update_campaign(
|
|
89
|
+
name: str = typer.Argument(..., help="Campaign name to update."),
|
|
90
|
+
body: str | None = typer.Option(None, "--body", "-b", help="Markdown body. Opens an editor if omitted."),
|
|
91
|
+
) -> None:
|
|
92
|
+
"""Update an existing campaign file's body. Fails once the campaign is 'completed' or
|
|
93
|
+
'abandoned' - its body is locked once its postmortem is recorded."""
|
|
94
|
+
try:
|
|
95
|
+
current = campaign_core.read_campaign(resolve_project_root(), name)
|
|
96
|
+
except campaign_core.CampaignNotFoundError as exc:
|
|
97
|
+
fail(console, str(exc))
|
|
98
|
+
|
|
99
|
+
content = body if body is not None else edit_markdown(current.body)
|
|
100
|
+
try:
|
|
101
|
+
path = campaign_core.update_campaign(resolve_project_root(), name, content)
|
|
102
|
+
except (campaign_core.CampaignNotMutableError, GitIdentityError) as exc:
|
|
103
|
+
fail(console, str(exc))
|
|
104
|
+
|
|
105
|
+
console.print(f"Updated [bold green]{path}[/bold green]")
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@app.command("delete")
|
|
109
|
+
def delete_campaign(
|
|
110
|
+
name: str = typer.Argument(..., help="Campaign name to delete."),
|
|
111
|
+
yes: bool = typer.Option(False, "--yes", "-y", help="Skip the confirmation prompt."),
|
|
112
|
+
) -> None:
|
|
113
|
+
"""Delete a campaign file."""
|
|
114
|
+
if not yes:
|
|
115
|
+
typer.confirm(f"Delete campaign {name!r}?", abort=True)
|
|
116
|
+
|
|
117
|
+
try:
|
|
118
|
+
path = campaign_core.delete_campaign(resolve_project_root(), name)
|
|
119
|
+
except campaign_core.CampaignNotFoundError as exc:
|
|
120
|
+
fail(console, str(exc))
|
|
121
|
+
|
|
122
|
+
console.print(f"Deleted [bold green]{path}[/bold green]")
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@app.command("open")
|
|
126
|
+
def open_campaign(
|
|
127
|
+
name: str = typer.Argument(..., help="Campaign name to open."),
|
|
128
|
+
) -> None:
|
|
129
|
+
"""Move a campaign from 'draft' or 'paused' to 'open'. Only one campaign may be open at a
|
|
130
|
+
time."""
|
|
131
|
+
try:
|
|
132
|
+
campaign_core.open_campaign(resolve_project_root(), name)
|
|
133
|
+
except (
|
|
134
|
+
campaign_core.CampaignNotFoundError,
|
|
135
|
+
campaign_core.InvalidCampaignTransitionError,
|
|
136
|
+
campaign_core.AnotherCampaignOpenError,
|
|
137
|
+
GitIdentityError,
|
|
138
|
+
) as exc:
|
|
139
|
+
fail(console, str(exc))
|
|
140
|
+
|
|
141
|
+
console.print(f"Opened [bold]{name}[/bold].")
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
@app.command("pause")
|
|
145
|
+
def pause_campaign(
|
|
146
|
+
name: str = typer.Argument(..., help="Campaign name to pause."),
|
|
147
|
+
) -> None:
|
|
148
|
+
"""Move a campaign from 'open' to 'paused'. Fails if it has an open encounter."""
|
|
149
|
+
try:
|
|
150
|
+
campaign_core.pause_campaign(resolve_project_root(), name)
|
|
151
|
+
except (
|
|
152
|
+
campaign_core.CampaignNotFoundError,
|
|
153
|
+
campaign_core.InvalidCampaignTransitionError,
|
|
154
|
+
campaign_core.CampaignHasOpenEncountersError,
|
|
155
|
+
GitIdentityError,
|
|
156
|
+
) as exc:
|
|
157
|
+
fail(console, str(exc))
|
|
158
|
+
|
|
159
|
+
console.print(f"Paused [bold]{name}[/bold].")
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
@app.command("complete")
|
|
163
|
+
def complete_campaign(
|
|
164
|
+
name: str = typer.Argument(..., help="Campaign name to complete."),
|
|
165
|
+
message: str = typer.Option(..., "--message", "-m", help="Postmortem for this campaign. Required."),
|
|
166
|
+
) -> None:
|
|
167
|
+
"""Move a campaign from 'open' or 'paused' to 'completed'. Fails if it has an open encounter.
|
|
168
|
+
The required message is recorded as the campaign's postmortem and its body is locked
|
|
169
|
+
thereafter."""
|
|
170
|
+
try:
|
|
171
|
+
campaign_core.complete_campaign(resolve_project_root(), name, message)
|
|
172
|
+
except (
|
|
173
|
+
campaign_core.CampaignNotFoundError,
|
|
174
|
+
campaign_core.InvalidCampaignTransitionError,
|
|
175
|
+
campaign_core.CampaignHasOpenEncountersError,
|
|
176
|
+
campaign_core.CampaignMessageRequiredError,
|
|
177
|
+
GitIdentityError,
|
|
178
|
+
) as exc:
|
|
179
|
+
fail(console, str(exc))
|
|
180
|
+
|
|
181
|
+
console.print(f"Completed [bold]{name}[/bold].")
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
@app.command("abandon")
|
|
185
|
+
def abandon_campaign(
|
|
186
|
+
name: str = typer.Argument(..., help="Campaign name to abandon."),
|
|
187
|
+
message: str = typer.Option(..., "--message", "-m", help="Postmortem for this campaign. Required."),
|
|
188
|
+
) -> None:
|
|
189
|
+
"""Move a campaign from 'draft', 'open', or 'paused' to 'abandoned'. Fails if it has an open
|
|
190
|
+
encounter. The required message is recorded as the campaign's postmortem and its body is
|
|
191
|
+
locked thereafter."""
|
|
192
|
+
try:
|
|
193
|
+
campaign_core.abandon_campaign(resolve_project_root(), name, message)
|
|
194
|
+
except (
|
|
195
|
+
campaign_core.CampaignNotFoundError,
|
|
196
|
+
campaign_core.InvalidCampaignTransitionError,
|
|
197
|
+
campaign_core.CampaignHasOpenEncountersError,
|
|
198
|
+
campaign_core.CampaignMessageRequiredError,
|
|
199
|
+
GitIdentityError,
|
|
200
|
+
) as exc:
|
|
201
|
+
fail(console, str(exc))
|
|
202
|
+
|
|
203
|
+
console.print(f"Abandoned [bold]{name}[/bold].")
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
@app.command("archive")
|
|
207
|
+
def archive_campaign(
|
|
208
|
+
name: str = typer.Argument(..., help="Campaign name to archive."),
|
|
209
|
+
) -> None:
|
|
210
|
+
"""Archive a campaign and all its encounters. The campaign must already be 'completed' or
|
|
211
|
+
'abandoned', and every one of its encounters must also be 'completed' or 'abandoned'. Moves the
|
|
212
|
+
campaign and its encounters into .sourcebook/archive/, mirroring their live layout, and sets
|
|
213
|
+
archived: true on each - status is preserved, not replaced."""
|
|
214
|
+
try:
|
|
215
|
+
campaign, archived_encounters = campaign_core.archive_campaign(resolve_project_root(), name)
|
|
216
|
+
except (
|
|
217
|
+
campaign_core.CampaignNotFoundError,
|
|
218
|
+
campaign_core.CampaignNotTerminalError,
|
|
219
|
+
campaign_core.CampaignAlreadyArchivedError,
|
|
220
|
+
campaign_core.CampaignHasUnfinishedEncountersError,
|
|
221
|
+
GitIdentityError,
|
|
222
|
+
) as exc:
|
|
223
|
+
fail(console, str(exc))
|
|
224
|
+
|
|
225
|
+
console.print(f"Archived [bold]{campaign.name}[/bold] and {len(archived_encounters)} encounter(s).")
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from typing import NoReturn
|
|
3
|
+
|
|
4
|
+
import click
|
|
5
|
+
import typer
|
|
6
|
+
from rich.console import Console
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def configure_output_encoding() -> None:
|
|
10
|
+
"""Force UTF-8 on the process stdout/stderr streams.
|
|
11
|
+
|
|
12
|
+
On Windows the interpreter's stdout/stderr default to the legacy code page
|
|
13
|
+
(cp1252), so ``rich`` fails with ``UnicodeEncodeError`` when printing stored
|
|
14
|
+
content that contains characters outside that page (arrows, dashes, smart
|
|
15
|
+
quotes, ...). Reconfiguring the streams to UTF-8 makes correct display
|
|
16
|
+
independent of the caller's environment.
|
|
17
|
+
|
|
18
|
+
Streams that do not support ``reconfigure`` (e.g. test-capture buffers or
|
|
19
|
+
some redirected streams that are not ``TextIOWrapper``) are left untouched.
|
|
20
|
+
"""
|
|
21
|
+
for stream in (sys.stdout, sys.stderr):
|
|
22
|
+
reconfigure = getattr(stream, "reconfigure", None)
|
|
23
|
+
if reconfigure is not None:
|
|
24
|
+
reconfigure(encoding="utf-8", errors="backslashreplace")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def edit_markdown(initial: str) -> str:
|
|
28
|
+
edited = click.edit(initial, extension=".txt")
|
|
29
|
+
return edited if edited is not None else initial
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def fail(console: Console, message: str) -> NoReturn:
|
|
33
|
+
console.print(f"[bold red]{message}[/bold red]")
|
|
34
|
+
raise typer.Exit(code=1)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
from rich.console import Console
|
|
3
|
+
|
|
4
|
+
from cac.cli.common import fail
|
|
5
|
+
from cac.core import budget as budget_core
|
|
6
|
+
from cac.core import docs as docs_core
|
|
7
|
+
from cac.core.config import DOCS_RESPONSE_BUDGET
|
|
8
|
+
|
|
9
|
+
app = typer.Typer(
|
|
10
|
+
help=(
|
|
11
|
+
"Read the framework's packaged reference docs - guide documents shipped with cac "
|
|
12
|
+
"(e.g. the Workflow Reference Guide), distinct from .sourcebook content. Read-only."
|
|
13
|
+
)
|
|
14
|
+
)
|
|
15
|
+
console = Console()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@app.command("list")
|
|
19
|
+
def list_docs(
|
|
20
|
+
cursor: str | None = typer.Option(None, "--cursor", help="Resume from a previous page's cursor."),
|
|
21
|
+
) -> None:
|
|
22
|
+
"""List registered docs as name + summary pairs, paged under the response budget."""
|
|
23
|
+
items = [{"name": name, "summary": summary} for name, summary in docs_core.list_docs()]
|
|
24
|
+
if not items:
|
|
25
|
+
console.print("No docs registered.")
|
|
26
|
+
return
|
|
27
|
+
|
|
28
|
+
try:
|
|
29
|
+
page = budget_core.paginate(items, cursor, render=lambda item: item["name"] + item["summary"])
|
|
30
|
+
except budget_core.InvalidCursorError as exc:
|
|
31
|
+
fail(console, str(exc))
|
|
32
|
+
|
|
33
|
+
for item in page.items:
|
|
34
|
+
console.print(f"[bold]{item['name']}[/bold]: ", end="")
|
|
35
|
+
console.print(item["summary"], markup=False)
|
|
36
|
+
if page.next_cursor is not None:
|
|
37
|
+
console.print(f"[dim]More results - pass --cursor {page.next_cursor} to continue.[/dim]")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@app.command("get")
|
|
41
|
+
def get_doc(
|
|
42
|
+
name: str = typer.Argument(..., help="Doc name to show."),
|
|
43
|
+
) -> None:
|
|
44
|
+
"""Show a registered doc's full body."""
|
|
45
|
+
try:
|
|
46
|
+
body = docs_core.read_doc(name)
|
|
47
|
+
except docs_core.DocNotFoundError as exc:
|
|
48
|
+
fail(console, str(exc))
|
|
49
|
+
|
|
50
|
+
body = budget_core.truncate_body(body, docs_core.doc_source_path(name), budget=DOCS_RESPONSE_BUDGET)
|
|
51
|
+
console.print(body, markup=False, soft_wrap=True)
|