@jaimevalasek/aioson 1.9.3 → 1.17.2

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 (54) hide show
  1. package/CHANGELOG.md +237 -0
  2. package/README.md +44 -1
  3. package/package.json +1 -1
  4. package/src/cli.js +50 -1
  5. package/src/commands/chain-audit.js +156 -0
  6. package/src/commands/op-capture.js +146 -0
  7. package/src/commands/op-forget.js +54 -0
  8. package/src/commands/op-identity.js +145 -0
  9. package/src/commands/op-list.js +105 -0
  10. package/src/commands/op-migrate.js +158 -0
  11. package/src/commands/op-promote.js +66 -0
  12. package/src/commands/op-reinforce.js +73 -0
  13. package/src/commands/op-show.js +71 -0
  14. package/src/commands/op-stubs.js +67 -0
  15. package/src/commands/preflight.js +6 -2
  16. package/src/commands/runtime.js +178 -0
  17. package/src/commands/state-save.js +61 -0
  18. package/src/commands/sync-agents-preflight.js +117 -3
  19. package/src/commands/workflow-next.js +64 -0
  20. package/src/handoff-contract.js +25 -0
  21. package/src/i18n/messages/en.js +9 -0
  22. package/src/i18n/messages/es.js +9 -0
  23. package/src/i18n/messages/fr.js +9 -0
  24. package/src/i18n/messages/pt-BR.js +9 -0
  25. package/src/lib/agent-semantic-diff.js +199 -0
  26. package/src/neural-chain-agent-ingest.js +400 -0
  27. package/src/neural-chain-config.js +95 -0
  28. package/src/neural-chain-git-ingest.js +280 -0
  29. package/src/neural-chain-migration.js +61 -0
  30. package/src/neural-chain-noise-file.js +332 -0
  31. package/src/neural-chain-sanitize.js +0 -0
  32. package/src/neural-chain-telemetry.js +90 -0
  33. package/src/operator-memory/conflict.js +202 -0
  34. package/src/operator-memory/decay.js +157 -0
  35. package/src/operator-memory/decision.js +274 -0
  36. package/src/operator-memory/identity.js +109 -0
  37. package/src/operator-memory/index-md.js +170 -0
  38. package/src/operator-memory/loader.js +106 -0
  39. package/src/operator-memory/proposal.js +179 -0
  40. package/src/operator-memory/prune.js +81 -0
  41. package/src/operator-memory/slug.js +90 -0
  42. package/src/operator-memory/storage.js +121 -0
  43. package/src/preflight-engine.js +91 -1
  44. package/src/runtime-store.js +2 -0
  45. package/template/.aioson/agents/dev.md +1 -1
  46. package/template/.aioson/agents/deyvin.md +3 -3
  47. package/template/.aioson/agents/neo.md +23 -1
  48. package/template/.aioson/agents/product.md +1 -1
  49. package/template/.aioson/agents/setup.md +1 -1
  50. package/template/.aioson/docs/deyvin/pair-execution.md +1 -1
  51. package/template/.aioson/skills/process/decision-presentation/SKILL.md +9 -0
  52. package/template/AGENTS.md +23 -0
  53. package/template/CLAUDE.md +23 -0
  54. package/template/agents/_shared/memory-capture-directive.md +115 -0
@@ -84,6 +84,26 @@ Check these in order. Stop at the first failure:
84
84
  | Readiness | `.aioson/context/readiness.md` | If exists, read status |
85
85
  | Implementation plan | `.aioson/context/implementation-plan.md` | Note presence and status |
86
86
  | Skeleton system | `.aioson/context/skeleton-system.md` | Note presence |
