git-intent 0.3.1__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zeng Deyang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,122 @@
1
+ Metadata-Version: 2.4
2
+ Name: git-intent
3
+ Version: 0.3.1
4
+ Summary: Semantic history for agent-driven development. Records what you did and why.
5
+ Author: Zeng Deyang
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/dozybot001/Intent
8
+ Project-URL: Repository, https://github.com/dozybot001/Intent
9
+ Keywords: agent,git,semantic-history,intent,developer-tools
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Version Control :: Git
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+
25
+ English | [简体中文](README.CN.md)
26
+
27
+ # Intent
28
+
29
+ > Git records code changes. Intent records why.
30
+
31
+ ## The Problem
32
+
33
+ Agent-driven development produces code fast, but reasoning disappears between sessions. Every new session starts from zero — the agent doesn't know what problem was being solved, what was tried, or why a path was chosen.
34
+
35
+ ## What's Missing
36
+
37
+ Git records *what* changed. Commit messages and comments add some context. But three things consistently fall through:
38
+
39
+ **Goal continuity.** Commits are isolated snapshots. There's no structure connecting five commits to one task, or saying "this is what we're trying to accomplish."
40
+
41
+ **Decision rationale.** Why JWT over cookies? Why 15-minute expiry? This rarely makes it into commit messages — and when it does, it's unstructured text that agents must parse and guess from.
42
+
43
+ **Work state.** `git status` can be clean while a task is half-done. The next session has no signal that work was interrupted or what comes next.
44
+
45
+ ## The Solution
46
+
47
+ Intent adds a `.intent/` directory to your repository — structured, machine-readable metadata that captures semantic history alongside code history.
48
+
49
+ ```
50
+ .git/ ← how code changed
51
+ .intent/ ← what you were doing and why
52
+ ```
53
+
54
+ Two objects: **intent** (the goal) and **snap** (a step taken, with rationale). All JSON. Any agent platform can read it.
55
+
56
+ ### What changes
57
+
58
+ **Without `.intent/`** — new agent session opens. It reads `git log` and source code. Understands what the code does *now*, but doesn't know the JWT migration was for compliance (might revert it), doesn't know the refresh token is intentionally incomplete, can't tell there's unfinished work. Asks: *"What would you like me to do?"*
59
+
60
+ **With `.intent/`** — new agent session opens. Runs `itt inspect`. Sees an active intent ("Migrate auth to JWT"), last snap ("Add refresh token — incomplete"), and rationale ("token rotation not done, security priority"). Says: *"I'll implement the token rotation next."*
61
+
62
+ The difference: 10 seconds of reading structured metadata vs. minutes of re-explaining context.
63
+
64
+ ## Core Loop
65
+
66
+ ```
67
+ start → snap → done
68
+ ```
69
+
70
+ - `start` — open an intent (what problem you're solving)
71
+ - `snap` — record a snap (what you did and why)
72
+ - `done` — close when complete
73
+
74
+ ## Example
75
+
76
+ ```bash
77
+ itt init
78
+ itt start "Fix login timeout"
79
+ itt snap "Increase timeout to 30s" -m "5s too short for slow networks"
80
+ git add . && git commit -m "fix timeout"
81
+ itt done
82
+ ```
83
+
84
+ ## Where This Is Going
85
+
86
+ `.intent/` is a protocol, not just a tool.
87
+
88
+ 1. **Agent memory** — agents read `.intent/` on startup, recover last session's context in seconds
89
+ 2. **Context exchange** — `.intent/` becomes the standard way to hand off work between agent platforms
90
+ 3. **Network effects** — when enough repos contain `.intent/`, new tooling emerges: intent-aware review, decision archaeology, semantic dashboards
91
+
92
+ ## Install
93
+
94
+ ```bash
95
+ pip install git-intent
96
+ ```
97
+
98
+ Or from source:
99
+
100
+ ```bash
101
+ git clone https://github.com/dozybot001/Intent.git && cd Intent
102
+ pip install -e .
103
+ ```
104
+
105
+ ## Commands
106
+
107
+ | Command | Purpose |
108
+ | --- | --- |
109
+ | `itt init` | Initialize `.intent/` in a Git repo |
110
+ | `itt start <title>` | Open an intent |
111
+ | `itt snap <title> [-m why]` | Record a snap |
112
+ | `itt done` | Close the active intent |
113
+ | `itt inspect` | Machine-readable workspace snapshot |
114
+ | `itt list <intent\|snap>` | List objects |
115
+ | `itt show <id>` | Show a single object |
116
+ | `itt adopt [id]` | Adopt a candidate snap |
117
+ | `itt revert` | Revert the latest snap |
118
+
119
+ ## Documentation
120
+
121
+ - [CLI spec](docs/cli.EN.md) — objects, commands, JSON output contract
122
+ - [Agent integration](docs/agent-integration.md) — copy-paste snippets for Claude Code, Cursor, AGENTS.md
@@ -0,0 +1,98 @@
1
+ English | [简体中文](README.CN.md)
2
+
3
+ # Intent
4
+
5
+ > Git records code changes. Intent records why.
6
+
7
+ ## The Problem
8
+
9
+ Agent-driven development produces code fast, but reasoning disappears between sessions. Every new session starts from zero — the agent doesn't know what problem was being solved, what was tried, or why a path was chosen.
10
+
11
+ ## What's Missing
12
+
13
+ Git records *what* changed. Commit messages and comments add some context. But three things consistently fall through:
14
+
15
+ **Goal continuity.** Commits are isolated snapshots. There's no structure connecting five commits to one task, or saying "this is what we're trying to accomplish."
16
+
17
+ **Decision rationale.** Why JWT over cookies? Why 15-minute expiry? This rarely makes it into commit messages — and when it does, it's unstructured text that agents must parse and guess from.
18
+
19
+ **Work state.** `git status` can be clean while a task is half-done. The next session has no signal that work was interrupted or what comes next.
20
+
21
+ ## The Solution
22
+
23
+ Intent adds a `.intent/` directory to your repository — structured, machine-readable metadata that captures semantic history alongside code history.
24
+
25
+ ```
26
+ .git/ ← how code changed
27
+ .intent/ ← what you were doing and why
28
+ ```
29
+
30
+ Two objects: **intent** (the goal) and **snap** (a step taken, with rationale). All JSON. Any agent platform can read it.
31
+
32
+ ### What changes
33
+
34
+ **Without `.intent/`** — new agent session opens. It reads `git log` and source code. Understands what the code does *now*, but doesn't know the JWT migration was for compliance (might revert it), doesn't know the refresh token is intentionally incomplete, can't tell there's unfinished work. Asks: *"What would you like me to do?"*
35
+
36
+ **With `.intent/`** — new agent session opens. Runs `itt inspect`. Sees an active intent ("Migrate auth to JWT"), last snap ("Add refresh token — incomplete"), and rationale ("token rotation not done, security priority"). Says: *"I'll implement the token rotation next."*
37
+
38
+ The difference: 10 seconds of reading structured metadata vs. minutes of re-explaining context.
39
+
40
+ ## Core Loop
41
+
42
+ ```
43
+ start → snap → done
44
+ ```
45
+
46
+ - `start` — open an intent (what problem you're solving)
47
+ - `snap` — record a snap (what you did and why)
48
+ - `done` — close when complete
49
+
50
+ ## Example
51
+
52
+ ```bash
53
+ itt init
54
+ itt start "Fix login timeout"
55
+ itt snap "Increase timeout to 30s" -m "5s too short for slow networks"
56
+ git add . && git commit -m "fix timeout"
57
+ itt done
58
+ ```
59
+
60
+ ## Where This Is Going
61
+
62
+ `.intent/` is a protocol, not just a tool.
63
+
64
+ 1. **Agent memory** — agents read `.intent/` on startup, recover last session's context in seconds
65
+ 2. **Context exchange** — `.intent/` becomes the standard way to hand off work between agent platforms
66
+ 3. **Network effects** — when enough repos contain `.intent/`, new tooling emerges: intent-aware review, decision archaeology, semantic dashboards
67
+
68
+ ## Install
69
+
70
+ ```bash
71
+ pip install git-intent
72
+ ```
73
+
74
+ Or from source:
75
+
76
+ ```bash
77
+ git clone https://github.com/dozybot001/Intent.git && cd Intent
78
+ pip install -e .
79
+ ```
80
+
81
+ ## Commands
82
+
83
+ | Command | Purpose |
84
+ | --- | --- |
85
+ | `itt init` | Initialize `.intent/` in a Git repo |
86
+ | `itt start <title>` | Open an intent |
87
+ | `itt snap <title> [-m why]` | Record a snap |
88
+ | `itt done` | Close the active intent |
89
+ | `itt inspect` | Machine-readable workspace snapshot |
90
+ | `itt list <intent\|snap>` | List objects |
91
+ | `itt show <id>` | Show a single object |
92
+ | `itt adopt [id]` | Adopt a candidate snap |
93
+ | `itt revert` | Revert the latest snap |
94
+
95
+ ## Documentation
96
+
97
+ - [CLI spec](docs/cli.EN.md) — objects, commands, JSON output contract
98
+ - [Agent integration](docs/agent-integration.md) — copy-paste snippets for Claude Code, Cursor, AGENTS.md
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "git-intent"
7
+ version = "0.3.1"
8
+ description = "Semantic history for agent-driven development. Records what you did and why."
9
+ requires-python = ">=3.9"
10
+ readme = "README.md"
11
+ license = "MIT"
12
+ authors = [
13
+ { name = "Zeng Deyang" },
14
+ ]
15
+ keywords = ["agent", "git", "semantic-history", "intent", "developer-tools"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Topic :: Software Development :: Version Control :: Git",
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://github.com/dozybot001/Intent"
31
+ Repository = "https://github.com/dozybot001/Intent"
32
+
33
+ [project.scripts]
34
+ itt = "intent_cli.cli:main"
35
+
36
+ [tool.setuptools]
37
+ package-dir = {"" = "src"}
38
+
39
+ [tool.setuptools.packages.find]
40
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,122 @@
1
+ Metadata-Version: 2.4
2
+ Name: git-intent
3
+ Version: 0.3.1
4
+ Summary: Semantic history for agent-driven development. Records what you did and why.
5
+ Author: Zeng Deyang
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/dozybot001/Intent
8
+ Project-URL: Repository, https://github.com/dozybot001/Intent
9
+ Keywords: agent,git,semantic-history,intent,developer-tools
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Version Control :: Git
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+
25
+ English | [简体中文](README.CN.md)
26
+
27
+ # Intent
28
+
29
+ > Git records code changes. Intent records why.
30
+
31
+ ## The Problem
32
+
33
+ Agent-driven development produces code fast, but reasoning disappears between sessions. Every new session starts from zero — the agent doesn't know what problem was being solved, what was tried, or why a path was chosen.
34
+
35
+ ## What's Missing
36
+
37
+ Git records *what* changed. Commit messages and comments add some context. But three things consistently fall through:
38
+
39
+ **Goal continuity.** Commits are isolated snapshots. There's no structure connecting five commits to one task, or saying "this is what we're trying to accomplish."
40
+
41
+ **Decision rationale.** Why JWT over cookies? Why 15-minute expiry? This rarely makes it into commit messages — and when it does, it's unstructured text that agents must parse and guess from.
42
+
43
+ **Work state.** `git status` can be clean while a task is half-done. The next session has no signal that work was interrupted or what comes next.
44
+
45
+ ## The Solution
46
+
47
+ Intent adds a `.intent/` directory to your repository — structured, machine-readable metadata that captures semantic history alongside code history.
48
+
49
+ ```
50
+ .git/ ← how code changed
51
+ .intent/ ← what you were doing and why
52
+ ```
53
+
54
+ Two objects: **intent** (the goal) and **snap** (a step taken, with rationale). All JSON. Any agent platform can read it.
55
+
56
+ ### What changes
57
+
58
+ **Without `.intent/`** — new agent session opens. It reads `git log` and source code. Understands what the code does *now*, but doesn't know the JWT migration was for compliance (might revert it), doesn't know the refresh token is intentionally incomplete, can't tell there's unfinished work. Asks: *"What would you like me to do?"*
59
+
60
+ **With `.intent/`** — new agent session opens. Runs `itt inspect`. Sees an active intent ("Migrate auth to JWT"), last snap ("Add refresh token — incomplete"), and rationale ("token rotation not done, security priority"). Says: *"I'll implement the token rotation next."*
61
+
62
+ The difference: 10 seconds of reading structured metadata vs. minutes of re-explaining context.
63
+
64
+ ## Core Loop
65
+
66
+ ```
67
+ start → snap → done
68
+ ```
69
+
70
+ - `start` — open an intent (what problem you're solving)
71
+ - `snap` — record a snap (what you did and why)
72
+ - `done` — close when complete
73
+
74
+ ## Example
75
+
76
+ ```bash
77
+ itt init
78
+ itt start "Fix login timeout"
79
+ itt snap "Increase timeout to 30s" -m "5s too short for slow networks"
80
+ git add . && git commit -m "fix timeout"
81
+ itt done
82
+ ```
83
+
84
+ ## Where This Is Going
85
+
86
+ `.intent/` is a protocol, not just a tool.
87
+
88
+ 1. **Agent memory** — agents read `.intent/` on startup, recover last session's context in seconds
89
+ 2. **Context exchange** — `.intent/` becomes the standard way to hand off work between agent platforms
90
+ 3. **Network effects** — when enough repos contain `.intent/`, new tooling emerges: intent-aware review, decision archaeology, semantic dashboards
91
+
92
+ ## Install
93
+
94
+ ```bash
95
+ pip install git-intent
96
+ ```
97
+
98
+ Or from source:
99
+
100
+ ```bash
101
+ git clone https://github.com/dozybot001/Intent.git && cd Intent
102
+ pip install -e .
103
+ ```
104
+
105
+ ## Commands
106
+
107
+ | Command | Purpose |
108
+ | --- | --- |
109
+ | `itt init` | Initialize `.intent/` in a Git repo |
110
+ | `itt start <title>` | Open an intent |
111
+ | `itt snap <title> [-m why]` | Record a snap |
112
+ | `itt done` | Close the active intent |
113
+ | `itt inspect` | Machine-readable workspace snapshot |
114
+ | `itt list <intent\|snap>` | List objects |
115
+ | `itt show <id>` | Show a single object |
116
+ | `itt adopt [id]` | Adopt a candidate snap |
117
+ | `itt revert` | Revert the latest snap |
118
+
119
+ ## Documentation
120
+
121
+ - [CLI spec](docs/cli.EN.md) — objects, commands, JSON output contract
122
+ - [Agent integration](docs/agent-integration.md) — copy-paste snippets for Claude Code, Cursor, AGENTS.md
@@ -0,0 +1,18 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/git_intent.egg-info/PKG-INFO
5
+ src/git_intent.egg-info/SOURCES.txt
6
+ src/git_intent.egg-info/dependency_links.txt
7
+ src/git_intent.egg-info/entry_points.txt
8
+ src/git_intent.egg-info/top_level.txt
9
+ src/intent_cli/__init__.py
10
+ src/intent_cli/__main__.py
11
+ src/intent_cli/cli.py
12
+ src/intent_cli/constants.py
13
+ src/intent_cli/core.py
14
+ src/intent_cli/errors.py
15
+ src/intent_cli/git.py
16
+ src/intent_cli/helpers.py
17
+ src/intent_cli/store.py
18
+ tests/test_cli.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ itt = intent_cli.cli:main
@@ -0,0 +1 @@
1
+ intent_cli
@@ -0,0 +1,29 @@
1
+ """Intent CLI package."""
2
+
3
+ from importlib import metadata
4
+ from pathlib import Path
5
+ import re
6
+ from typing import Optional
7
+
8
+
9
+ PACKAGE_NAME = "git-intent"
10
+ REPO_ROOT = Path(__file__).resolve().parents[2]
11
+ PYPROJECT_PATH = REPO_ROOT / "pyproject.toml"
12
+ VERSION_PATTERN = re.compile(r'^version\s*=\s*"([^"]+)"\s*$', re.MULTILINE)
13
+
14
+
15
+ def version_from_checkout() -> Optional[str]:
16
+ if not PYPROJECT_PATH.exists():
17
+ return None
18
+ match = VERSION_PATTERN.search(PYPROJECT_PATH.read_text(encoding="utf-8"))
19
+ if not match:
20
+ return None
21
+ return match.group(1)
22
+
23
+
24
+ __version__ = version_from_checkout()
25
+ if __version__ is None:
26
+ try:
27
+ __version__ = metadata.version(PACKAGE_NAME)
28
+ except metadata.PackageNotFoundError:
29
+ __version__ = "0.3.1"
@@ -0,0 +1,5 @@
1
+ from .cli import main
2
+
3
+
4
+ if __name__ == "__main__":
5
+ raise SystemExit(main())
@@ -0,0 +1,146 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import json
5
+ from pathlib import Path
6
+ from typing import Any, Dict, Optional
7
+
8
+ from . import __version__
9
+ from .constants import EXIT_GENERAL_FAILURE, EXIT_SUCCESS
10
+ from .core import IntentRepository
11
+ from .errors import IntentError
12
+
13
+
14
+ def emit(payload: Dict[str, Any]) -> None:
15
+ print(json.dumps(payload, indent=2))
16
+
17
+
18
+ def ok(action: str, result: Any, **extra: Any) -> Dict[str, Any]:
19
+ payload: Dict[str, Any] = {"ok": True, "action": action, "result": result}
20
+ payload.update(extra)
21
+ return payload
22
+
23
+
24
+ def build_parser() -> argparse.ArgumentParser:
25
+ parser = argparse.ArgumentParser(
26
+ prog="itt",
27
+ description="Intent CLI — semantic history for agents.",
28
+ )
29
+ parser.add_argument("--version", action="version", version=f"intent-cli {__version__}")
30
+ sub = parser.add_subparsers(dest="command", required=True, title="commands")
31
+
32
+ sub.add_parser("version", help="Show version")
33
+
34
+ sub.add_parser("init", help="Initialize Intent in the current Git repository")
35
+
36
+ start_p = sub.add_parser("start", help="Create and activate an intent")
37
+ start_p.add_argument("title")
38
+
39
+ snap_p = sub.add_parser("snap", help="Record a snap (adopted by default)")
40
+ snap_p.add_argument("title")
41
+ snap_p.add_argument("-m", "--message", help="Rationale for this snap")
42
+ snap_p.add_argument("--candidate", action="store_true", help="Record as candidate without adopting")
43
+
44
+ adopt_p = sub.add_parser("adopt", help="Adopt a candidate snap")
45
+ adopt_p.add_argument("snap_id", nargs="?")
46
+ adopt_p.add_argument("-m", "--message", help="Rationale for adoption")
47
+
48
+ revert_p = sub.add_parser("revert", help="Revert the latest adopted snap")
49
+ revert_p.add_argument("-m", "--message", help="Rationale for revert")
50
+
51
+ done_p = sub.add_parser("done", help="Close the active intent")
52
+ done_p.add_argument("intent_id", nargs="?")
53
+
54
+ sub.add_parser("inspect", help="Machine-readable workspace snapshot")
55
+
56
+ list_p = sub.add_parser("list", help="List objects")
57
+ list_p.add_argument("type", choices=["intent", "snap"])
58
+
59
+ show_p = sub.add_parser("show", help="Show a single object by ID")
60
+ show_p.add_argument("id")
61
+
62
+ return parser
63
+
64
+
65
+ def main(argv: Optional[list[str]] = None) -> int:
66
+ parser = build_parser()
67
+ args = parser.parse_args(argv)
68
+ repo = IntentRepository(Path.cwd())
69
+
70
+ try:
71
+ if args.command == "version":
72
+ emit(ok("version", {"version": __version__}))
73
+ return EXIT_SUCCESS
74
+
75
+ if args.command == "init":
76
+ repo.ensure_git()
77
+ config, state = repo.init_workspace()
78
+ emit(ok("init", {"config": config, "state": state}))
79
+ return EXIT_SUCCESS
80
+
81
+ if args.command == "start":
82
+ intent, warnings = repo.create_intent(args.title)
83
+ emit(ok("start", intent, warnings=warnings))
84
+ return EXIT_SUCCESS
85
+
86
+ if args.command == "snap":
87
+ snap, warnings = repo.create_snap(
88
+ args.title,
89
+ rationale=args.message,
90
+ candidate=args.candidate,
91
+ )
92
+ emit(ok("snap", snap, warnings=warnings))
93
+ return EXIT_SUCCESS
94
+
95
+ if args.command == "adopt":
96
+ snap, warnings = repo.adopt_snap(
97
+ snap_id=args.snap_id,
98
+ rationale=args.message,
99
+ )
100
+ emit(ok("adopt", snap, warnings=warnings))
101
+ return EXIT_SUCCESS
102
+
103
+ if args.command == "revert":
104
+ snap, warnings = repo.revert_snap(rationale=args.message)
105
+ emit(ok("revert", snap, warnings=warnings))
106
+ return EXIT_SUCCESS
107
+
108
+ if args.command == "done":
109
+ intent, warnings = repo.close_intent(intent_id=args.intent_id)
110
+ emit(ok("done", intent, warnings=warnings))
111
+ return EXIT_SUCCESS
112
+
113
+ if args.command == "inspect":
114
+ emit(repo.inspect())
115
+ return EXIT_SUCCESS
116
+
117
+ if args.command == "list":
118
+ items = repo.list_objects(args.type)
119
+ emit(ok("list", items, count=len(items)))
120
+ return EXIT_SUCCESS
121
+
122
+ if args.command == "show":
123
+ obj = repo.show_object(args.id)
124
+ emit(ok("show", obj))
125
+ return EXIT_SUCCESS
126
+
127
+ parser.error("unknown command")
128
+ return 2
129
+
130
+ except IntentError as error:
131
+ emit(error.to_json())
132
+ return error.exit_code
133
+ except Exception as error:
134
+ emit({
135
+ "ok": False,
136
+ "error": {
137
+ "code": "INTERNAL_ERROR",
138
+ "message": str(error),
139
+ "details": {},
140
+ },
141
+ })
142
+ return EXIT_GENERAL_FAILURE
143
+
144
+
145
+ if __name__ == "__main__":
146
+ raise SystemExit(main())
@@ -0,0 +1,19 @@
1
+ from __future__ import annotations
2
+
3
+ SCHEMA_VERSION = "0.2"
4
+
5
+ EXIT_SUCCESS = 0
6
+ EXIT_GENERAL_FAILURE = 1
7
+ EXIT_INVALID_INPUT = 2
8
+ EXIT_STATE_CONFLICT = 3
9
+ EXIT_OBJECT_NOT_FOUND = 4
10
+
11
+ DIR_NAMES = {
12
+ "intent": "intents",
13
+ "snap": "snaps",
14
+ }
15
+
16
+ ID_PREFIXES = {
17
+ "intent": "intent",
18
+ "snap": "snap",
19
+ }