@codacy/verity-cli 0.23.3 → 0.24.0
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.
package/bin/verity.js
CHANGED
|
@@ -13710,7 +13710,12 @@ function isReflectionQuestion(response) {
|
|
|
13710
13710
|
/reflection\s+for\s+future\s+agents/i,
|
|
13711
13711
|
/what(?:'s|\s+is)\s+one\s+thing\s+you\s+learned/i,
|
|
13712
13712
|
/say\s+['"]?skip['"]?\s+to\s+skip/i,
|
|
13713
|
-
/quick\s+reflection\s+question/i
|
|
13713
|
+
/quick\s+reflection\s+question/i,
|
|
13714
|
+
// Post-flip (VRT-21): the agent drafts the reflection itself and, when
|
|
13715
|
+
// interactive, asks the user to confirm/correct before recording. That
|
|
13716
|
+
// turn authors no code either, so it's still a reflection turn.
|
|
13717
|
+
/reflection\s+draft/i,
|
|
13718
|
+
/confirm,?\s+correct,?\s+or\s+add/i
|
|
13714
13719
|
];
|
|
13715
13720
|
return markers.some((m) => m.test(response));
|
|
13716
13721
|
}
|
|
@@ -16047,10 +16052,29 @@ function registerResetCommand(program2) {
|
|
|
16047
16052
|
});
|
|
16048
16053
|
}
|
|
16049
16054
|
|
|
16055
|
+
// src/lib/run-mode.ts
|
|
16056
|
+
function parseAutonomousEnv(raw) {
|
|
16057
|
+
if (raw === void 0) return void 0;
|
|
16058
|
+
const v = raw.trim().toLowerCase();
|
|
16059
|
+
if (v === "") return void 0;
|
|
16060
|
+
if (v === "0" || v === "false" || v === "off" || v === "no") return false;
|
|
16061
|
+
return true;
|
|
16062
|
+
}
|
|
16063
|
+
function resolveRunMode(inputs = {}) {
|
|
16064
|
+
if (inputs.autonomousFlag === true) return "autonomous";
|
|
16065
|
+
if (inputs.autonomousFlag === false) return "interactive";
|
|
16066
|
+
const env = inputs.env ?? process.env;
|
|
16067
|
+
const envDecision = parseAutonomousEnv(env.VERITY_AUTONOMOUS);
|
|
16068
|
+
if (envDecision !== void 0) return envDecision ? "autonomous" : "interactive";
|
|
16069
|
+
const isTTY = inputs.isTTY ?? Boolean(process.stdin?.isTTY);
|
|
16070
|
+
return isTTY ? "interactive" : "autonomous";
|
|
16071
|
+
}
|
|
16072
|
+
|
|
16050
16073
|
// src/commands/reflect.ts
|
|
16051
16074
|
function registerReflectCommand(program2) {
|
|
16052
|
-
program2.command("reflect").description("Capture learnings \u2014 auto-extract or submit a human reflection").option("--user-input <text>", "
|
|
16075
|
+
program2.command("reflect").description("Capture learnings \u2014 auto-extract or submit a human reflection").option("--user-input <text>", "The reflection to record (the agent-drafted or user-confirmed text)").option("--kind <kind>", "Node kind (decision, gotcha, pattern, security, quality, intent, domain, integration)", "gotcha").option("--task-id <id>", "Task to reflect on (defaults to current task)").option("--autonomous", "Record the drafted reflection without a confirm step (auto-detected from TTY / VERITY_AUTONOMOUS when omitted)").action(async (opts) => {
|
|
16053
16076
|
const globals = program2.opts();
|
|
16077
|
+
const mode = resolveRunMode({ autonomousFlag: opts.autonomous });
|
|
16054
16078
|
await ensureMemoryDir();
|
|
16055
16079
|
const tokenResult = await resolveToken(globals.token);
|
|
16056
16080
|
if (!tokenResult.ok) {
|
|
@@ -16141,7 +16165,9 @@ function registerReflectCommand(program2) {
|
|
|
16141
16165
|
const nodeId = result.data.node_id;
|
|
16142
16166
|
const filePath = result.data.file_path;
|
|
16143
16167
|
printInfo(`Queued: ${nodeId} (will sync to .verity/memory/${filePath} on next analysis).`);
|
|
16144
|
-
printInfo(
|
|
16168
|
+
printInfo(
|
|
16169
|
+
mode === "autonomous" ? "Recorded autonomously (no confirm step) into the project knowledge base." : "Recorded your confirmed reflection into the project knowledge base."
|
|
16170
|
+
);
|
|
16145
16171
|
if (taskResolution === "none") {
|
|
16146
16172
|
printInfo("(No task context \u2014 reflection lives at the project level.)");
|
|
16147
16173
|
}
|
|
@@ -16408,7 +16434,7 @@ function registerTelemetryCommands(program2) {
|
|
|
16408
16434
|
}
|
|
16409
16435
|
|
|
16410
16436
|
// src/cli.ts
|
|
16411
|
-
program.name("verity").description("CLI for Verity quality gate service").version("0.
|
|
16437
|
+
program.name("verity").description("CLI for Verity quality gate service").version("0.24.0").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr");
|
|
16412
16438
|
registerAuthCommands(program);
|
|
16413
16439
|
registerHooksCommands(program);
|
|
16414
16440
|
registerIntentCommands(program);
|
|
@@ -1,47 +1,83 @@
|
|
|
1
1
|
# /verity-reflect — Capture learnings after a task
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
At a natural task-completion moment, **the agent reflects first** — draft a
|
|
4
|
+
concrete, cited observation from what actually happened — then either confirm it
|
|
5
|
+
with the user (interactive) or record it directly (autonomous). This is the
|
|
6
|
+
"reflection flip": Verity stops asking the user to do the reflecting and instead
|
|
7
|
+
does the work, with the human as editor rather than author.
|
|
4
8
|
|
|
5
|
-
##
|
|
9
|
+
## The flip — draft first, then confirm or auto-record
|
|
10
|
+
|
|
11
|
+
### 1. Self-draft (always)
|
|
12
|
+
|
|
13
|
+
When a task is complete, draft **1–3** things genuinely worth remembering — a
|
|
14
|
+
**decision**, a **gotcha**, or a **pattern** — from what happened this task. Each
|
|
15
|
+
item must be **concrete and cited**: name the files, PR, commands, or
|
|
16
|
+
error-signatures it came from. **Skip entirely if nothing non-obvious happened**
|
|
17
|
+
— an empty reflection is better than a filler one.
|
|
18
|
+
|
|
19
|
+
Pick the right `--kind` per item: `decision`, `gotcha`, `pattern`, `security`,
|
|
20
|
+
`quality`, `intent`, `domain`, `integration`.
|
|
21
|
+
|
|
22
|
+
### 2. Branch on run mode
|
|
6
23
|
|
|
7
|
-
|
|
24
|
+
**Interactive** (a person is at the keyboard — a TTY): show your draft and ask
|
|
25
|
+
one question before recording:
|
|
26
|
+
|
|
27
|
+
> "Here's my reflection draft for the project memory: _\<draft\>_. Anything to
|
|
28
|
+
> **confirm, correct, or add** before I record it? (Say 'skip' to drop it.)"
|
|
29
|
+
|
|
30
|
+
Then record the **final** text — with their corrections folded in — via:
|
|
8
31
|
|
|
9
32
|
```bash
|
|
10
|
-
verity reflect
|
|
33
|
+
verity reflect --user-input "<final reflection>" --kind <kind>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
If they say "skip", do **not** record.
|
|
37
|
+
|
|
38
|
+
**Autonomous** (no person to confirm — headless / CI / cron, or
|
|
39
|
+
`VERITY_AUTONOMOUS=1`, or a non-TTY session): record your draft **directly**,
|
|
40
|
+
never blocking:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
verity reflect --user-input "<your draft>" --kind <kind> --autonomous
|
|
11
44
|
```
|
|
12
45
|
|
|
13
|
-
|
|
46
|
+
Mode is auto-detected when you omit the flag (TTY ⇒ interactive, non-TTY ⇒
|
|
47
|
+
autonomous); pass `--autonomous` to be explicit, or set `VERITY_AUTONOMOUS=0` to
|
|
48
|
+
force a confirm step even in a headless run.
|
|
49
|
+
|
|
50
|
+
### 3. Where it lands
|
|
51
|
+
|
|
52
|
+
The reflection is recorded **only to Verity's own memory namespace** —
|
|
53
|
+
`.verity/memory/` (synced to the service). Verity never writes a repo's own
|
|
54
|
+
`agents/memory` or any other store. One node per item; `source: 'user'`,
|
|
55
|
+
`confidence: 1.0`, never auto-archived.
|
|
14
56
|
|
|
15
|
-
##
|
|
57
|
+
## Auto-reflection (extract from task history)
|
|
16
58
|
|
|
17
|
-
|
|
59
|
+
Complementary to the flip: trigger the server-side LLM extractor to mine the
|
|
60
|
+
current task's run history and produce 0–3 nodes. This is the same extraction
|
|
61
|
+
that runs automatically on task close and every 5 runs — use it to trigger
|
|
62
|
+
mid-task:
|
|
18
63
|
|
|
19
64
|
```bash
|
|
20
|
-
verity reflect
|
|
65
|
+
verity reflect
|
|
21
66
|
```
|
|
22
67
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
2. Set `source: 'user'` and `confidence: 1.0`
|
|
26
|
-
3. Opportunistically link to existing nodes
|
|
27
|
-
4. Write the node locally and sync to cloud
|
|
68
|
+
Use the self-draft flow above for the **compound moment** (a specific insight
|
|
69
|
+
worth a confirmed node); use auto-extract to harvest what the run history shows.
|
|
28
70
|
|
|
29
71
|
## When to reflect
|
|
30
72
|
|
|
31
|
-
|
|
73
|
+
At natural task-completion moments:
|
|
32
74
|
|
|
33
75
|
- After creating a PR
|
|
34
76
|
- When the user says "done", "ship it", or "that's it"
|
|
35
77
|
- When a task is explicitly closed
|
|
36
78
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
> "Quick reflection for future agents: what's one thing you learned during this task that would help next time? A decision, a gotcha, a pattern — anything worth remembering. (Say 'skip' to skip.)"
|
|
40
|
-
|
|
41
|
-
If the user says "skip", do NOT call `verity reflect`. The reflection is optional.
|
|
42
|
-
|
|
43
|
-
## Examples of good reflections
|
|
79
|
+
## Examples of good drafts
|
|
44
80
|
|
|
45
|
-
- "The Stripe retry logic needs
|
|
46
|
-
- "We
|
|
47
|
-
- "Don't touch the RLS policies without updating the cleanup cron
|
|
81
|
+
- "The Stripe retry logic needs idempotency keys or we double-charge — hit it in `payments/retry.ts:88`." → `gotchas/stripe-idempotency-keys.md`
|
|
82
|
+
- "We chose advisory locks over optimistic locking because Supabase supports them natively (see PR #214)." → `decisions/advisory-locks-for-versioning.md`
|
|
83
|
+
- "Don't touch the RLS policies without updating the cleanup cron — they're coupled (`migrations/0190`, `cron/cleanup.sql`)." → `gotchas/rls-cleanup-coupling.md`
|
|
@@ -425,18 +425,31 @@ If `CLAUDE.md` exists (or `.claude/CLAUDE.md`), append these two blocks. If it d
|
|
|
425
425
|
|
|
426
426
|
## Post-task reflection
|
|
427
427
|
When a task is complete (you've created a PR, the user says "done" or "ship it",
|
|
428
|
-
or the work is clearly finished),
|
|
428
|
+
or the work is clearly finished), **draft the reflection yourself first** — 1–3
|
|
429
|
+
concrete things worth remembering (a decision, a gotcha, or a pattern), each
|
|
430
|
+
cited with the files / PR / commands / error-signatures it came from. Skip
|
|
431
|
+
entirely if nothing non-obvious happened.
|
|
429
432
|
|
|
430
|
-
|
|
431
|
-
> task that would help next time? A decision, a gotcha, a pattern — anything
|
|
432
|
-
> worth remembering. (Say 'skip' to skip.)"
|
|
433
|
+
Then, depending on how the session is running:
|
|
433
434
|
|
|
434
|
-
|
|
435
|
+
- **Interactive** (a person is at the keyboard): show your draft and ask one
|
|
436
|
+
question before recording —
|
|
437
|
+
|
|
438
|
+
> "Here's my reflection draft for the project memory: \<draft\>. Anything to
|
|
439
|
+
> confirm, correct, or add before I record it? (Say 'skip' to drop it.)"
|
|
440
|
+
|
|
441
|
+
Record the final text (with their corrections) via
|
|
442
|
+
`verity reflect --user-input "<final reflection>" --kind <kind>`. If they say
|
|
443
|
+
"skip", do not record.
|
|
444
|
+
|
|
445
|
+
- **Autonomous** (headless / CI / cron, or `VERITY_AUTONOMOUS=1`): record your
|
|
446
|
+
draft directly, never blocking —
|
|
447
|
+
`verity reflect --user-input "<your draft>" --kind <kind> --autonomous`.
|
|
435
448
|
```
|
|
436
449
|
|
|
437
450
|
These blocks enable two capabilities:
|
|
438
451
|
1. **Knowledge Base pointer** — agents can browse `.verity/memory/` for project context on demand (KNOWLEDGE-SYSTEM §8.2 Path B)
|
|
439
|
-
2. **Post-task reflection** — the compound moment where the user's
|
|
452
|
+
2. **Post-task reflection** — the compound moment where the agent drafts a cited reflection and the user confirms/corrects it (interactive) or it's auto-recorded (autonomous), entering the knowledge base (KNOWLEDGE-SYSTEM §9.3)
|
|
440
453
|
|
|
441
454
|
---
|
|
442
455
|
|