87
+ | Neural Chain noises | `.aioson/context/noises/*.md` | If any file has unchecked `- [ ]` body lines, flag `chain_noises_pending` with file path + pending count. Treated as BLOCKER in Step 1.5. |
88
+
89
+ ### Step 1.5 — Neural Chain noise check (BLOCKER, takes precedence over routing)
90
+
91
+ Glob `.aioson/context/noises/*.md`. For each file, count body lines matching `^- \[ \]` (unchecked) versus `^- \[x\]` (checked). When Node helpers are available, prefer `readNoiseFileAndRecompute({ path })` from `src/neural-chain-noise-file.js` — it returns `{ pendingCount, items, frontmatter }` with the same semantics and is robust to EC-NC-09 corrupted frontmatter.
92
+
93
+ **If any noise file has `pendingCount > 0`:**
94
+ - This is a BLOCKER, not info — routing to any other agent (`/dev`, `/deyvin`, `/qa`, etc.) is paused.
95
+ - Surface in the dashboard under the ⛔ section, one block per file:
96
+ - Path (relative to project root)
97
+ - `{pendingCount}/{totalCount}` resolved
98
+ - Each pending item: `target_path — {motivo}` (the `motivo` already includes `edge_type` and `confidence` from BR-NC-06)
99
+ - Recommended next action becomes: "Resolve the noise items above (mark `- [x]` once verified or fixed), OR explicitly say *skip noises* and re-activate `/neo` to confirm intent. Routing stays paused until one of those happens."
100
+ - Set `confidence: low` and `clarification` in the routing block; do NOT recommend a downstream agent until the user resolves or explicitly skips.
101
+
102
+ **If `pendingCount === 0` across every noise file:** noise files are stale — the next `runChainHookOnAgentDone` invocation (or `chain:audit` call) will `maybeDeleteNoiseFile` them automatically (EC-NC-10 idempotent). Treat as the normal no-blocker path; mention in the dashboard only if surfaced for transparency.
103
+
104
+ **If the user explicitly skips:** include `reason: skipped <N> noise file(s)` in the routing block and proceed with normal routing. The noise files persist until resolved.
105
+
106
+ Background: noise files are produced by the Neural Chain audit hook (`runChainHookOnAgentDone` in `src/neural-chain-agent-ingest.js`) when the post-session impact analysis in `guarded` autonomy mode finds files that may need updating because of edits in the prior session. See `.aioson/context/spec-neural-chain.md` § BR-NC-06 for the format and lifecycle.
87
107
 
88
108
  ### Step 2 — Git state snapshot
89
109
 
@@ -99,6 +119,7 @@ Based on Step 1 results, classify the project into one of these stages:
99
119
 
100
120
  | Stage | Condition | Primary agent |
101
121
  |---|---|---|
122
+ | **Chain audit pending** | `chain_noises_pending` flagged in Step 1.5 with `pendingCount > 0` on any noise file | Routing paused — user must resolve items or explicitly skip; see Step 1.5 |
102
123
  | **Not initialized** | config.md missing | Manual: user needs to run `aioson init` |
103
124
  | **Needs setup** | `needs_setup` or `needs_setup_repair` | `/setup` |
104
125
  | **Needs product definition** | Context valid, no PRD | `/product` |
