aperta-cli 1.0.0-beta.1

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.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +386 -0
  3. package/bin/aperta.js +3 -0
  4. package/dashboard/dist/assets/index-CWL1aA6j.js +11 -0
  5. package/dashboard/dist/assets/index-D0Ru46BW.css +1 -0
  6. package/dashboard/dist/index.html +15 -0
  7. package/dist-cli/src/adapters/git-only.js +7 -0
  8. package/dist-cli/src/adapters/git-only.js.map +1 -0
  9. package/dist-cli/src/adapters/opencode.js +47 -0
  10. package/dist-cli/src/adapters/opencode.js.map +1 -0
  11. package/dist-cli/src/agent-harness.js +1292 -0
  12. package/dist-cli/src/agent-harness.js.map +1 -0
  13. package/dist-cli/src/capture.js +17 -0
  14. package/dist-cli/src/capture.js.map +1 -0
  15. package/dist-cli/src/cli.js +283 -0
  16. package/dist-cli/src/cli.js.map +1 -0
  17. package/dist-cli/src/coach.js +315 -0
  18. package/dist-cli/src/coach.js.map +1 -0
  19. package/dist-cli/src/dashboard-data.js +254 -0
  20. package/dist-cli/src/dashboard-data.js.map +1 -0
  21. package/dist-cli/src/dashboard-server.js +379 -0
  22. package/dist-cli/src/dashboard-server.js.map +1 -0
  23. package/dist-cli/src/engine.js +85 -0
  24. package/dist-cli/src/engine.js.map +1 -0
  25. package/dist-cli/src/execution.js +20 -0
  26. package/dist-cli/src/execution.js.map +1 -0
  27. package/dist-cli/src/git.js +131 -0
  28. package/dist-cli/src/git.js.map +1 -0
  29. package/dist-cli/src/harness-intelligence.js +110 -0
  30. package/dist-cli/src/harness-intelligence.js.map +1 -0
  31. package/dist-cli/src/hook.js +39 -0
  32. package/dist-cli/src/hook.js.map +1 -0
  33. package/dist-cli/src/impact.js +224 -0
  34. package/dist-cli/src/impact.js.map +1 -0
  35. package/dist-cli/src/jobs.js +27 -0
  36. package/dist-cli/src/jobs.js.map +1 -0
  37. package/dist-cli/src/ledger.js +211 -0
  38. package/dist-cli/src/ledger.js.map +1 -0
  39. package/dist-cli/src/map.js +73 -0
  40. package/dist-cli/src/map.js.map +1 -0
  41. package/dist-cli/src/observer.js +127 -0
  42. package/dist-cli/src/observer.js.map +1 -0
  43. package/dist-cli/src/probes.js +195 -0
  44. package/dist-cli/src/probes.js.map +1 -0
  45. package/dist-cli/src/prompt.js +44 -0
  46. package/dist-cli/src/prompt.js.map +1 -0
  47. package/dist-cli/src/proof-graph.js +123 -0
  48. package/dist-cli/src/proof-graph.js.map +1 -0
  49. package/dist-cli/src/proof.js +99 -0
  50. package/dist-cli/src/proof.js.map +1 -0
  51. package/dist-cli/src/registry.js +60 -0
  52. package/dist-cli/src/registry.js.map +1 -0
  53. package/dist-cli/src/repository.js +39 -0
  54. package/dist-cli/src/repository.js.map +1 -0
  55. package/dist-cli/src/semantic.js +183 -0
  56. package/dist-cli/src/semantic.js.map +1 -0
  57. package/dist-cli/src/service.js +60 -0
  58. package/dist-cli/src/service.js.map +1 -0
  59. package/dist-cli/src/session.js +41 -0
  60. package/dist-cli/src/session.js.map +1 -0
  61. package/dist-cli/src/settings.js +305 -0
  62. package/dist-cli/src/settings.js.map +1 -0
  63. package/dist-cli/src/skills.js +104 -0
  64. package/dist-cli/src/skills.js.map +1 -0
  65. package/dist-cli/src/storage.js +163 -0
  66. package/dist-cli/src/storage.js.map +1 -0
  67. package/dist-cli/src/types.js +2 -0
  68. package/dist-cli/src/types.js.map +1 -0
  69. package/package.json +56 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vequan Clark
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.
package/README.md ADDED
@@ -0,0 +1,386 @@
1
+ # Aperta
2
+
3
+ **Your code works. Could you explain why?**
4
+
5
+ AI coding agents make it easy to ship code you cannot explain. Aperta measures
6
+ that comprehension gap before it becomes a debugging, maintenance, or ownership
7
+ problem. It records what changed, asks for a quick self-rating, and shows where
8
+ the codebase has outrun your understanding. It records explanations but does not
9
+ grade them.
10
+
11
+ The current 1.0 beta combines a provider-neutral coding-agent harness with a
12
+ local comprehension system. It observes changes from any editor or agent,
13
+ executes bounded work in disposable Git worktrees, verifies outcomes, and turns
14
+ the resulting evidence into review sessions, a learning journal, and a durable
15
+ Proof Graph.
16
+
17
+ The local Vue dashboard includes:
18
+
19
+ - Agent Workbench with persistent multi-turn conversations
20
+ - Aperta Native, Cursor Agent, Claude Code, and OpenCode execution runtimes
21
+ - OpenAI, Anthropic, Google Gemini, DeepSeek, Ollama, OpenRouter, Groq, and
22
+ OpenAI-compatible model profiles
23
+ - staged, unstaged, and untracked Git views
24
+ - syntax-highlighted source, diffs, agent responses, and execution output
25
+ - repository, impact, and behavioral Proof Graphs
26
+ - guided ownership sessions, Review Queue, Learn Next, and Learning Journal
27
+ - local harness reliability, verification, repair, and trusted-keep metrics
28
+
29
+ Repository evidence stays in private per-user storage unless the user explicitly
30
+ invokes a configured model. Credentials never enter project memory.
31
+
32
+ ## How the harness is divided
33
+
34
+ Aperta deliberately separates three responsibilities:
35
+
36
+ - **Model APIs reason.** A configured model can plan, explain, and choose from
37
+ Aperta's bounded tools.
38
+ - **Agent runtimes execute.** Aperta Native, Cursor Agent, Claude Code, or
39
+ OpenCode can inspect and edit an isolated workspace. External runtimes keep
40
+ their own authentication and model configuration.
41
+ - **Aperta owns trust.** Aperta selects the skill contract, constrains
42
+ capabilities, captures actions, runs deterministic checks and localhost
43
+ probes, controls promotion, and records proof and learning evidence.
44
+
45
+ Changing the runtime or model never gives it authority to declare its own work
46
+ correct or understood.
47
+
48
+ ## Aperta Coach (optional AI)
49
+
50
+ Aperta Coach turns the deterministic ownership brief into an adaptive change
51
+ debrief. It can orient the maintainer and personalize trace, failure-mode,
52
+ evidence, and debugging questions. Model output remains visibly AI-generated:
53
+ it cannot change Trust Kernel relationships, mark runtime evidence as proven,
54
+ grade prose, or award ownership. Returned file citations are accepted only when
55
+ they match files in the captured change.
56
+
57
+ Coach is provider-neutral and configured through environment variables so API
58
+ keys never enter the project config or ledger. It supports native OpenAI,
59
+ Anthropic, Google Gemini, DeepSeek, and Ollama APIs; OpenRouter and Groq
60
+ gateways; and any OpenAI-compatible HTTPS or local endpoint, including LM
61
+ Studio.
62
+
63
+ ```sh
64
+ # OpenAI (OPENAI_API_KEY is read automatically)
65
+ export OPENAI_API_KEY="..."
66
+
67
+ # Anthropic
68
+ export APERTA_AI_PROVIDER="anthropic"
69
+ export ANTHROPIC_API_KEY="..."
70
+ export APERTA_AI_MODEL="your-model-id"
71
+
72
+ # Google Gemini
73
+ export APERTA_AI_PROVIDER="google"
74
+ export GOOGLE_API_KEY="..."
75
+ export APERTA_AI_MODEL="your-model-id"
76
+
77
+ # DeepSeek
78
+ export APERTA_AI_PROVIDER="deepseek"
79
+ export DEEPSEEK_API_KEY="..."
80
+ export APERTA_AI_MODEL="your-model-id"
81
+
82
+ # OpenRouter or Groq
83
+ export APERTA_AI_PROVIDER="openrouter" # or groq
84
+ export OPENROUTER_API_KEY="..." # or GROQ_API_KEY
85
+ export APERTA_AI_MODEL="provider/model-id"
86
+
87
+ # Local Ollama — no API key required
88
+ export APERTA_AI_PROVIDER="ollama"
89
+ export APERTA_AI_MODEL="qwen2.5-coder"
90
+
91
+ # Any OpenAI-compatible provider
92
+ export APERTA_AI_PROVIDER="openai-compatible"
93
+ export APERTA_AI_BASE_URL="https://provider.example/v1"
94
+ export APERTA_AI_MODEL="provider/model-id"
95
+ export APERTA_AI_API_KEY="..."
96
+
97
+ aperta dashboard
98
+ ```
99
+
100
+ `APERTA_AI_MODEL` overrides every provider default. Remote custom endpoints
101
+ must use HTTPS; plaintext HTTP is accepted only for loopback model servers.
102
+ The evidence bundle is sent to the configured provider only when the user
103
+ explicitly clicks **Personalize this debrief**.
104
+
105
+ The dashboard also provides **Model Settings** for reusable provider profiles.
106
+ Profile metadata is stored globally in `~/.aperta/settings.json`, never in a
107
+ repository. On macOS, supplied API keys are stored in Keychain and never
108
+ returned to the browser; environment variables remain supported for automated
109
+ and cross-platform use.
110
+
111
+ ## Repository comprehension explorer
112
+
113
+ The Repository Map is a navigable tree of Git-visible tracked and untracked
114
+ files. Ignored files—including ignored `.env` files—are excluded at the server
115
+ boundary. Selecting a file opens a bounded, syntax-highlighted read-only source
116
+ view with its confidence, authorship ratio, captured churn, and ownership
117
+ history. Binary files are identified without rendering their contents, and
118
+ text previews are limited to 1 MB.
119
+
120
+ ## Agent Workbench
121
+
122
+ The Agent Workbench is Aperta's controlled action plane. An active model profile
123
+ can run a bounded implementation loop inside a disposable Git worktree using
124
+ repository list, read, search, and write tools plus allowlisted project checks,
125
+ detected local-service startup, and localhost HTTP probes. The agent has no
126
+ arbitrary shell or remote-network tool and cannot access ignored files,
127
+ credential-bearing files, `.git`, or `.comprehension`. Existing files must be
128
+ read before they can be rewritten; runs are capped at 48 implementation
129
+ actions, 20 writes, 300 KB per file, and 1 MB of total writes.
130
+
131
+ Alternatively, Aperta can delegate the isolated execution loop to an installed
132
+ Cursor Agent, Claude Code, or OpenCode CLI. Aperta still owns the disposable
133
+ workspace, exact changed-file capture, verification loop, action record, and
134
+ promotion gate. Read-only requests discard unexpected runtime mutations.
135
+
136
+ Completed runs produce a retained local action record and a syntax-highlighted
137
+ patch. Aperta detects allowlisted project checks for Maven, Gradle, Node package
138
+ scripts, Python, Go, and Cargo, runs them inside the disposable worktree, and
139
+ gives the agent up to three bounded attempts to repair failures. Changes,
140
+ verification output, and live activity have separate review surfaces, and a
141
+ run with failing checks cannot be promoted. Analysis-only runs use a dedicated
142
+ readable response view instead of pretending an empty patch exists.
143
+
144
+ The source repository remains unchanged until the maintainer checks the
145
+ promotion acknowledgement and explicitly applies the patch. Before promotion,
146
+ Aperta compares the real repository tree with the run's starting tree and
147
+ refuses to apply over newer work. A promoted patch then enters the normal Git
148
+ observer, proof, ownership-session, journal, and recall workflow.
149
+
150
+ Every run also carries a durable execution contract: goal, ordered plan,
151
+ constraints, risks, acceptance criteria, evidence status, deterministic
152
+ critique, and promotion decision. Aperta records the pre-change project baseline
153
+ separately from post-change checks, so a green result cannot hide a repository
154
+ that was already failing. Passing generic checks proves project health; it does
155
+ not by itself prove the user's requested behavior.
156
+
157
+ ## Skill Contracts
158
+
159
+ Every run receives a deterministic, provider-neutral Skill Contract before a
160
+ model or external runtime acts. The current built-in contracts cover debugging,
161
+ project verification, runtime observation, implementation, code explanation,
162
+ and repository exploration. Each contract declares:
163
+
164
+ - the capabilities the runtime may use
165
+ - ordered execution phases
166
+ - required proof before completion
167
+ - learning objectives that feed the understanding loop
168
+
169
+ Models may refine a plan, but they cannot remove the skill's required proof or
170
+ expand its tool authority. The selected skill is visible in the Workbench and
171
+ stored as evidence in the Proof Graph.
172
+
173
+ ## Git and universal capture
174
+
175
+ Aperta's observer tracks stable staged, unstaged, untracked, and committed
176
+ changes regardless of whether they came from a human, an IDE, or an agent. The
177
+ Git Changes view shows the current working tree independently from captured
178
+ learning sessions. Agent attribution is additional evidence, not a requirement
179
+ for the comprehension workflow.
180
+
181
+ ## Harness Intelligence
182
+
183
+ Harness Health turns retained local runs into an improvement loop. It measures
184
+ first-pass verification, repair recovery, tool reliability, promotion rate,
185
+ provider latency, structured error classes, and an approximate Trusted Keep
186
+ Rate for promoted additions that remain in the working repository. Results are
187
+ broken down by provider, model, and bounded tool action so model and harness
188
+ changes can be compared instead of judged by anecdote.
189
+
190
+ Telemetry contains run metadata, timings, bounded error messages, and patch-line
191
+ survival counts. It is computed locally; Aperta does not export source code,
192
+ prompts, credentials, or repository evidence to an analytics service. Unknown
193
+ errors are surfaced as harness defects rather than silently folded into an
194
+ "agent failed" bucket.
195
+
196
+ The Impact Graph connects changed and removed code surfaces to repository
197
+ callers, imported dependencies, Spring configuration, API entry points, and
198
+ tests. It distinguishes structural evidence from unproven behavior and warns
199
+ when a saved explanation overlaps code that changed again. The analyzers are
200
+ language-specific and pluggable; the current beta starts with Java and
201
+ TypeScript rather
202
+ than claiming regex can provide compiler-level semantics for every language.
203
+
204
+ The repository Proof Graph unifies claims from captured changes and agent runs
205
+ with the evidence that supports them: selected skills, diffs, checks, runtime
206
+ observations, human explanations, and ownership reviews. A claim can be proven,
207
+ understood, supported, unproven, stale, or regressed. Later changes invalidate
208
+ only connected claims, preserving an auditable answer to both “does this work?”
209
+ and “can the maintainer explain it?”
210
+
211
+ The Proof Engine detects Maven, Gradle, npm, pnpm, or Yarn from project-owned
212
+ manifests and wrappers. From the Impact Graph, a developer can explicitly run
213
+ the relevant changed tests, retain the bounded result in the append-only local
214
+ ledger, and see graph surfaces move from inferred or unproven to proven—or to
215
+ regressed when the runner fails. Aperta also keeps uncovered behaviors visible
216
+ as proposed probes instead of treating a green test command as universal proof.
217
+
218
+ ## Install and run
219
+
220
+ Requires Node.js 22.6 or newer and Git.
221
+
222
+ ```sh
223
+ npm install --global aperta-cli@beta
224
+ ```
225
+
226
+ To develop Aperta itself from source instead:
227
+
228
+ ```sh
229
+ git clone https://github.com/Vequan23/aperta.git
230
+ cd aperta
231
+ npm install
232
+ npm test
233
+ npm run build
234
+ npm link
235
+ ```
236
+
237
+ Initialize the repository you want Aperta to track:
238
+
239
+ ```sh
240
+ cd /path/to/your/repository
241
+ aperta init
242
+ aperta status
243
+ aperta dashboard
244
+ ```
245
+
246
+ `aperta init` starts the universal observer automatically. On macOS it installs
247
+ a private per-project login service, so observation returns after login and is
248
+ restarted if the process crashes. It captures stable staged, unstaged,
249
+ untracked, and committed changes from any coding tool. Manage it explicitly with:
250
+
251
+ ```sh
252
+ aperta start
253
+ aperta status
254
+ aperta stop
255
+ ```
256
+
257
+ Changes are grouped after a short quiet period rather than recorded once per
258
+ keystroke. Agent adapters add model, prompt, and session provenance when it is
259
+ available; unattributed activity remains explicitly unknown.
260
+
261
+ Every initialized repository is added to the local `~/.aperta/projects.json`
262
+ registry. The dashboard project picker can switch between registered
263
+ repositories without exposing arbitrary filesystem browsing. Each project keeps
264
+ its own ledger, observer, branch state, queue, journal, and ownership history.
265
+
266
+ For dashboard development with live reload, run `npm run dev` from the cloned
267
+ Aperta repository and open the local URL Vite prints.
268
+
269
+ The standalone Vue marketing site lives in `marketing/` and uses the same Snow
270
+ Leopard/Aqua visual language as the product:
271
+
272
+ ```sh
273
+ npm run dev:marketing
274
+ npm run build:marketing
275
+ ```
276
+
277
+ The repository-level `vercel.json` deploys `marketing/dist`, so the repository
278
+ can be imported directly into Vercel without additional build configuration.
279
+
280
+ Automation can avoid interactive prompts with `aperta capture --ai --score 2`.
281
+ Interactive use captures authorship and confidence with one keystroke; confidence
282
+ times out after 15 seconds and Escape leaves it unrated.
283
+
284
+ ## Recommended agent loop
285
+
286
+ Wrap the coding agent once and work normally inside it:
287
+
288
+ ```sh
289
+ aperta run --intent "Add passwordless login" -- opencode
290
+ ```
291
+
292
+ Aperta snapshots the repository before and after the agent session, attributes
293
+ only the resulting changes to AI, stores the exact patch as local evidence, and
294
+ refuses to record the same change twice. Existing dirty work is not incorrectly
295
+ included in the session. If you skip the confidence prompt, the change appears
296
+ in the dashboard review queue.
297
+
298
+ For non-interactive agents or scripts:
299
+
300
+ ```sh
301
+ aperta run --intent "Repair CSV export" --score 2 -- your-agent-command --flags
302
+ ```
303
+
304
+ ## Data
305
+
306
+ Aperta keeps repository identity separate from private developer memory. The
307
+ repository contains only a safe pointer:
308
+
309
+ ```text
310
+ .comprehension/
311
+ ├── project.json
312
+ └── .gitignore
313
+ ```
314
+
315
+ Raw prompts, agent transcripts, explanations, learning answers, diffs, logs,
316
+ observer state, and the append-only evidence ledger live under:
317
+
318
+ ```text
319
+ ~/.aperta/repositories/<project-id>/
320
+ ├── config.json
321
+ ├── ledger.jsonl
322
+ └── cache/
323
+ ```
324
+
325
+ This private directory is outside the Git working tree. Initializing an older
326
+ Aperta repository migrates its existing config, ledger, and cache without
327
+ discarding history. `aperta init` and `aperta doctor` warn when legacy private
328
+ files are still Git-tracked so the developer can commit their deletion and
329
+ audit earlier repository history before sharing it.
330
+
331
+ The ledger remains append-only and integrity-chained. Each line is one intent,
332
+ diff, confidence, explanation, ownership-evidence, proof, probe, review,
333
+ session-complete, or gate-bypass event. From the Review Queue, an ownership
334
+ session constructs a risk-ranked Change Story, shows the exact diff, collects
335
+ evidence-linked reasoning, and distinguishes demonstrated ownership from a
336
+ self-reported confidence claim without pretending an LLM can grade prose.
337
+
338
+ Every completed ownership session enters the Learning Journal and leaves the
339
+ immediate review queue, including an honest low-confidence session with evidence
340
+ but no separate prose note. Future session evidence, rating, explanation, and
341
+ completion records are appended as one durable ledger operation.
342
+
343
+ ## Trust Kernel and semantic adapters
344
+
345
+ Aperta labels every graph claim as Git-observed, structurally inferred,
346
+ compiler-resolved, or runtime-proven. The JDK compiler adapter resolves
347
+ project-local Java symbols and call targets with annotation processing disabled.
348
+ The TypeScript compiler adapter covers JavaScript, TypeScript, JSX/TSX, and the
349
+ script portions of Vue single-file components. Compiler diagnostics downgrade
350
+ semantic coverage to partial instead of hiding missing dependencies or invalid
351
+ project configuration. Other languages retain the universal Git-level workflow
352
+ without invented symbol or call-graph certainty.
353
+
354
+ ## MVP beta workflow
355
+
356
+ The 1.0 beta separates immediate change review from scheduled retrieval practice
357
+ in **Learn Next**. Completed sessions return after one, three, or seven days
358
+ based on confidence, and return immediately when a later capture touches the
359
+ same files. Proofs and probes run as visible cancelable jobs with a minimized
360
+ environment, bounded output, secret redaction, and explicit disclosure that the
361
+ disposable project copy is not network isolation. A successful Maven proof also
362
+ caches the resolved dependency classpath for deeper subsequent Java analysis.
363
+
364
+ Ledger writes are serialized across Aperta processes, runtime-validated, and
365
+ integrity-chained. Existing records remain readable as legacy entries. Run
366
+ `aperta doctor` from a tracked repository to check its observer, ledger,
367
+ semantic adapter, and release readiness. The installed CLI runs compiled
368
+ JavaScript; experimental TypeScript execution is used only by the source test
369
+ suite.
370
+
371
+ ## Probe Lab
372
+
373
+ Aperta turns unproven Impact Graph paths into previewable executable
374
+ probes. A probe is selected by stable ID from Aperta's repository-aware catalog;
375
+ the browser never supplies source code or a command. Aperta copies the project
376
+ into a disposable directory, injects the generated test only there, runs the
377
+ allowlisted test runner, deletes the copy, and retains a bounded result plus a
378
+ hash of the generated source in the local ledger. Proven or disproven probes
379
+ update the graph verdicts. The first executable provider covers Spring Security
380
+ JWT expiry, issuer, and signature validation; endpoint authorization remains
381
+ explicitly blocked until a concrete protected route exists.
382
+
383
+ Diff evidence and generated probe previews use a safe token renderer with
384
+ language-aware highlighting for Java, TypeScript/JavaScript, JSON, XML, YAML,
385
+ properties, TOML, and shell-like files. Source is rendered as text tokens—not
386
+ injected HTML—so highlighting does not expand the dashboard's trust boundary.
package/bin/aperta.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ try { await import("../dist-cli/src/cli.js"); }
3
+ catch (error) { console.error(`aperta: ${error instanceof Error ? error.message : String(error)}`); process.exit(1); }