aiset-cli 0.1.0__tar.gz → 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.
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/PKG-INFO +31 -6
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/README.md +29 -4
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/pyproject.toml +2 -2
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/__init__.py +1 -1
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/archmap.py +5 -5
- aiset_cli-0.2.0/src/aiset/atomic.py +61 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/brain.py +19 -6
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/brief_index.py +1 -1
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/core.py +58 -8
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/init_team.py +109 -25
- aiset_cli-0.2.0/src/aiset/nudge.py +206 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/registry.py +8 -7
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/research.py +23 -24
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/server.py +90 -25
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/settings.py +16 -5
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/static/brain.html +13 -3
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/static/index.html +7 -7
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/sync_names.py +5 -6
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/teammap.py +155 -46
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/templates/engineer.md +1 -1
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/templates/integration-checker.md +1 -1
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/templates/tester.md +1 -1
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/workspace.py +28 -3
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset_cli.egg-info/PKG-INFO +31 -6
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset_cli.egg-info/SOURCES.txt +19 -1
- aiset_cli-0.2.0/tests/test_atomic.py +136 -0
- aiset_cli-0.2.0/tests/test_brain_graph_files.py +73 -0
- aiset_cli-0.2.0/tests/test_brain_live_link.py +25 -0
- aiset_cli-0.2.0/tests/test_core.py +91 -0
- aiset_cli-0.2.0/tests/test_encodings.py +80 -0
- aiset_cli-0.2.0/tests/test_init_team.py +129 -0
- aiset_cli-0.2.0/tests/test_nudge.py +154 -0
- aiset_cli-0.2.0/tests/test_repository_paths.py +134 -0
- aiset_cli-0.2.0/tests/test_security.py +280 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/tests/test_settings.py +15 -0
- aiset_cli-0.2.0/tests/test_single_repo.py +312 -0
- aiset_cli-0.2.0/tests/test_teammap_cli_inputs.py +87 -0
- aiset_cli-0.2.0/tests/test_teammap_lookup.py +259 -0
- aiset_cli-0.2.0/tests/test_teammap_route_frames.py +147 -0
- aiset_cli-0.2.0/tests/test_usage_cost.py +56 -0
- aiset_cli-0.2.0/tests/test_version.py +29 -0
- aiset_cli-0.2.0/tests/test_workspace_slug.py +98 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/LICENSE +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/setup.cfg +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/roster.json +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/static/aiset-icon.png +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/static/apple-touch-icon.png +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/static/architecture.html +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/static/favicon-16.png +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/static/favicon-32.png +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/static/favicon-48.png +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/static/favicon.ico +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/static/icon-192.png +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/static/icon-512.png +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/static/settings.html +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/static/site.webmanifest +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/teammap_ts.js +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset/templates/pm.md +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset_cli.egg-info/dependency_links.txt +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset_cli.egg-info/entry_points.txt +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/src/aiset_cli.egg-info/top_level.txt +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/tests/test_file_imports.py +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/tests/test_registry.py +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/tests/test_research.py +0 -0
- {aiset_cli-0.1.0 → aiset_cli-0.2.0}/tests/test_task_ids.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aiset-cli
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Turn your
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Turn your repos into a team of Claude Code agents with persistent memory, coordinated tasks, and a live dashboard.
|
|
5
5
|
Author: Jamshid Sadik
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/JamshidS/aiset
|
|
@@ -41,6 +41,8 @@ work in parallel, and show you every step, live.
|
|
|
41
41
|
|
|
42
42
|
<br>
|
|
43
43
|
|
|
44
|
+
[](https://pypi.org/project/aiset-cli/)
|
|
45
|
+
[](https://github.com/JamshidS/aiset/actions/workflows/ci.yml)
|
|
44
46
|
[](pyproject.toml)
|
|
45
47
|
[](pyproject.toml)
|
|
46
48
|
[](https://claude.com/claude-code)
|
|
@@ -73,7 +75,11 @@ Give the PM its first task:
|
|
|
73
75
|
|
|
74
76
|
> *"Build the knowledge briefs. Document the architecture, conventions, test commands and known pitfalls for each repository."*
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
> [!TIP]
|
|
79
|
+
> Agents working in parallel spend tokens in parallel. The office shows the cost per agent and task as it happens, and **Settings** lets you put routine roles on Sonnet or Haiku.
|
|
80
|
+
|
|
81
|
+
<sub>Needs Python 3.9+, Git and [Claude Code](https://claude.com/claude-code); TypeScript indexing also uses Node.js. Works with a folder of repositories or a monorepo; a single repository with its project at the root is one unit, and a root package that later gains service folders keeps its root engineer ([#36](https://github.com/JamshidS/aiset/issues/36)).</sub><br>
|
|
82
|
+
<sub>The PyPI package is `aiset-cli`; `aiset` on PyPI is an unrelated project.</sub>
|
|
77
83
|
|
|
78
84
|
<br>
|
|
79
85
|
|
|
@@ -155,7 +161,7 @@ Services, databases and the calls between them, each backed by a file and line.
|
|
|
155
161
|
|
|
156
162
|
| | |
|
|
157
163
|
|---|---|
|
|
158
|
-
| **Office** | Live isometric or classic view of the team: assignments, task boards, activity feed, models, tokens and estimated cost per agent. |
|
|
164
|
+
| **Office** | Live isometric or classic view of the team: assignments, task boards, activity feed, models, tokens and estimated cost per agent. Its footer uses the `<team>-pm` command when the launcher is available on `PATH`. |
|
|
159
165
|
| **Brain** | One graph of agents, briefs, sections, episodes, files, endpoints, models and API calls. Follow an agent, search anything, focus on a node. |
|
|
160
166
|
| **Architecture** | Static map of frontends, APIs, workers and infrastructure (PostgreSQL, MongoDB, Redis, RabbitMQ, Kafka, Keycloak and more), with evidence for every link. Exports Mermaid. |
|
|
161
167
|
| **Settings** | Names, roles, colours, duties and the **model per agent**: put routine work on Sonnet or Haiku, keep Opus where it matters. |
|
|
@@ -169,12 +175,15 @@ Services, databases and the calls between them, each backed by a file and line.
|
|
|
169
175
|
| Command | What it does |
|
|
170
176
|
|---|---|
|
|
171
177
|
| `aiset-init <folder> [--team NAME]` | Detect stacks, generate the roster, agents and brief stubs in `<folder>/.claude/`. Safe to re-run: keeps your names, adds new repos. |
|
|
172
|
-
| `<team>-pm` | Start the PM in its workspace from anywhere. Extra arguments go to Claude Code, e.g. `shop-pm --model sonnet`. |
|
|
178
|
+
| `<team>-pm` | Start the PM in its workspace from anywhere. The office footer suggests this command when its launcher is on `PATH`. Extra arguments go to Claude Code, e.g. `shop-pm --model sonnet`. |
|
|
173
179
|
| `aiset [--workspace FOLDER\|TEAM]` | Open the office. Without `--workspace`: the workspace you're in, else the team you set up most recently. |
|
|
174
180
|
| `teammap relevant "<task>"` | Files, symbols, endpoints, brief sections and past episodes to read first. |
|
|
175
181
|
| `teammap impact <path\|symbol\|Model> [METHOD]` | What a change can reach: consumers, models, importers, tests. Exact vs inferred. |
|
|
176
182
|
| `teammap failures <log>` | Failed tests, messages and in-repo frames from a saved test run, grouped. |
|
|
177
183
|
| `teammap endpoint` · `model` · `arch` · `symbol` | Direct lookups. `teammap --help` lists them all. |
|
|
184
|
+
| `aiset --version` · `aiset-init --version` · `teammap --version` | Print the installed version. Doesn't start the office or touch a workspace. |
|
|
185
|
+
|
|
186
|
+
`teammap --repo NAME` uses repository names from the active roster. Unknown names and missing or non-integer numeric option values produce a usage error (exit 2); see the [user guide](docs/USER-GUIDE.md#research-tools-teammap-impact-failures-relevant) for options.
|
|
178
187
|
|
|
179
188
|
<details>
|
|
180
189
|
<summary><b>Example: what does changing an endpoint break?</b></summary>
|
|
@@ -242,6 +251,14 @@ Everything is plain Markdown and JSON in your workspace. In a monorepo, `.claude
|
|
|
242
251
|
|
|
243
252
|
## FAQ
|
|
244
253
|
|
|
254
|
+
<details>
|
|
255
|
+
<summary><b>How is this different from Claude Code subagents?</b></summary>
|
|
256
|
+
<br>
|
|
257
|
+
|
|
258
|
+
aiset is built on them. `aiset-init` writes the subagent files for you, one per repo or stack, with each agent's repos, test commands and brief. On top it adds what subagents don't have on their own: a PM that plans and verifies, memory that carries over between tasks (briefs, field notes, episodes), `teammap` research tools, and a dashboard that shows what every agent is doing and what it costs.
|
|
259
|
+
|
|
260
|
+
</details>
|
|
261
|
+
|
|
245
262
|
<details>
|
|
246
263
|
<summary><b><code>aiset-init</code> is "not recognized" after installing</b></summary>
|
|
247
264
|
<br>
|
|
@@ -286,10 +303,18 @@ The office shows one workspace at a time and prints which one at startup. Run `a
|
|
|
286
303
|
|
|
287
304
|
## Contributing
|
|
288
305
|
|
|
289
|
-
Issues and pull requests are welcome.
|
|
306
|
+
Issues and pull requests are welcome. A good place to start is an issue labeled [**good first issue**](https://github.com/JamshidS/aiset/labels/good%20first%20issue): each one names the files to change and how to test it. To work on aiset itself, clone it, `pip install -e .`, and run `make check`. [CONTRIBUTING.md](CONTRIBUTING.md) has the full workflow; report vulnerabilities privately as described in [SECURITY.md](SECURITY.md).
|
|
290
307
|
|
|
291
308
|
More docs: [User guide](docs/USER-GUIDE.md) · [Feature inventory](docs/FEATURES.md) · [Research tools](docs/RESEARCH-TOOLS.md) · [Brand assets](docs/branding/preview.html)
|
|
292
309
|
|
|
310
|
+
### Contributors
|
|
311
|
+
|
|
312
|
+
Thanks to everyone who has helped build aiset.
|
|
313
|
+
|
|
314
|
+
<a href="https://github.com/JamshidS/aiset/graphs/contributors">
|
|
315
|
+
<img src="https://contrib.rocks/image?repo=JamshidS/aiset" alt="aiset contributors">
|
|
316
|
+
</a>
|
|
317
|
+
|
|
293
318
|
<br>
|
|
294
319
|
|
|
295
320
|
<div align="center">
|
|
@@ -11,6 +11,8 @@ work in parallel, and show you every step, live.
|
|
|
11
11
|
|
|
12
12
|
<br>
|
|
13
13
|
|
|
14
|
+
[](https://pypi.org/project/aiset-cli/)
|
|
15
|
+
[](https://github.com/JamshidS/aiset/actions/workflows/ci.yml)
|
|
14
16
|
[](pyproject.toml)
|
|
15
17
|
[](pyproject.toml)
|
|
16
18
|
[](https://claude.com/claude-code)
|
|
@@ -43,7 +45,11 @@ Give the PM its first task:
|
|
|
43
45
|
|
|
44
46
|
> *"Build the knowledge briefs. Document the architecture, conventions, test commands and known pitfalls for each repository."*
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
> [!TIP]
|
|
49
|
+
> Agents working in parallel spend tokens in parallel. The office shows the cost per agent and task as it happens, and **Settings** lets you put routine roles on Sonnet or Haiku.
|
|
50
|
+
|
|
51
|
+
<sub>Needs Python 3.9+, Git and [Claude Code](https://claude.com/claude-code); TypeScript indexing also uses Node.js. Works with a folder of repositories or a monorepo; a single repository with its project at the root is one unit, and a root package that later gains service folders keeps its root engineer ([#36](https://github.com/JamshidS/aiset/issues/36)).</sub><br>
|
|
52
|
+
<sub>The PyPI package is `aiset-cli`; `aiset` on PyPI is an unrelated project.</sub>
|
|
47
53
|
|
|
48
54
|
<br>
|
|
49
55
|
|
|
@@ -125,7 +131,7 @@ Services, databases and the calls between them, each backed by a file and line.
|
|
|
125
131
|
|
|
126
132
|
| | |
|
|
127
133
|
|---|---|
|
|
128
|
-
| **Office** | Live isometric or classic view of the team: assignments, task boards, activity feed, models, tokens and estimated cost per agent. |
|
|
134
|
+
| **Office** | Live isometric or classic view of the team: assignments, task boards, activity feed, models, tokens and estimated cost per agent. Its footer uses the `<team>-pm` command when the launcher is available on `PATH`. |
|
|
129
135
|
| **Brain** | One graph of agents, briefs, sections, episodes, files, endpoints, models and API calls. Follow an agent, search anything, focus on a node. |
|
|
130
136
|
| **Architecture** | Static map of frontends, APIs, workers and infrastructure (PostgreSQL, MongoDB, Redis, RabbitMQ, Kafka, Keycloak and more), with evidence for every link. Exports Mermaid. |
|
|
131
137
|
| **Settings** | Names, roles, colours, duties and the **model per agent**: put routine work on Sonnet or Haiku, keep Opus where it matters. |
|
|
@@ -139,12 +145,15 @@ Services, databases and the calls between them, each backed by a file and line.
|
|
|
139
145
|
| Command | What it does |
|
|
140
146
|
|---|---|
|
|
141
147
|
| `aiset-init <folder> [--team NAME]` | Detect stacks, generate the roster, agents and brief stubs in `<folder>/.claude/`. Safe to re-run: keeps your names, adds new repos. |
|
|
142
|
-
| `<team>-pm` | Start the PM in its workspace from anywhere. Extra arguments go to Claude Code, e.g. `shop-pm --model sonnet`. |
|
|
148
|
+
| `<team>-pm` | Start the PM in its workspace from anywhere. The office footer suggests this command when its launcher is on `PATH`. Extra arguments go to Claude Code, e.g. `shop-pm --model sonnet`. |
|
|
143
149
|
| `aiset [--workspace FOLDER\|TEAM]` | Open the office. Without `--workspace`: the workspace you're in, else the team you set up most recently. |
|
|
144
150
|
| `teammap relevant "<task>"` | Files, symbols, endpoints, brief sections and past episodes to read first. |
|
|
145
151
|
| `teammap impact <path\|symbol\|Model> [METHOD]` | What a change can reach: consumers, models, importers, tests. Exact vs inferred. |
|
|
146
152
|
| `teammap failures <log>` | Failed tests, messages and in-repo frames from a saved test run, grouped. |
|
|
147
153
|
| `teammap endpoint` · `model` · `arch` · `symbol` | Direct lookups. `teammap --help` lists them all. |
|
|
154
|
+
| `aiset --version` · `aiset-init --version` · `teammap --version` | Print the installed version. Doesn't start the office or touch a workspace. |
|
|
155
|
+
|
|
156
|
+
`teammap --repo NAME` uses repository names from the active roster. Unknown names and missing or non-integer numeric option values produce a usage error (exit 2); see the [user guide](docs/USER-GUIDE.md#research-tools-teammap-impact-failures-relevant) for options.
|
|
148
157
|
|
|
149
158
|
<details>
|
|
150
159
|
<summary><b>Example: what does changing an endpoint break?</b></summary>
|
|
@@ -212,6 +221,14 @@ Everything is plain Markdown and JSON in your workspace. In a monorepo, `.claude
|
|
|
212
221
|
|
|
213
222
|
## FAQ
|
|
214
223
|
|
|
224
|
+
<details>
|
|
225
|
+
<summary><b>How is this different from Claude Code subagents?</b></summary>
|
|
226
|
+
<br>
|
|
227
|
+
|
|
228
|
+
aiset is built on them. `aiset-init` writes the subagent files for you, one per repo or stack, with each agent's repos, test commands and brief. On top it adds what subagents don't have on their own: a PM that plans and verifies, memory that carries over between tasks (briefs, field notes, episodes), `teammap` research tools, and a dashboard that shows what every agent is doing and what it costs.
|
|
229
|
+
|
|
230
|
+
</details>
|
|
231
|
+
|
|
215
232
|
<details>
|
|
216
233
|
<summary><b><code>aiset-init</code> is "not recognized" after installing</b></summary>
|
|
217
234
|
<br>
|
|
@@ -256,10 +273,18 @@ The office shows one workspace at a time and prints which one at startup. Run `a
|
|
|
256
273
|
|
|
257
274
|
## Contributing
|
|
258
275
|
|
|
259
|
-
Issues and pull requests are welcome.
|
|
276
|
+
Issues and pull requests are welcome. A good place to start is an issue labeled [**good first issue**](https://github.com/JamshidS/aiset/labels/good%20first%20issue): each one names the files to change and how to test it. To work on aiset itself, clone it, `pip install -e .`, and run `make check`. [CONTRIBUTING.md](CONTRIBUTING.md) has the full workflow; report vulnerabilities privately as described in [SECURITY.md](SECURITY.md).
|
|
260
277
|
|
|
261
278
|
More docs: [User guide](docs/USER-GUIDE.md) · [Feature inventory](docs/FEATURES.md) · [Research tools](docs/RESEARCH-TOOLS.md) · [Brand assets](docs/branding/preview.html)
|
|
262
279
|
|
|
280
|
+
### Contributors
|
|
281
|
+
|
|
282
|
+
Thanks to everyone who has helped build aiset.
|
|
283
|
+
|
|
284
|
+
<a href="https://github.com/JamshidS/aiset/graphs/contributors">
|
|
285
|
+
<img src="https://contrib.rocks/image?repo=JamshidS/aiset" alt="aiset contributors">
|
|
286
|
+
</a>
|
|
287
|
+
|
|
263
288
|
<br>
|
|
264
289
|
|
|
265
290
|
<div align="center">
|
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "aiset-cli"
|
|
7
|
-
version = "0.
|
|
8
|
-
description = "Turn your
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Turn your repos into a team of Claude Code agents with persistent memory, coordinated tasks, and a live dashboard."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
11
11
|
license-files = ["LICENSE"]
|
|
@@ -235,7 +235,7 @@ def _deps(repo_path, files):
|
|
|
235
235
|
"""Python, npm and JVM dependency names, each with where it was declared."""
|
|
236
236
|
py, npm, jvm = {}, {}, {}
|
|
237
237
|
for path, f in files:
|
|
238
|
-
rel = os.path.relpath(path, repo_path)
|
|
238
|
+
rel = os.path.relpath(path, repo_path).replace(os.sep, "/")
|
|
239
239
|
if re.match(r"requirements.*\.txt$", f):
|
|
240
240
|
for i, line in enumerate(_read(path).splitlines(), 1):
|
|
241
241
|
m = re.match(r"\s*([A-Za-z0-9_.\-\[\]]+)", line)
|
|
@@ -321,7 +321,7 @@ def scan_repo(name):
|
|
|
321
321
|
detectors = [(d, [re.compile(p, re.M) for p in d["code"]]) for d in DETECTORS]
|
|
322
322
|
has_dags = False
|
|
323
323
|
for full, f in files:
|
|
324
|
-
rel = os.path.relpath(full, path)
|
|
324
|
+
rel = os.path.relpath(full, path).replace(os.sep, "/")
|
|
325
325
|
ext = os.path.splitext(f)[1].lower()
|
|
326
326
|
if f.startswith(".env") and not f.endswith((".example", ".sample")) or "/secrets/" in "/" + rel:
|
|
327
327
|
continue
|
|
@@ -676,7 +676,7 @@ def fingerprint():
|
|
|
676
676
|
try:
|
|
677
677
|
h.update(str(os.path.getmtime(os.path.join(HERE, mod))).encode())
|
|
678
678
|
except OSError:
|
|
679
|
-
pass
|
|
679
|
+
pass # an installed package may not ship the module; its absence is part of the fingerprint
|
|
680
680
|
for name in repo_dirs():
|
|
681
681
|
for full, _ in _walk(os.path.join(CODE_ROOT, name)):
|
|
682
682
|
try:
|
|
@@ -697,7 +697,7 @@ def cached(force=False):
|
|
|
697
697
|
if data.get("fingerprint") == fp:
|
|
698
698
|
return data
|
|
699
699
|
except (OSError, ValueError):
|
|
700
|
-
pass
|
|
700
|
+
pass # no usable cache: build the map again
|
|
701
701
|
data = build()
|
|
702
702
|
data["fingerprint"] = fp
|
|
703
703
|
try:
|
|
@@ -705,7 +705,7 @@ def cached(force=False):
|
|
|
705
705
|
with open(CACHE_FILE, "w", encoding="utf-8") as f:
|
|
706
706
|
json.dump(data, f)
|
|
707
707
|
except OSError:
|
|
708
|
-
pass
|
|
708
|
+
pass # a read-only workspace still gets the map, just without the cache
|
|
709
709
|
return data
|
|
710
710
|
|
|
711
711
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Small helpers for replacing text files without exposing partial writes."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import secrets
|
|
5
|
+
import stat
|
|
6
|
+
import time
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _open_temporary(directory):
|
|
10
|
+
flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL | getattr(os, "O_BINARY", 0)
|
|
11
|
+
for _ in range(10):
|
|
12
|
+
temporary = os.path.join(directory, f".aiset-{secrets.token_hex(16)}.tmp")
|
|
13
|
+
try:
|
|
14
|
+
return os.open(temporary, flags, 0o666), temporary
|
|
15
|
+
except FileExistsError:
|
|
16
|
+
continue
|
|
17
|
+
raise FileExistsError(f"could not create a unique temporary file in {directory!r}")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _replace_with_retry(temporary, target):
|
|
21
|
+
for attempt in range(4):
|
|
22
|
+
try:
|
|
23
|
+
os.replace(temporary, target)
|
|
24
|
+
return
|
|
25
|
+
except PermissionError:
|
|
26
|
+
if os.name != "nt" or attempt == 3:
|
|
27
|
+
raise
|
|
28
|
+
time.sleep(0.05)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def write_text_atomic(path, text, *, encoding="utf-8", errors="strict", newline=None):
|
|
32
|
+
"""Write text beside its destination, then atomically replace the destination.
|
|
33
|
+
|
|
34
|
+
The temporary file is removed if writing or replacement fails. Existing POSIX
|
|
35
|
+
permission bits are retained; new files use mode 0666 filtered by the active umask.
|
|
36
|
+
"""
|
|
37
|
+
target = os.path.realpath(os.fspath(path))
|
|
38
|
+
directory = os.path.dirname(target)
|
|
39
|
+
try:
|
|
40
|
+
existing_mode = stat.S_IMODE(os.stat(target).st_mode)
|
|
41
|
+
except FileNotFoundError:
|
|
42
|
+
existing_mode = None
|
|
43
|
+
|
|
44
|
+
fd, temporary = _open_temporary(directory)
|
|
45
|
+
try:
|
|
46
|
+
stream = os.fdopen(fd, "w", encoding=encoding, errors=errors, newline=newline)
|
|
47
|
+
fd = None
|
|
48
|
+
with stream as f:
|
|
49
|
+
f.write(text)
|
|
50
|
+
if existing_mode is not None and os.name != "nt":
|
|
51
|
+
os.chmod(temporary, existing_mode)
|
|
52
|
+
_replace_with_retry(temporary, target)
|
|
53
|
+
temporary = None
|
|
54
|
+
finally:
|
|
55
|
+
if fd is not None:
|
|
56
|
+
os.close(fd)
|
|
57
|
+
if temporary is not None:
|
|
58
|
+
try:
|
|
59
|
+
os.unlink(temporary)
|
|
60
|
+
except FileNotFoundError:
|
|
61
|
+
pass
|
|
@@ -20,10 +20,23 @@ from .workspace import CODE_ROOT, EPISODES, GRAPHS, KNOWLEDGE, norm, relative, r
|
|
|
20
20
|
EPISODE_FIELDS = ("TASK", "DATE", "AGENTS", "OUTCOME", "TOUCHED", "CONTRACT", "DECISIONS", "GOTCHAS", "COST")
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
def _json_files(directory):
|
|
24
|
+
"""Sorted JSON files, including hidden names produced by the root unit."""
|
|
25
|
+
try:
|
|
26
|
+
with os.scandir(directory) as entries:
|
|
27
|
+
return sorted(
|
|
28
|
+
entry.path
|
|
29
|
+
for entry in entries
|
|
30
|
+
if entry.name.endswith(".json") and entry.is_file()
|
|
31
|
+
)
|
|
32
|
+
except OSError:
|
|
33
|
+
return []
|
|
34
|
+
|
|
35
|
+
|
|
23
36
|
def brief_sections(filename):
|
|
24
37
|
"""[(level, title, first line, text)] for the ## and ### headings of a brief."""
|
|
25
38
|
try:
|
|
26
|
-
with open(os.path.join(KNOWLEDGE, filename), encoding="utf-8") as f:
|
|
39
|
+
with open(os.path.join(KNOWLEDGE, filename), encoding="utf-8", errors="replace") as f:
|
|
27
40
|
lines = f.read().splitlines()
|
|
28
41
|
except OSError:
|
|
29
42
|
return []
|
|
@@ -43,7 +56,7 @@ def read_episodes():
|
|
|
43
56
|
if os.path.basename(path) == "index.md":
|
|
44
57
|
continue
|
|
45
58
|
try:
|
|
46
|
-
with open(path, encoding="utf-8") as f:
|
|
59
|
+
with open(path, encoding="utf-8", errors="replace") as f:
|
|
47
60
|
text = f.read()
|
|
48
61
|
except OSError:
|
|
49
62
|
continue
|
|
@@ -181,7 +194,7 @@ def build(office, roster):
|
|
|
181
194
|
|
|
182
195
|
# -- external code graphs ---------------------------------------------------------
|
|
183
196
|
tree_code = []
|
|
184
|
-
for path in
|
|
197
|
+
for path in _json_files(GRAPHS):
|
|
185
198
|
try:
|
|
186
199
|
with open(path, encoding="utf-8") as f:
|
|
187
200
|
g = json.load(f)
|
|
@@ -279,7 +292,7 @@ def _cached(key, stamp, make):
|
|
|
279
292
|
|
|
280
293
|
def _graph_nodes():
|
|
281
294
|
"""Endpoint/model/file nodes from the code graphs, for resolving teammap queries."""
|
|
282
|
-
files =
|
|
295
|
+
files = _json_files(GRAPHS)
|
|
283
296
|
stamp = tuple(os.path.getmtime(f) for f in files)
|
|
284
297
|
|
|
285
298
|
def make():
|
|
@@ -291,14 +304,14 @@ def _graph_nodes():
|
|
|
291
304
|
if n.get("type") in out:
|
|
292
305
|
out[n["type"]].append(n)
|
|
293
306
|
except (OSError, ValueError):
|
|
294
|
-
pass
|
|
307
|
+
pass # a graph file being rewritten or invalid: skip it this round
|
|
295
308
|
return out
|
|
296
309
|
return _cached("graph", stamp, make)
|
|
297
310
|
|
|
298
311
|
|
|
299
312
|
def _symbol_files():
|
|
300
313
|
"""symbol name -> [(repo, rel)] from teammap's index, refreshed when the index changes."""
|
|
301
|
-
files =
|
|
314
|
+
files = _json_files(os.path.join(GRAPHS, "index"))
|
|
302
315
|
stamp = tuple(os.path.getmtime(f) for f in files)
|
|
303
316
|
|
|
304
317
|
def make():
|
|
@@ -26,7 +26,7 @@ def index_path(brief):
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
def build(brief):
|
|
29
|
-
with open(brief, encoding="utf-8") as f:
|
|
29
|
+
with open(brief, encoding="utf-8", errors="replace") as f:
|
|
30
30
|
lines = f.read().splitlines()
|
|
31
31
|
heads = [(i + 1, len(m.group(1)), m.group(2).strip())
|
|
32
32
|
for i, l in enumerate(lines) if (m := re.match(r"^(##|###) (.+)", l))]
|
|
@@ -80,18 +80,27 @@ PRICES = {
|
|
|
80
80
|
"claude-opus-5-5": (4, 20, 0.20, 5, 8), "claude-opus-5": (5, 25, 0.50, 6.25, 10),
|
|
81
81
|
"claude-sonnet-5-5": (2, 10, 0.20, 2.5, 4), "claude-sonnet-5": (2, 10, 0.20, 2.5, 4),
|
|
82
82
|
"claude-haiku-5-5": (0.10, 0.50, 0.01, 0.125, 0.20),
|
|
83
|
+
# older models still in use (pinned in Settings, or inside the Brain window)
|
|
84
|
+
"claude-opus-4-8": (5, 25, 0.50, 6.25, 10), "claude-opus-4-7": (5, 25, 0.50, 6.25, 10),
|
|
85
|
+
"claude-opus-4-6": (5, 25, 0.50, 6.25, 10), "claude-sonnet-4-6": (3, 15, 0.30, 3.75, 6),
|
|
86
|
+
"claude-haiku-4-5": (1, 5, 0.10, 1.25, 2),
|
|
83
87
|
}
|
|
84
88
|
FAMILY_PRICES = {"fable": PRICES["claude-fable-5-1"], "opus": PRICES["claude-opus-5-5"],
|
|
85
89
|
"sonnet": PRICES["claude-sonnet-5-5"], "haiku": PRICES["claude-haiku-5-5"]}
|
|
90
|
+
# A prompt (input plus cache tokens) over the limit is billed at these rates instead.
|
|
91
|
+
LONG_PROMPT_PRICES = {"claude-haiku-5-5": (100_000, (0.50, 2.50, 0.05, 0.625, 1))}
|
|
86
92
|
|
|
87
93
|
|
|
88
94
|
def usage_cost(model, u):
|
|
89
95
|
"""Dollar cost of one API message's usage block."""
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
key = next((k for k in sorted(PRICES, key=len, reverse=True) if (model or "").startswith(k)), None)
|
|
97
|
+
p = PRICES.get(key) or FAMILY_PRICES.get(model_family(model))
|
|
92
98
|
if not p:
|
|
93
99
|
return 0.0
|
|
94
100
|
write = u.get("cache_creation_input_tokens") or 0
|
|
101
|
+
long_prompt = LONG_PROMPT_PRICES.get(key)
|
|
102
|
+
if long_prompt and (u.get("input_tokens") or 0) + (u.get("cache_read_input_tokens") or 0) + write > long_prompt[0]:
|
|
103
|
+
p = long_prompt[1]
|
|
95
104
|
split = u.get("cache_creation") or {}
|
|
96
105
|
w1h = split.get("ephemeral_1h_input_tokens") or 0
|
|
97
106
|
w5m = split.get("ephemeral_5m_input_tokens", write - w1h) or 0
|
|
@@ -121,16 +130,34 @@ def _legacy_id(tid):
|
|
|
121
130
|
return re.sub(r"^(\d{4})-(\d\d)-(\d\d)-", r"\1\2\3-", tid)
|
|
122
131
|
|
|
123
132
|
|
|
133
|
+
TASK_NAME = re.compile(r"[A-Za-z0-9][A-Za-z0-9._-]*")
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def _inside(base, name, suffix=""):
|
|
137
|
+
"""base/name+suffix when name is a plain task name; else None.
|
|
138
|
+
|
|
139
|
+
Task ids arrive in HTTP requests. A plain name (no separators, no leading dot) can't leave base; the normpath
|
|
140
|
+
check states that without resolving symlinks, so a task folder that is a symlink still works.
|
|
141
|
+
"""
|
|
142
|
+
if not TASK_NAME.fullmatch(name):
|
|
143
|
+
return None
|
|
144
|
+
root = os.path.normpath(base)
|
|
145
|
+
path = os.path.normpath(os.path.join(root, name + suffix))
|
|
146
|
+
return path if path.startswith(root + os.sep) else None
|
|
147
|
+
|
|
148
|
+
|
|
124
149
|
def _board_dir(tid):
|
|
125
150
|
"""Board folder of a task, under either date format; None if there is none."""
|
|
126
151
|
tid = task_id(os.path.basename(tid))
|
|
127
|
-
|
|
152
|
+
dirs = (_inside(BOARDS, n) for n in (tid, _legacy_id(tid)))
|
|
153
|
+
return next((d for d in dirs if d and os.path.isdir(d)), None)
|
|
128
154
|
|
|
129
155
|
|
|
130
156
|
def _episode_path(tid):
|
|
157
|
+
"""Episode file of a task, under either date format; None for a name that isn't a task id."""
|
|
131
158
|
tid = task_id(os.path.basename(tid))
|
|
132
|
-
|
|
133
|
-
|
|
159
|
+
paths = [p for p in (_inside(EPISODES, n, ".md") for n in (tid, _legacy_id(tid))) if p]
|
|
160
|
+
return next((p for p in paths if os.path.exists(p)), paths[0] if paths else None)
|
|
134
161
|
|
|
135
162
|
|
|
136
163
|
def expand_vars(cmd):
|
|
@@ -428,12 +455,31 @@ def project_name(dirname):
|
|
|
428
455
|
return name
|
|
429
456
|
|
|
430
457
|
|
|
458
|
+
def workspace_project(dirname):
|
|
459
|
+
"""True when a ~/.claude/projects folder holds this workspace's own sessions.
|
|
460
|
+
|
|
461
|
+
Claude Code names the folder after the workspace path, and folders inside
|
|
462
|
+
the workspace get ``<workspace slug>-<path inside it>``. Matching on the
|
|
463
|
+
bare prefix therefore lets siblings through: with workspace
|
|
464
|
+
``C:\\work\\app``, the folder for ``C:\\work\\apples`` also starts with
|
|
465
|
+
``c--work-app``, so its sessions, tokens and cost landed on the floor too.
|
|
466
|
+
Requiring an exact match or a ``-`` boundary keeps them out.
|
|
467
|
+
|
|
468
|
+
``app`` and ``app-old`` still share a prefix; telling those apart needs the
|
|
469
|
+
``cwd`` recorded in the transcript, which this filter doesn't read.
|
|
470
|
+
"""
|
|
471
|
+
folder = str(dirname or "").lower()
|
|
472
|
+
if not WS_SLUG:
|
|
473
|
+
return True
|
|
474
|
+
return folder == WS_SLUG or folder.startswith(WS_SLUG + "-")
|
|
475
|
+
|
|
476
|
+
|
|
431
477
|
def knowledge_info(filename):
|
|
432
478
|
if not filename:
|
|
433
479
|
return None
|
|
434
480
|
path = os.path.join(KNOWLEDGE, filename)
|
|
435
481
|
try:
|
|
436
|
-
with open(path, encoding="utf-8") as f:
|
|
482
|
+
with open(path, encoding="utf-8", errors="replace") as f:
|
|
437
483
|
text = f.read()
|
|
438
484
|
except OSError:
|
|
439
485
|
return {"file": path, "exists": False}
|
|
@@ -449,8 +495,10 @@ def knowledge_info(filename):
|
|
|
449
495
|
|
|
450
496
|
|
|
451
497
|
def _read(path, limit=20000):
|
|
498
|
+
if not path:
|
|
499
|
+
return None
|
|
452
500
|
try:
|
|
453
|
-
with open(path, encoding="utf-8") as f:
|
|
501
|
+
with open(path, encoding="utf-8", errors="replace") as f:
|
|
454
502
|
return f.read(limit)
|
|
455
503
|
except OSError:
|
|
456
504
|
return None
|
|
@@ -540,6 +588,8 @@ def task_detail(office, tid):
|
|
|
540
588
|
meta = current_meta(office, tid, time.time())
|
|
541
589
|
else:
|
|
542
590
|
tid = task_id(os.path.basename(tid))
|
|
591
|
+
if not TASK_NAME.fullmatch(tid):
|
|
592
|
+
return None
|
|
543
593
|
meta = task_meta(tid)
|
|
544
594
|
return {**meta, "board": board_detail(tid) if meta["hasBoard"] else None,
|
|
545
595
|
"episode": _read(_episode_path(tid)) if meta["hasEpisode"] else None,
|
|
@@ -819,7 +869,7 @@ class Office:
|
|
|
819
869
|
continue
|
|
820
870
|
if now - max([mtime] + [m for _, m in subs]) > self.window:
|
|
821
871
|
continue
|
|
822
|
-
if
|
|
872
|
+
if not workspace_project(os.path.basename(os.path.dirname(path))):
|
|
823
873
|
continue
|
|
824
874
|
project = project_name(os.path.basename(os.path.dirname(path)))
|
|
825
875
|
lead = self._get(path, "main", project)
|