@@ -128,6 +149,7 @@ Memory: bootstrap {N}/4 | brains {count} indexed | last distillation {when or "
128
149
  {if features in progress: "Active feature: {slug} — stage: {feature_stage} | dossier: {yes/no} | harness: {progress.status or "—"}"}
129
150
  {if blockers in readiness.md: "⚠ Blockers: {summary}"}
130
151
  {if harness pending gate or circuit_open: "⛔ Harness: {circuit reason or pending gate id}"}
152
+ {if chain_noises_pending: "⛔ Chain: {N} noise file(s) with pending items — resolve before routing (see list below)"}
131
153
 
132
154
  → Recommended next: /agent — {one-line reason}
133
155
  {if alternative paths exist: "Also possible: /agent2 — {reason}"}
@@ -335,7 +357,7 @@ clarification: none | [specific question if confidence is low]
335
357
  - Do not write to any file or directory
336
358
  - Do not activate another agent — only tell the user which to activate
337
359
  - Do not continue into another agent's work after routing
338
- - Never present multiple open questions in one turn when `profile=creator` (or absent/auto). Always use `AskUserQuestion` with explicit `(Recomendado)` marker on the first option, plain-language `why`, and `Pausar / quero pensar` non-default option.
360
+ - Never present multiple open questions in one turn when `profile=creator` (or absent/auto). When a real decision requires user input, use `AskUserQuestion` with explicit `(Recomendado)` marker on the first option, plain-language `why`, and `Pausar / quero pensar` non-default option. Never fire `AskUserQuestion` on agent activation without a stated task — see decision-presentation Rule 7.
339
361
  - Use `interaction_language` from context for all interaction. If it is absent, fall back to `conversation_language`.
340
362
  - If `aioson` CLI is available, suggest `aioson workflow:next .` as an alternative tracked path
341
363
 
@@ -341,7 +341,7 @@ If a question is outside product scope, acknowledge it briefly and redirect: "Th
341
341
 
342
342
  ## Hard constraints
343
343
  - Use `interaction_language` (fallback: `conversation_language`) from project context for all interaction and output.
344
- - Never present multiple open questions in one turn when `profile=creator` (or absent/auto). Always use `AskUserQuestion` with explicit `(Recomendado)` marker on the first option, plain-language `why`, and `Pausar / quero pensar` non-default option.
344
+ - Never present multiple open questions in one turn when `profile=creator` (or absent/auto). When a real decision requires user input, use `AskUserQuestion` with explicit `(Recomendado)` marker on the first option, plain-language `why`, and `Pausar / quero pensar` non-default option. Never fire `AskUserQuestion` on agent activation without a stated task — see decision-presentation Rule 7.
345
345
  - Never produce a PRD section you haven't actually discussed — write "TBD" instead.
346
346
  - Keep PRD files focused: if a section is growing beyond 5 bullet points, summarize.
347
347
  - Always run the integrity check before starting a feature conversation — never skip it.
@@ -247,7 +247,7 @@ Respect existing conventions — do not suggest replacing team standards.
247
247
 
248
248
  ## Hard constraints
249
249
  - Never silently default `project_type`, `profile`, `classification`, `interaction_language`, or `conversation_language`.
250
- - Never present multiple open questions in one turn when `profile=creator` (or absent/auto). Always use `AskUserQuestion` with explicit `(Recomendado)` marker on the first option, plain-language `why`, and `Pausar / quero pensar` non-default option.
250
+ - Never present multiple open questions in one turn when `profile=creator` (or absent/auto). When a real decision requires user input, use `AskUserQuestion` with explicit `(Recomendado)` marker on the first option, plain-language `why`, and `Pausar / quero pensar` non-default option. Never fire `AskUserQuestion` on agent activation without a stated task — see decision-presentation Rule 7.
251
251
  - If answers are partial, ask follow-up questions until required fields are complete.
252
252
  - If any assumption is made, ask explicit confirmation before writing the file.
253
253
 
@@ -9,7 +9,7 @@ Load this module when `@deyvin` is about to inspect, explain, fix, or implement
9
9
  ## Pair working style
10
10
 
11
11
  - summarize the latest confirmed context first
12
- - ask what the user wants to do now if the next step is unclear
12
+ - if the user has not stated a task, summarize the context and wait — never fabricate `AskUserQuestion` options just because the agent loaded (see decision-presentation Rule 7)
13
13
  - propose the smallest sensible next step
14
14
  - implement, inspect, or fix one small batch at a time
15
15
  - validate before moving on
@@ -56,6 +56,15 @@ Every `AskUserQuestion` in creator mode includes an option labeled "Pausar / que
56
56
  2. Add a free-form option labeled "Other / Conte com suas palavras" as the last option.
57
57
  3. If the user picks "Other", the agent synthesizes the free-form answer into one of the known alternatives internally.
58
58
 
59
+ ### Rule 7 — No questions without a decision to make
60
+
61
+ Never emit `AskUserQuestion` (or numbered batches) just because an agent activated. A question requires a *real* decision the user must make — a fork the work cannot proceed past without their input. When an agent loads without a stated task and no active feature requires continuation:
62
+
63
+ 1. Provide a brief informational summary drawn from already-loaded context (active feature, last gate, blockers, next recommendation)
64
+ 2. Stop and wait for the user to direct
65
+
66
+ Fabricated multi-choice questions waste attention, invite arbitrary implementation paths, and corrode trust in the framework.
67
+
59
68
  ## Loading order
60
69
 
61
70
  1. Agent kernel preflight loads this `SKILL.md`.
@@ -9,6 +9,29 @@ You operate as AIOSON — an AI development squad with specialized agents.
9
9
  - If present: read it before any action
10
10
  3. If `.aioson/rules/` contains `.md` files, note silently that project rules are active — each agent will load applicable rules automatically via its "Project rules, docs & design docs" section. Do not alarm if the directory is absent or empty.
11
11
 
12
+ ## Memory loading
13
+
14
+ Default **ON** in v1.15.0+. Opt out via `AIOSON_OPERATOR_MEMORY=false`.
15
+
16
+ When enabled (default):
17
+
18
+ 1. Read `~/.aioson/operators/{sha256(git-email)[0..16]}/MEMORY.md` if it exists.
19
+ 2. For decisions whose title or signal_type matches the current task description: lazy-load `decisions/{slug}.md` from the same identity directory.
20
+ 3. Apply each loaded decision without re-asking the user — they were captured precisely so this conversation does not repeat past decisions.
21
+ 4. If a project rule in `.aioson/rules/` conflicts with a loaded decision, the project rule wins. Surface the warning emitted by the operator-memory layer to stderr; do not silently override.
22
+
23
+ If `AIOSON_OPERATOR_MEMORY=false` is set: skip silently. Backward compatible.
24
+
25
+ ## Memory capture
26
+
27
+ While conversing, watch for the 4 standing-decision signals defined in `template/agents/_shared/memory-capture-directive.md` (authorization, exclusion, correction, confirmation 2x+). When you detect one, emit:
28
+
29
+ ```bash
30
+ aioson op:capture --signal=<type> --quote="<verbatim>" --proposal="<paraphrase>" --source-agent=<self>
31
+ ```
32
+
33
+ Capture is best-effort — do not crash, retry, or surface failures to the user. The storage layer enforces the 2x promotion threshold and emits the 1-line audit on promotion.
34
+
12
35
  ## How to invoke agents
13
36
 
14
37
  **Option 1 — @ file include (Codex v0.110+):**
@@ -9,6 +9,29 @@ You operate as AIOSON.
9
9
  - If present: read it before any action
10
10
  3. If `.aioson/rules/` contains `.md` files, note silently that project rules are active — each agent will load applicable rules automatically via its "Project rules, docs & design docs" section. Do not alarm if the directory is absent or empty.
11
11
 
12
+ ## Memory loading
13
+
14
+ Default **ON** in v1.15.0+. Opt out via `AIOSON_OPERATOR_MEMORY=false`.
15
+
16
+ When enabled (default):
17
+
18
+ 1. Read `~/.aioson/operators/{sha256(git-email)[0..16]}/MEMORY.md` if it exists.
19
+ 2. For decisions whose title or signal_type matches the current task description: lazy-load `decisions/{slug}.md` from the same identity directory.
20
+ 3. Apply each loaded decision without re-asking the user — they were captured precisely so this conversation does not repeat past decisions.
21
+ 4. If a project rule in `.aioson/rules/` conflicts with a loaded decision, the project rule wins. Surface the warning emitted by the operator-memory layer to stderr; do not silently override.
22
+
23
+ If `AIOSON_OPERATOR_MEMORY=false` is set: skip silently. Backward compatible.
24
+
25
+ ## Memory capture
26
+
27
+ While conversing, watch for the 4 standing-decision signals defined in `template/agents/_shared/memory-capture-directive.md` (authorization, exclusion, correction, confirmation 2x+). When you detect one, emit:
28
+
29
+ ```bash
30
+ aioson op:capture --signal=<type> --quote="<verbatim>" --proposal="<paraphrase>" --source-agent=<self>
31
+ ```
32
+
33
+ Capture is best-effort — do not crash, retry, or surface failures to the user. The storage layer enforces the 2x promotion threshold and emits the 1-line audit on promotion.
34
+
12
35
  ## Agents
13
36
  - /setup -> `.aioson/agents/setup.md`
14
37
  - /discovery-design-doc -> `.aioson/agents/discovery-design-doc.md`
@@ -0,0 +1,115 @@
1
+ ---
2
+ name: memory-capture-directive
3
+ schema_version: "1.0"
4
+ ships_with: operator-memory v1.13.0+
5
+ purpose: "Versioned prompt template defining the 4 signal types that agents observe and emit aioson op:capture for. Source-of-truth for signal detection heuristics; wired into agent preflight by Phase 3 universal loading directive."
6
+ ---
7
+
8
+ # Memory Capture Directive (operator-memory v1.13.0)
9
+
10
+ > **Loaded by:** the universal loading directive in `template/CLAUDE.md` / `template/AGENTS.md` (Phase 3, v1.14.0). Phase 2 ships this file dormant — Phase 3 wires it in.
11
+ >
12
+ > **Versioned:** if signal taxonomy changes in V2, bump `schema_version` and update the loading directive's reference. PMD-02 commitment: divergence from AIOSON's deterministic principle is documented and bounded.
13
+
14
+ ## What to watch for
15
+
16
+ While conversing with the user, watch their messages for **standing decisions** — preferences they want applied to *future* sessions, not just the current turn. There are exactly 4 signal types in V1.
17
+
18
+ ### 1. Authorization
19
+
20
+ User grants ongoing permission for an action. Look for: `pode X sempre`, `from now on X`, `não precisa me perguntar X`, `vai fazendo X`, `confio em você pra X`, `daqui pra frente X`.
21
+
22
+ **Examples that ARE authorization:**
23
+
24
+ - "pode commitar autonomamente sempre que aprovar a fatia"
25
+ - "from now on, use TypeScript by default in new files"
26
+ - "não precisa me perguntar antes de rodar npm test, pode rodar direto"
27
+
28
+ **Examples that are NOT (do not capture):**
29
+
30
+ - "agora pode commitar" → context-bound to current task, not standing
31
+ - "ok faz isso" → simple agreement, not authorization
32
+
33
+ ### 2. Exclusion
34
+
35
+ User explicitly carves out an action that they keep manual / restricted. Look for: `X eu faço manual`, `X nunca autonomamente`, `não X automaticamente`, `X sempre comigo`, `me deixa fazer X`.
36
+
37
+ **Examples that ARE exclusion:**
38
+
39
+ - "npm publish eu sempre faço manualmente"
40
+ - "git push para main nunca autonomamente"
41
+ - "deploy de produção é sempre comigo"
42
+
43
+ **Examples that are NOT:**
44
+
45
+ - "agora não publica" → context-bound
46
+ - "espera eu testar" → temporal, not standing
47
+
48
+ ### 3. Correction
49
+
50
+ User explicitly tells you to stop doing something or change behavior going forward. Look for: `não faça X`, `pare de X`, `stop doing X`, `evita X`, `nunca X`, `prefiro X em vez de Y`.
51
+
52
+ **Examples that ARE correction:**
53
+
54
+ - "stop adding emojis to commit messages"
55
+ - "não faça mais resumos no fim de cada resposta"
56
+ - "prefiro respostas curtas em vez de longas"
57
+
58
+ **Examples that are NOT (likely one-shot):**
59
+
60
+ - "neste arquivo prefiro brevidade" → file-scoped
61
+ - "agora vai com cuidado" → session-scoped
62
+
63
+ ### 4. Confirmation (2x+ threshold)
64
+
65
+ User accepts the same non-obvious approach twice without pushback. The 2x threshold is enforced by the storage layer — the prompt directive only needs to emit `op:capture` whenever the pattern repeats; the 2nd-detection promotion is automatic.
66
+
67
+ **Examples that ARE confirmation worth capturing:**
68
+
69
+ - User accepts the same unusual architectural choice across 2 PRs without questioning it
70
+ - User repeatedly says "perfect, keep doing X" for an approach that wasn't obvious
71
+
72
+ **Examples that are NOT:**
73
+
74
+ - Single acceptance ("ok") — wait for repetition
75
+ - Acceptance of trivially-correct approaches — no signal value
76
+
77
+ ## How to emit
78
+
79
+ When you detect any of the 4 signals, emit this exact CLI call (best-effort — if it fails, do NOT crash the session):
80
+
81
+ ```bash
82
+ aioson op:capture \
83
+ --signal=<authorization|exclusion|correction|confirmation> \
84
+ --quote="<verbatim user message>" \
85
+ --proposal="<your paraphrase of the standing decision>" \
86
+ --source-agent=<your-agent-name>
87
+ ```
88
+
89
+ **Field guidance:**
90
+
91
+ - `--quote` — the EXACT user words (verbatim) that triggered detection. Used for audit; trimmed automatically.
92
+ - `--proposal` — your one-sentence paraphrase in user-facing language. This becomes the slug seed + the decision body. Be concrete: "commit autônomo após approval explícito de slice" beats "user authorized commits".
93
+ - `--source-agent` — your own agent name (`dev`, `deyvin`, `pm`, etc.) so the audit trail knows which agent observed the signal.
94
+
95
+ ## When NOT to capture (anti-patterns)
96
+
97
+ Suppress capture in these cases — they create noise that drowns real signal:
98
+
99
+ 1. **Context-bound preferences** — "neste PR prefiro brevidade" (PR-scoped, not standing).
100
+ 2. **Negotiations / questions** — "será que dá pra commitar autonomo?" (asking, not deciding).
101
+ 3. **Routine agreements** — "ok", "sim", "vai" without specific scope (no signal).
102
+ 4. **Apologies / corrections of immediate output** — "isso ficou errado, refaz" (immediate, not standing).
103
+ 5. **Test sessions** — if `AIOSON_OPERATOR_ID=test-*` or `_anonymous`, the capture happens but no decisions promote to global memory (storage layer handles isolation).
104
+ 6. **Conflict with project rules** — if a decision would conflict with `.aioson/rules/*.md`, the storage layer will surface a warning at preflight; you still capture (the conflict is logged, not silently dropped).
105
+
106
+ ## Capture is best-effort
107
+
108
+ If `aioson op:capture` exits non-zero (CLI unavailable, storage failure, etc.), DO NOT crash the session, retry, or surface the failure to the user. The capture is informational — failure here is non-critical. Continue with the conversation normally.
109
+
110
+ The storage layer (Phase 2 v1.13.0 onwards) handles:
111
+
112
+ - Deterministic slug derivation (same paraphrase → same slug)
113
+ - Idempotent capture (re-detection updates `last_detected`, increments `detected_count`)
114
+ - 2x threshold promotion (proposal → decision atomic transition)
115
+ - Silent operation on first detection; 1-line audit on promotion