@njeybe/nativ 2.5.1 → 2.6.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/CHANGELOG.md +32 -0
- package/README.md +29 -4
- package/dist/commands/init.js +2 -10
- package/dist/commands/notify.d.ts +2 -0
- package/dist/commands/notify.js +25 -0
- package/dist/commands/session.d.ts +22 -0
- package/dist/commands/session.js +106 -0
- package/dist/commands/task/task-add.js +1 -1
- package/dist/commands/task/task-common.js +6 -6
- package/dist/commands/task/task-escalate.js +8 -10
- package/dist/commands/task/task-lifecycle.d.ts +7 -1
- package/dist/commands/task/task-lifecycle.js +30 -5
- package/dist/commands/task/task-query.d.ts +2 -0
- package/dist/commands/task/task-query.js +27 -12
- package/dist/commands/task/task-reclaim.d.ts +20 -0
- package/dist/commands/task/task-reclaim.js +87 -0
- package/dist/commands/task.d.ts +2 -0
- package/dist/commands/task.js +1 -0
- package/dist/commands/triage.js +3 -3
- package/dist/commands/validate.js +1 -0
- package/dist/commands/verify.js +21 -5
- package/dist/core/enforcement.js +18 -17
- package/dist/core/lock-manager.d.ts +6 -0
- package/dist/core/lock-manager.js +50 -41
- package/dist/core/notify.d.ts +38 -0
- package/dist/core/notify.js +133 -0
- package/dist/core/profiles.js +7 -16
- package/dist/core/session-memory.d.ts +42 -0
- package/dist/core/session-memory.js +121 -0
- package/dist/core/setup/pm-playbook.d.ts +5 -0
- package/dist/core/setup/pm-playbook.js +26 -0
- package/dist/core/setup/session-context.js +35 -2
- package/dist/core/setup/setup-planner.js +2 -2
- package/dist/core/setup/types.d.ts +2 -0
- package/dist/core/setup/types.js +5 -1
- package/dist/core/task-claims.d.ts +15 -0
- package/dist/core/task-claims.js +32 -0
- package/dist/core/tier1-liaison.d.ts +1 -0
- package/dist/core/tier1-liaison.js +25 -27
- package/dist/core/verifier/output-digest.d.ts +19 -0
- package/dist/core/verifier/output-digest.js +48 -0
- package/dist/db/data-engine.js +33 -32
- package/dist/db/introspector.js +61 -60
- package/dist/db/sqlite.d.ts +3 -0
- package/dist/db/sqlite.js +10 -0
- package/dist/governor/circuit-breaker.js +12 -0
- package/dist/governor/patch-applier.d.ts +1 -0
- package/dist/governor/patch-applier.js +3 -7
- package/dist/index.js +29 -6
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.js +53 -14
- package/dist/providers/claude-api.js +3 -0
- package/dist/providers/gemini.js +4 -1
- package/dist/providers/registry.d.ts +6 -2
- package/dist/providers/registry.js +28 -16
- package/dist/providers/types.d.ts +4 -1
- package/dist/runner/agent-supervisor.js +2 -2
- package/dist/runner/cli-config.js +1 -1
- package/dist/scanner/types.d.ts +5 -1
- package/dist/scanner/types.js +7 -0
- package/dist/server/routes/task-routes.d.ts +2 -0
- package/dist/server/routes/triage-routes.js +3 -18
- package/package.json +2 -2
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/agents/architect.md +1 -1
- package/plugin/agents/explorer.md +1 -1
- package/plugin/agents/verifier.md +2 -2
- package/plugin/agents/worker.md +5 -7
- package/plugin/skills/nativ/SKILL.md +36 -49
- package/templates/AGENTS.md +36 -49
- package/templates/CLAUDE.md +1 -41
- package/templates/claude-agents/architect.md +1 -1
- package/templates/claude-agents/explorer.md +1 -1
- package/templates/claude-agents/verifier.md +2 -2
- package/templates/claude-agents/worker.md +5 -7
- package/templates/dot-ai/api_contracts.json +66 -66
- package/templates/dot-ai/context.md +38 -38
- package/templates/dot-ai/db_schema.json +39 -39
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
export type ProviderId = 'claude-cli' | 'claude-api' | 'gemini';
|
|
8
8
|
/** Roles a provider can be assigned to in `.nativ/config.json`. */
|
|
9
9
|
export type ProviderRole = 'architect' | 'pm' | 'worker' | 'verifier' | 'triage';
|
|
10
|
-
|
|
10
|
+
/** TRANSIENT: a network failure or a 5xx answer, worth retrying on the same provider after a short wait. */
|
|
11
|
+
export type ProviderErrorCode = 'NO_CREDENTIALS' | 'TIMEOUT' | 'RATE_LIMITED' | 'TRANSIENT' | 'BAD_RESPONSE';
|
|
11
12
|
/** Typed failure so callers can fall through the provider chain without string matching. */
|
|
12
13
|
export declare class ProviderError extends Error {
|
|
13
14
|
readonly code: ProviderErrorCode;
|
|
@@ -57,6 +58,8 @@ export interface ProviderDeps {
|
|
|
57
58
|
anthropicClient?: () => AnthropicLike;
|
|
58
59
|
env?: NodeJS.ProcessEnv;
|
|
59
60
|
now?: () => number;
|
|
61
|
+
/** Waits between retries; injectable so tests do not sleep. */
|
|
62
|
+
sleep?: (ms: number) => Promise<void>;
|
|
60
63
|
}
|
|
61
64
|
export interface AnthropicLike {
|
|
62
65
|
messages: {
|
|
@@ -5,6 +5,7 @@ import fs from 'node:fs';
|
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import Anthropic from '@anthropic-ai/sdk';
|
|
7
7
|
import { loadMasterPlan } from '../core/verifier.js';
|
|
8
|
+
import { writeJsonAtomicSync } from '../core/lock-manager.js';
|
|
8
9
|
import { cacheHitRate, computeActualCostUsd, emptyActualUsage, recordRunnerUsage, } from '../core/telemetry.js';
|
|
9
10
|
import { resolveProjectRoot, linkWorktreeAiDirectory, safeUnlinkWorktreeAiDirectory, linkWorktreeNodeModules, safeUnlinkWorktreeNodeModules, } from '../core/root-resolver.js';
|
|
10
11
|
import { resolveWorkerModel, toNativeModelId } from '../core/model-routing.js';
|
|
@@ -713,8 +714,7 @@ export class AgentSupervisor extends EventEmitter {
|
|
|
713
714
|
}
|
|
714
715
|
persist(record) {
|
|
715
716
|
try {
|
|
716
|
-
|
|
717
|
-
fs.writeFileSync(path.join(this.runsDir, `${record.taskId}.json`), `${JSON.stringify(record, null, 2)}\n`, 'utf8');
|
|
717
|
+
writeJsonAtomicSync(path.join(this.runsDir, `${record.taskId}.json`), record);
|
|
718
718
|
}
|
|
719
719
|
catch {
|
|
720
720
|
// Local-first persistence is advisory; in-memory state stays authoritative.
|
|
@@ -77,7 +77,7 @@ export function buildRunnerPrompt(task) {
|
|
|
77
77
|
task.description ? `Description: ${task.description}.` : '',
|
|
78
78
|
task.verificationCommand ? `Verify your work using: ${task.verificationCommand}.` : '',
|
|
79
79
|
`Start by running: nativ task start ${task.id}. When finished and verified, run: nativ task complete ${task.id}.`,
|
|
80
|
-
`If blocked, follow
|
|
80
|
+
`If blocked, follow "Talking to the human" in AGENTS.md: explain the user experience symptom, root cause in plain English, and clear options without technical jargon.`,
|
|
81
81
|
]
|
|
82
82
|
.filter(Boolean)
|
|
83
83
|
.join(' ');
|
package/dist/scanner/types.d.ts
CHANGED
|
@@ -42,6 +42,9 @@ export interface MasterPlanTask {
|
|
|
42
42
|
complexity?: TaskComplexity;
|
|
43
43
|
/** Plain-language "done when" lines. */
|
|
44
44
|
acceptanceCriteria?: string[];
|
|
45
|
+
/** Set by `task start` while in_progress: who claimed it (NATIV_AGENT_ID or --agent) and when. */
|
|
46
|
+
claimedBy?: string;
|
|
47
|
+
claimedAt?: string;
|
|
45
48
|
}
|
|
46
49
|
export type TaskComplexity = 'simple' | 'standard' | 'complex';
|
|
47
50
|
export declare const TASK_COMPLEXITIES: readonly TaskComplexity[];
|
|
@@ -64,7 +67,8 @@ export interface MasterPlan {
|
|
|
64
67
|
activeMilestoneId: string;
|
|
65
68
|
milestones: MasterPlanMilestone[];
|
|
66
69
|
}
|
|
67
|
-
export
|
|
70
|
+
export declare const ESCALATION_TYPES: readonly ["contract_drift", "schema_flaw", "missing_credential", "dependency_conflict", "architectural_ambiguity"];
|
|
71
|
+
export type EscalationType = (typeof ESCALATION_TYPES)[number];
|
|
68
72
|
export interface EscalationRecord {
|
|
69
73
|
id: string;
|
|
70
74
|
taskId: string;
|
package/dist/scanner/types.js
CHANGED
|
@@ -71,6 +71,8 @@ export declare function handlePipelineTasks(root: string): {
|
|
|
71
71
|
specRefs?: string[];
|
|
72
72
|
complexity?: import("../../scanner/types.js").TaskComplexity;
|
|
73
73
|
acceptanceCriteria?: string[];
|
|
74
|
+
claimedBy?: string;
|
|
75
|
+
claimedAt?: string;
|
|
74
76
|
}[];
|
|
75
77
|
id: string;
|
|
76
78
|
name: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { withFileLock, withPlanLock } from '../../core/lock-manager.js';
|
|
3
|
+
import { withFileLock, withPlanLock, writeJsonAtomicSync } from '../../core/lock-manager.js';
|
|
4
4
|
import { CircuitBreaker, applySelfHealingProposal, } from '../../governor/index.js';
|
|
5
5
|
import { finalizeTriage, triageBlocker } from '../../commands/triage.js';
|
|
6
6
|
import { HttpError } from '../http-utils.js';
|
|
@@ -19,7 +19,7 @@ export function readEscalationFile(root) {
|
|
|
19
19
|
catch {
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
|
-
//
|
|
22
|
+
// Older versions left an empty file behind when they first took its lock.
|
|
23
23
|
if (!raw.trim())
|
|
24
24
|
return null;
|
|
25
25
|
try {
|
|
@@ -34,22 +34,7 @@ export function readEscalationFile(root) {
|
|
|
34
34
|
}
|
|
35
35
|
/** tmp-file + rename so the SSE watcher and concurrent readers never observe a half-written file. */
|
|
36
36
|
export function writeJsonAtomic(file, data) {
|
|
37
|
-
|
|
38
|
-
fs.writeFileSync(tmp, `${JSON.stringify(data, null, 2)}\n`, 'utf8');
|
|
39
|
-
for (let attempt = 0;; attempt++) {
|
|
40
|
-
try {
|
|
41
|
-
fs.renameSync(tmp, file);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
catch (err) {
|
|
45
|
-
const code = err.code;
|
|
46
|
-
if (attempt >= 10 || (code !== 'EPERM' && code !== 'EBUSY')) {
|
|
47
|
-
fs.rmSync(tmp, { force: true });
|
|
48
|
-
throw err;
|
|
49
|
-
}
|
|
50
|
-
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
37
|
+
writeJsonAtomicSync(file, data);
|
|
53
38
|
}
|
|
54
39
|
/** Moves a blocked task back to pending so it can be dispatched again. False when it was not blocked. */
|
|
55
40
|
export async function unblockTask(root, taskId, note) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@njeybe/nativ",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Role-based multi-agent workflow harness: Claude Code by default, other AI agents pluggable",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"prepare": "npm run build",
|
|
23
23
|
"prepublishOnly": "npm run build && node scripts/sync-plugin.mjs --check",
|
|
24
24
|
"start": "node bin/cli.js",
|
|
25
|
-
"test": "node tests/
|
|
25
|
+
"test": "node tests/run-all.mjs"
|
|
26
26
|
},
|
|
27
27
|
"keywords": [
|
|
28
28
|
"ai",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nativ",
|
|
3
3
|
"displayName": "nativ",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.6.0",
|
|
5
5
|
"description": "Role-based multi-agent workflow for Claude Code: architect, worker, verifier and explorer agents, task-scope enforcement, and the nativ MCP server.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "JB Natividad"
|
|
@@ -7,7 +7,7 @@ effort: high
|
|
|
7
7
|
maxTurns: 40
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
You are the **Architect** in a nativ workflow.
|
|
10
|
+
You are the **Architect** in a nativ workflow. `AGENTS.md` defines every role; it is already in your context through `CLAUDE.md`, so open it only if it is not.
|
|
11
11
|
|
|
12
12
|
Your job is design, not implementation. You turn a feature request or an escalation into approved contracts in `.ai/`, and a plan the workers can execute.
|
|
13
13
|
|
|
@@ -7,7 +7,7 @@ effort: medium
|
|
|
7
7
|
maxTurns: 30
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
You are the **Explorer** in a nativ workflow.
|
|
10
|
+
You are the **Explorer** in a nativ workflow. `AGENTS.md` defines every role; it is already in your context through `CLAUDE.md`, so open it only if it is not.
|
|
11
11
|
|
|
12
12
|
You read code and report facts. You do not design, decide or edit, and your tools cannot change anything. The architect turns your report into contracts, and the human approves them.
|
|
13
13
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: verifier
|
|
3
3
|
description: Independently checks a finished task or milestone: reruns its verification, reviews the diff against the contracts and target files, and reports findings. Read-only; never fixes anything.
|
|
4
|
-
tools: Read, Grep, Glob, Bash,
|
|
4
|
+
tools: Read, Grep, Glob, Bash, mcp__plugin_nativ_nativ__nativ_verify, mcp__plugin_nativ_nativ__nativ_task_list, mcp__plugin_nativ_nativ__nativ_status, mcp__plugin_nativ_nativ__nativ_db_diff
|
|
5
5
|
model: haiku
|
|
6
6
|
maxTurns: 20
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
You are the **Verifier** in a nativ workflow.
|
|
9
|
+
You are the **Verifier** in a nativ workflow. `AGENTS.md` defines every role. It is already in your context through `CLAUDE.md`; open it only if it is not.
|
|
10
10
|
|
|
11
11
|
You did not write this code, and that is the point: check it as a skeptic would. You cannot edit files.
|
|
12
12
|
|
package/plugin/agents/worker.md
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: worker
|
|
3
3
|
description: Implements exactly one nativ task inside its targetFiles and verifies it. Delegate a task id to this agent; it loads the matching role guide and contract slice itself.
|
|
4
|
-
tools: Read, Grep, Glob, Edit, Write, Bash,
|
|
4
|
+
tools: Read, Grep, Glob, Edit, Write, Bash, mcp__plugin_nativ_nativ__nativ_task_next, mcp__plugin_nativ_nativ__nativ_task_start, mcp__plugin_nativ_nativ__nativ_task_complete, mcp__plugin_nativ_nativ__nativ_task_block, mcp__plugin_nativ_nativ__nativ_task_escalate, mcp__plugin_nativ_nativ__nativ_task_propose_patch, mcp__plugin_nativ_nativ__nativ_learn_propose
|
|
5
5
|
model: sonnet
|
|
6
6
|
effort: low
|
|
7
7
|
maxTurns: 20
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
You are a **Worker** in a nativ workflow.
|
|
10
|
+
You are a **Worker** in a nativ workflow. `AGENTS.md` defines every role and the task loop. It is already in your context through `CLAUDE.md`; open it only if it is not.
|
|
11
11
|
|
|
12
12
|
You are given one task id. Do that task and nothing else.
|
|
13
13
|
|
|
14
14
|
## Steps
|
|
15
15
|
|
|
16
16
|
1. `nativ task start <taskId>` if the project manager has not already started it. Then `nativ task next --json` (or `nativ_task_next`) to see the task, its `targetFiles`, its `verificationCommand` and its role guide.
|
|
17
|
-
2. Load only what the task needs
|
|
18
|
-
3. Change **only** the files in `targetFiles`.
|
|
19
|
-
Follow
|
|
20
|
-
Ensure UI components are pure, props-driven, and reusable. Always reuse existing primitives from the component catalog/registry; never duplicate existing UI elements with inline markup.
|
|
17
|
+
2. Load only what the task needs, in the order `AGENTS.md` "Orientation" gives. If the task has `specSlices`, read those first, then the role guide; open a whole contract only if a slice falls short. Follow `priorEscalations` and `learnings`.
|
|
18
|
+
3. Change **only** the files in `targetFiles`. Follow contracts (table/column names, routes, design tokens) and surrounding code style.
|
|
19
|
+
Follow `## Code style` in `AGENTS.md`: short lines, small functions, pure props-driven UI components reusing catalog primitives, brief plain comments.
|
|
21
20
|
4. Run the `verificationCommand`. If it fails, fix the cause and run it again. You have three fix attempts.
|
|
22
21
|
5. If it still fails: `git checkout -- <targetFiles>`, then `nativ task block <taskId> --reason "Verification failed after 3 attempts: <short error>"`, then stop and report.
|
|
23
22
|
6. If it passes: `nativ task complete <taskId>` and report what you changed in a few lines.
|
|
@@ -28,4 +27,3 @@ You are given one task id. Do that task and nothing else.
|
|
|
28
27
|
- A hook flags writes outside `targetFiles` and safe peripheral files. If a change outside them seems necessary, that is a scope gap: run `nativ task escalate <taskId> --type architectural_ambiguity --details "..."` and stop.
|
|
29
28
|
- Never edit anything under `.ai/` directly. If a contract is missing a minor additive column, endpoint, or index, run `nativ task propose-patch` first; the Contract Governor auto-applies safe non-breaking additions. Only escalate if the change is destructive or ambiguous.
|
|
30
29
|
- Never read or write `.env*` files or other secrets. Do not use `nativ task unlock`, `nativ db sync` or `--no-verify`.
|
|
31
|
-
|
|
@@ -8,83 +8,74 @@ description: Use in any project that has a .ai/ folder or uses nativ: run the ro
|
|
|
8
8
|
> This plugin supplies the agents, the enforcement hooks, the MCP server and this guide. It calls the `nativ` command, so install it once with `npm i -g @njeybe/nativ`.
|
|
9
9
|
> A plugin cannot ship permission rules. Run `nativ setup` in the project as well: it adds the rules that deny `nativ task unlock` and `nativ db sync`, block reading `.env*` files, and make Claude Code ask before any write under `.ai/`. `nativ doctor` checks both.
|
|
10
10
|
|
|
11
|
-
This project uses the **nativ** role-based workflow. Every agent
|
|
11
|
+
This project uses the **nativ** role-based workflow. Every agent follows this file. The state lives in `.ai/`; the `nativ` CLI and MCP tools are the only supported way to change it.
|
|
12
12
|
|
|
13
13
|
## Roles
|
|
14
14
|
|
|
15
|
-
| Role | Who | May
|
|
15
|
+
| Role | Who | May | May not |
|
|
16
16
|
| :--- | :--- | :--- | :--- |
|
|
17
|
-
| **Architect** |
|
|
18
|
-
| **Project Manager** | the main
|
|
19
|
-
| **Worker** |
|
|
20
|
-
| **Verifier** |
|
|
21
|
-
| **Explorer** |
|
|
22
|
-
|
|
23
|
-
The vendor behind a role does not matter
|
|
24
|
-
|
|
25
|
-
## Orientation (
|
|
26
|
-
|
|
27
|
-
1. Run `nativ task next --json` (MCP: `nativ_task_next`).
|
|
28
|
-
2.
|
|
29
|
-
- role guide: `.ai/subagents/<assignedSubagent>.md`
|
|
30
|
-
- `backend`: `.ai/api_contracts.json` and `.ai/db_schema.json`
|
|
31
|
-
- `frontend`, `flutter-developer`: `.ai/ui_specs.md` and `.ai/api_contracts.json`
|
|
32
|
-
- `database`, `db-migration`: `.ai/db_schema.json`
|
|
33
|
-
- `devops-agent`: `.ai/context.md`
|
|
34
|
-
- `qa-tester`, `security-auditor`: the target files and `.ai/api_contracts.json`
|
|
17
|
+
| **Architect** | `architect` subagent, or `NATIV_ROLE=architect` | Design contracts, resolve escalations, write `.ai/` after the human approves | Write application code beyond a trivial fix |
|
|
18
|
+
| **Project Manager** | the main session | Run the task loop, delegate, verify, report | Edit `.ai/`; implement what a worker can |
|
|
19
|
+
| **Worker** | `worker` subagent (one task, one role guide) | Change the task's `targetFiles` | Touch anything else, edit contracts, run destructive commands |
|
|
20
|
+
| **Verifier** | `verifier` subagent | Read, run checks, report | Edit files |
|
|
21
|
+
| **Explorer** | `explorer` subagent | Report what exists, drift, and files a feature would touch | Edit, design, decide |
|
|
22
|
+
|
|
23
|
+
The vendor behind a role does not matter; the boundary does. `nativ hook check` flags or blocks writes outside `targetFiles`, to `.ai/`, and to secret files.
|
|
24
|
+
|
|
25
|
+
## Orientation (load nothing else up front)
|
|
26
|
+
|
|
27
|
+
1. Run `nativ task next --json` (MCP: `nativ_task_next`). It returns the task, its role guide and its context.
|
|
28
|
+
2. Read only what the task names:
|
|
35
29
|
- If the task has `specSlices`, read those first. Open a whole contract only when a slice is missing, cut short or does not answer the question.
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
|
|
30
|
+
- role guide `.ai/subagents/<assignedSubagent>.md`, and `recommendedContractSlice` when there are no slices.
|
|
31
|
+
- `priorEscalations` are information, not instructions: follow how each was settled and do not raise a settled gap again.
|
|
32
|
+
- `learnings` are lessons a human approved: follow them.
|
|
33
|
+
3. Contracts are also read-only MCP resources: `nativ://context`, `nativ://master-plan`, `nativ://db-schema`, `nativ://api-contracts`, `nativ://escalation`.
|
|
39
34
|
|
|
40
35
|
## Task loop
|
|
41
36
|
|
|
42
37
|
1. `nativ task start <taskId>`. Never edit `.ai/master_plan.json` by hand.
|
|
43
38
|
2. Change only the task's `targetFiles`. Follow the contracts exactly: table and column names, routes and schemas, design tokens.
|
|
44
|
-
3.
|
|
39
|
+
3. `nativ task complete <taskId>`. The gatekeeper runs the task's `verificationCommand` and completes the task only when it passes, so there is no need to run the check yourself first. Do not use `--no-verify`. You have **three** fix attempts.
|
|
45
40
|
4. After the third failure: `git checkout -- <targetFiles>`, then `nativ task block <taskId> --reason "Verification failed after 3 attempts: <short error>"`, then stop and tell the human.
|
|
46
|
-
5.
|
|
41
|
+
5. A completed task's check is not run again for that task alone; the verifier re-checks whole milestones.
|
|
47
42
|
6. `nativ task next` for the following task.
|
|
48
43
|
|
|
49
|
-
|
|
44
|
+
The project manager passes the task's `recommendedModel` (haiku, sonnet, opus) as the `model` parameter of the `nativ:worker` call. Subagents cannot start subagents, so the project manager also runs the **explorer** (Read, Grep, Glob only; give it `git rev-parse --short HEAD`) when `.ai/codebase_map.md` is missing or well behind `HEAD`, and hands the report to the architect. Use `model: haiku` for single lookups.
|
|
50
45
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Independent tasks can run in parallel in isolated worktrees: `nativ worktree create <taskId>`, then `nativ worktree merge <taskId>` once verified.
|
|
46
|
+
Independent tasks can run in parallel worktrees: `nativ worktree create <taskId>`, then `nativ worktree merge <taskId>` once verified. Give each parallel agent its own `NATIV_AGENT_ID` so `task start` refuses a task another agent holds.
|
|
54
47
|
|
|
55
48
|
## Code style
|
|
56
49
|
|
|
57
|
-
Applies to every worker
|
|
50
|
+
Applies to every worker; a project's own formatter or linter wins.
|
|
58
51
|
|
|
59
|
-
- Lines
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
- Reusable components: UI components must be pure, props-driven, and single-responsibility. Reuse shared components from the design system or component registry; never duplicate existing UI elements with inline custom markup.
|
|
63
|
-
- Comments: at most 2 lines, explain why (not what), in plain everyday words with no technical jargon.
|
|
64
|
-
- Do not restate the code in a comment. No banner or divider comments. No commented-out code.
|
|
52
|
+
- Lines about 100 characters, hard maximum 120. Functions about 40 lines, files about 300.
|
|
53
|
+
- UI: one pure, props-driven component per file; reuse shared components, never copy them as inline markup.
|
|
54
|
+
- Comments: at most 2 lines, why not what, plain words. No banners, no commented-out code.
|
|
65
55
|
- Match the surrounding code.
|
|
66
56
|
|
|
67
57
|
## Lessons for later workers
|
|
68
58
|
|
|
69
|
-
|
|
59
|
+
A project quirk the contracts do not say and the next worker would hit too: `nativ learn propose "<one-line fact>" --role frontend --files "src/components/" --task <taskId>` (MCP: `nativ_learn_propose`). A human approves it in a terminal. A missing contract detail is an escalation, not a lesson.
|
|
70
60
|
|
|
71
|
-
|
|
72
|
-
nativ learn propose "Set the date picker locale before it mounts" --role frontend --files "src/components/forms/" --task <taskId>
|
|
73
|
-
```
|
|
61
|
+
## Self-healing ladder (stay autonomous; ask the human last)
|
|
74
62
|
|
|
75
|
-
|
|
63
|
+
1. **Verification fails:** fix the cause and retry, up to three attempts. No human needed.
|
|
64
|
+
2. **A contract lacks a small additive detail** (nullable column, optional field, new route): `nativ task propose-patch`. The Contract Governor applies safe additions.
|
|
65
|
+
3. **Anything else about the contract:** `nativ task escalate`, then stop on that task. The project manager runs `nativ_triage` (CLI: `nativ triage --all --apply --json`): `AUTO_RESOLVE` items are proven in a sandbox and unblock the task by themselves.
|
|
66
|
+
4. **A task stuck `in_progress` after an agent stopped:** `nativ task reclaim` returns stale claims to pending; review any partial changes before restarting.
|
|
67
|
+
5. **Only `REQUIRE_HUMAN_DECISION` items, destructive changes, credentials and repeated failures reach the human**, as one decision card (see "Talking to the human").
|
|
68
|
+
6. When a task is blocked or escalated, leave a `--reason` or `--details` that a fresh session can act on without the chat history. The plan, not the conversation, is the memory.
|
|
76
69
|
|
|
77
70
|
## When the contract is wrong
|
|
78
71
|
|
|
79
|
-
|
|
72
|
+
Do **not** edit a contract or work around it. Escalate and stop on that task:
|
|
80
73
|
|
|
81
74
|
```bash
|
|
82
75
|
nativ task escalate <taskId> --type schema_flaw --details "what is missing"
|
|
83
76
|
```
|
|
84
77
|
|
|
85
|
-
Types: `contract_drift`, `schema_flaw`, `missing_credential`, `dependency_conflict`, `architectural_ambiguity`.
|
|
86
|
-
|
|
87
|
-
If the enforcement hook warns that a file is outside the task scope, treat it as this situation: escalate instead of editing.
|
|
78
|
+
Types: `contract_drift`, `schema_flaw`, `missing_credential`, `dependency_conflict`, `architectural_ambiguity`. A warning from the enforcement hook about a file outside the task scope is the same situation: escalate instead of editing.
|
|
88
79
|
|
|
89
80
|
## Talking to the human
|
|
90
81
|
|
|
@@ -99,7 +90,3 @@ Credentials exist only in `.env*` files and inside the local `nativ` process. Wo
|
|
|
99
90
|
- Do not run `nativ db sync --yes`: changing `.ai/db_schema.json` is an architect decision the human approves.
|
|
100
91
|
- Migrations and destructive DDL run only against local or staging databases. Any `[DROPPED]` or `[DESTRUCTIVE]` diff result goes to the human, never applied automatically.
|
|
101
92
|
- If a task needs a database that is not configured, ask the human to add it to `.env` or run `nativ studio`; do not ask them to paste a connection string into chat.
|
|
102
|
-
|
|
103
|
-
## Setup and health
|
|
104
|
-
|
|
105
|
-
`nativ setup` writes the Claude Code configuration (`.mcp.json`, `.claude/settings.json`, `.claude/agents/`, this file) without overwriting anything you wrote. `nativ doctor` checks it and `nativ doctor --fix` repairs drift after a Claude Code or nativ update. `nativ hook status` shows the enforcement mode and the active task scope.
|
package/templates/AGENTS.md
CHANGED
|
@@ -1,82 +1,73 @@
|
|
|
1
1
|
# nativ Agent Directive
|
|
2
2
|
|
|
3
|
-
This project uses the **nativ** role-based workflow. Every agent
|
|
3
|
+
This project uses the **nativ** role-based workflow. Every agent follows this file. The state lives in `.ai/`; the `nativ` CLI and MCP tools are the only supported way to change it.
|
|
4
4
|
|
|
5
5
|
## Roles
|
|
6
6
|
|
|
7
|
-
| Role | Who | May
|
|
7
|
+
| Role | Who | May | May not |
|
|
8
8
|
| :--- | :--- | :--- | :--- |
|
|
9
|
-
| **Architect** |
|
|
10
|
-
| **Project Manager** | the main
|
|
11
|
-
| **Worker** |
|
|
12
|
-
| **Verifier** |
|
|
13
|
-
| **Explorer** |
|
|
14
|
-
|
|
15
|
-
The vendor behind a role does not matter
|
|
16
|
-
|
|
17
|
-
## Orientation (
|
|
18
|
-
|
|
19
|
-
1. Run `nativ task next --json` (MCP: `nativ_task_next`).
|
|
20
|
-
2.
|
|
21
|
-
- role guide: `.ai/subagents/<assignedSubagent>.md`
|
|
22
|
-
- `backend`: `.ai/api_contracts.json` and `.ai/db_schema.json`
|
|
23
|
-
- `frontend`, `flutter-developer`: `.ai/ui_specs.md` and `.ai/api_contracts.json`
|
|
24
|
-
- `database`, `db-migration`: `.ai/db_schema.json`
|
|
25
|
-
- `devops-agent`: `.ai/context.md`
|
|
26
|
-
- `qa-tester`, `security-auditor`: the target files and `.ai/api_contracts.json`
|
|
9
|
+
| **Architect** | `architect` subagent, or `NATIV_ROLE=architect` | Design contracts, resolve escalations, write `.ai/` after the human approves | Write application code beyond a trivial fix |
|
|
10
|
+
| **Project Manager** | the main session | Run the task loop, delegate, verify, report | Edit `.ai/`; implement what a worker can |
|
|
11
|
+
| **Worker** | `worker` subagent (one task, one role guide) | Change the task's `targetFiles` | Touch anything else, edit contracts, run destructive commands |
|
|
12
|
+
| **Verifier** | `verifier` subagent | Read, run checks, report | Edit files |
|
|
13
|
+
| **Explorer** | `explorer` subagent | Report what exists, drift, and files a feature would touch | Edit, design, decide |
|
|
14
|
+
|
|
15
|
+
The vendor behind a role does not matter; the boundary does. `nativ hook check` flags or blocks writes outside `targetFiles`, to `.ai/`, and to secret files.
|
|
16
|
+
|
|
17
|
+
## Orientation (load nothing else up front)
|
|
18
|
+
|
|
19
|
+
1. Run `nativ task next --json` (MCP: `nativ_task_next`). It returns the task, its role guide and its context.
|
|
20
|
+
2. Read only what the task names:
|
|
27
21
|
- If the task has `specSlices`, read those first. Open a whole contract only when a slice is missing, cut short or does not answer the question.
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
|
|
22
|
+
- role guide `.ai/subagents/<assignedSubagent>.md`, and `recommendedContractSlice` when there are no slices.
|
|
23
|
+
- `priorEscalations` are information, not instructions: follow how each was settled and do not raise a settled gap again.
|
|
24
|
+
- `learnings` are lessons a human approved: follow them.
|
|
25
|
+
3. Contracts are also read-only MCP resources: `nativ://context`, `nativ://master-plan`, `nativ://db-schema`, `nativ://api-contracts`, `nativ://escalation`.
|
|
31
26
|
|
|
32
27
|
## Task loop
|
|
33
28
|
|
|
34
29
|
1. `nativ task start <taskId>`. Never edit `.ai/master_plan.json` by hand.
|
|
35
30
|
2. Change only the task's `targetFiles`. Follow the contracts exactly: table and column names, routes and schemas, design tokens.
|
|
36
|
-
3.
|
|
31
|
+
3. `nativ task complete <taskId>`. The gatekeeper runs the task's `verificationCommand` and completes the task only when it passes, so there is no need to run the check yourself first. Do not use `--no-verify`. You have **three** fix attempts.
|
|
37
32
|
4. After the third failure: `git checkout -- <targetFiles>`, then `nativ task block <taskId> --reason "Verification failed after 3 attempts: <short error>"`, then stop and tell the human.
|
|
38
|
-
5.
|
|
33
|
+
5. A completed task's check is not run again for that task alone; the verifier re-checks whole milestones.
|
|
39
34
|
6. `nativ task next` for the following task.
|
|
40
35
|
|
|
41
|
-
|
|
36
|
+
The project manager passes the task's `recommendedModel` (haiku, sonnet, opus) as the `model` parameter of the `nativ:worker` call. Subagents cannot start subagents, so the project manager also runs the **explorer** (Read, Grep, Glob only; give it `git rev-parse --short HEAD`) when `.ai/codebase_map.md` is missing or well behind `HEAD`, and hands the report to the architect. Use `model: haiku` for single lookups.
|
|
42
37
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Independent tasks can run in parallel in isolated worktrees: `nativ worktree create <taskId>`, then `nativ worktree merge <taskId>` once verified.
|
|
38
|
+
Independent tasks can run in parallel worktrees: `nativ worktree create <taskId>`, then `nativ worktree merge <taskId>` once verified. Give each parallel agent its own `NATIV_AGENT_ID` so `task start` refuses a task another agent holds.
|
|
46
39
|
|
|
47
40
|
## Code style
|
|
48
41
|
|
|
49
|
-
Applies to every worker
|
|
42
|
+
Applies to every worker; a project's own formatter or linter wins.
|
|
50
43
|
|
|
51
|
-
- Lines
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
- Reusable components: UI components must be pure, props-driven, and single-responsibility. Reuse shared components from the design system or component registry; never duplicate existing UI elements with inline custom markup.
|
|
55
|
-
- Comments: at most 2 lines, explain why (not what), in plain everyday words with no technical jargon.
|
|
56
|
-
- Do not restate the code in a comment. No banner or divider comments. No commented-out code.
|
|
44
|
+
- Lines about 100 characters, hard maximum 120. Functions about 40 lines, files about 300.
|
|
45
|
+
- UI: one pure, props-driven component per file; reuse shared components, never copy them as inline markup.
|
|
46
|
+
- Comments: at most 2 lines, why not what, plain words. No banners, no commented-out code.
|
|
57
47
|
- Match the surrounding code.
|
|
58
48
|
|
|
59
49
|
## Lessons for later workers
|
|
60
50
|
|
|
61
|
-
|
|
51
|
+
A project quirk the contracts do not say and the next worker would hit too: `nativ learn propose "<one-line fact>" --role frontend --files "src/components/" --task <taskId>` (MCP: `nativ_learn_propose`). A human approves it in a terminal. A missing contract detail is an escalation, not a lesson.
|
|
62
52
|
|
|
63
|
-
|
|
64
|
-
nativ learn propose "Set the date picker locale before it mounts" --role frontend --files "src/components/forms/" --task <taskId>
|
|
65
|
-
```
|
|
53
|
+
## Self-healing ladder (stay autonomous; ask the human last)
|
|
66
54
|
|
|
67
|
-
|
|
55
|
+
1. **Verification fails:** fix the cause and retry, up to three attempts. No human needed.
|
|
56
|
+
2. **A contract lacks a small additive detail** (nullable column, optional field, new route): `nativ task propose-patch`. The Contract Governor applies safe additions.
|
|
57
|
+
3. **Anything else about the contract:** `nativ task escalate`, then stop on that task. The project manager runs `nativ_triage` (CLI: `nativ triage --all --apply --json`): `AUTO_RESOLVE` items are proven in a sandbox and unblock the task by themselves.
|
|
58
|
+
4. **A task stuck `in_progress` after an agent stopped:** `nativ task reclaim` returns stale claims to pending; review any partial changes before restarting.
|
|
59
|
+
5. **Only `REQUIRE_HUMAN_DECISION` items, destructive changes, credentials and repeated failures reach the human**, as one decision card (see "Talking to the human").
|
|
60
|
+
6. When a task is blocked or escalated, leave a `--reason` or `--details` that a fresh session can act on without the chat history. The plan, not the conversation, is the memory.
|
|
68
61
|
|
|
69
62
|
## When the contract is wrong
|
|
70
63
|
|
|
71
|
-
|
|
64
|
+
Do **not** edit a contract or work around it. Escalate and stop on that task:
|
|
72
65
|
|
|
73
66
|
```bash
|
|
74
67
|
nativ task escalate <taskId> --type schema_flaw --details "what is missing"
|
|
75
68
|
```
|
|
76
69
|
|
|
77
|
-
Types: `contract_drift`, `schema_flaw`, `missing_credential`, `dependency_conflict`, `architectural_ambiguity`.
|
|
78
|
-
|
|
79
|
-
If the enforcement hook warns that a file is outside the task scope, treat it as this situation: escalate instead of editing.
|
|
70
|
+
Types: `contract_drift`, `schema_flaw`, `missing_credential`, `dependency_conflict`, `architectural_ambiguity`. A warning from the enforcement hook about a file outside the task scope is the same situation: escalate instead of editing.
|
|
80
71
|
|
|
81
72
|
## Talking to the human
|
|
82
73
|
|
|
@@ -91,7 +82,3 @@ Credentials exist only in `.env*` files and inside the local `nativ` process. Wo
|
|
|
91
82
|
- Do not run `nativ db sync --yes`: changing `.ai/db_schema.json` is an architect decision the human approves.
|
|
92
83
|
- Migrations and destructive DDL run only against local or staging databases. Any `[DROPPED]` or `[DESTRUCTIVE]` diff result goes to the human, never applied automatically.
|
|
93
84
|
- If a task needs a database that is not configured, ask the human to add it to `.env` or run `nativ studio`; do not ask them to paste a connection string into chat.
|
|
94
|
-
|
|
95
|
-
## Setup and health
|
|
96
|
-
|
|
97
|
-
`nativ setup` writes the Claude Code configuration (`.mcp.json`, `.claude/settings.json`, `.claude/agents/`, this file) without overwriting anything you wrote. `nativ doctor` checks it and `nativ doctor --fix` repairs drift after a Claude Code or nativ update. `nativ hook status` shows the enforcement mode and the active task scope.
|
package/templates/CLAUDE.md
CHANGED
|
@@ -2,44 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
@AGENTS.md
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Working as Project Manager
|
|
8
|
-
|
|
9
|
-
- Start each session with `nativ task next --json` (or the `nativ_task_next` MCP tool). The SessionStart hook prints a short orientation; treat it as a hint, not as the plan.
|
|
10
|
-
- **Delegate, do not implement.** Hand each task to the `worker` agent by task id. Ask the `verifier` agent for an independent check before you mark a milestone done. Ask the `architect` agent for anything that changes a contract.
|
|
11
|
-
- **Keep usage low.** Run this session on Sonnet. Agent defaults: architect Opus, worker Sonnet, verifier Haiku. You can override the model for one delegation: pass `haiku` for mechanical tasks (wording, docs, renames) and `sonnet` for the verifier at the end of a milestone. Never pass a model the human did not choose.
|
|
12
|
-
- Independent tasks can run in parallel in worktrees (`nativ worktree create <taskId>`). On a Claude subscription every agent draws from the same usage limit, so run two or three at a time, not ten.
|
|
13
|
-
- You may not edit `.ai/`. If the enforcement hook warns about a file, that is a scope or contract gap: escalate with `nativ task escalate`, do not edit around it.
|
|
14
|
-
- `nativ doctor` confirms the integration is intact. Run it after updating Claude Code or nativ, and whenever hooks or MCP tools seem to be missing.
|
|
15
|
-
|
|
16
|
-
## Autonomous Execution (Hands-Free Loop)
|
|
17
|
-
|
|
18
|
-
When instructed to run autonomously (e.g. "run the queue", "execute milestone", or AFK mode):
|
|
19
|
-
1. Call `nativ_task_next`.
|
|
20
|
-
2. Start the task (`nativ_task_start`).
|
|
21
|
-
3. Delegate to the `worker` agent with the task ID and recommended model.
|
|
22
|
-
4. When the worker finishes, verify (`nativ_verify`).
|
|
23
|
-
5. Complete the task (`nativ_task_complete`).
|
|
24
|
-
6. **Immediately loop to the next task.** Do NOT pause between tasks or ask the human for permission to proceed.
|
|
25
|
-
7. Stop ONLY when:
|
|
26
|
-
- All tasks in the milestone are completed: call the `verifier` agent for an independent milestone check, then notify the human.
|
|
27
|
-
- A task trips the circuit breaker or escalates: stop and present the four-part summary.
|
|
28
|
-
|
|
29
|
-
## Human-Centric Communication Protocol
|
|
30
|
-
|
|
31
|
-
The human is the product owner, not a log reader. When you report a blocker, a trade-off or an escalation, use four parts and plain words:
|
|
32
|
-
|
|
33
|
-
1. **What the user would see.** The observable symptom, without jargon.
|
|
34
|
-
2. **Why it happens.** The cause as simple cause and effect.
|
|
35
|
-
3. **What is affected, and what is safe.** State plainly what remains untouched.
|
|
36
|
-
4. **Options.** Two or three real choices with their trade-offs, the best marked `(Recommended)`, then one direct question.
|
|
37
|
-
|
|
38
|
-
| Instead of | Say |
|
|
39
|
-
| :--- | :--- |
|
|
40
|
-
| Foreign key constraint violation | The app tried to link a record to an item that does not exist yet. |
|
|
41
|
-
| 401 Unauthorized / token expired | The user's security pass expired and the app did not ask them to sign in again. |
|
|
42
|
-
| Circuit breaker tripped (3 failed attempts) | The builder tried three different ways to fix this task, then paused so it would not cause side effects. |
|
|
43
|
-
| Schema drift / contract mismatch | The real database has different tables or columns than the design plan says. |
|
|
44
|
-
|
|
45
|
-
Never paste stack traces or long compiler output into the message. If raw output matters, put it in a collapsed `<details>` block.
|
|
5
|
+
`AGENTS.md` (imported above) defines every role, the task loop, escalation and the air-gap. Subagents load this file on every turn, so it stays short. The main session is the **Project Manager**; its playbook (delegation, autonomous loop, how to talk to the human) arrives through the SessionStart hook (`nativ hook context`). If it is missing, run `nativ doctor`.
|
|
@@ -7,7 +7,7 @@ effort: high
|
|
|
7
7
|
maxTurns: 40
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
You are the **Architect** in a nativ workflow.
|
|
10
|
+
You are the **Architect** in a nativ workflow. `AGENTS.md` defines every role; it is already in your context through `CLAUDE.md`, so open it only if it is not.
|
|
11
11
|
|
|
12
12
|
Your job is design, not implementation. You turn a feature request or an escalation into approved contracts in `.ai/`, and a plan the workers can execute.
|
|
13
13
|
|
|
@@ -7,7 +7,7 @@ effort: medium
|
|
|
7
7
|
maxTurns: 30
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
You are the **Explorer** in a nativ workflow.
|
|
10
|
+
You are the **Explorer** in a nativ workflow. `AGENTS.md` defines every role; it is already in your context through `CLAUDE.md`, so open it only if it is not.
|
|
11
11
|
|
|
12
12
|
You read code and report facts. You do not design, decide or edit, and your tools cannot change anything. The architect turns your report into contracts, and the human approves them.
|
|
13
13
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: verifier
|
|
3
3
|
description: Independently checks a finished task or milestone: reruns its verification, reviews the diff against the contracts and target files, and reports findings. Read-only; never fixes anything.
|
|
4
|
-
tools: Read, Grep, Glob, Bash,
|
|
4
|
+
tools: Read, Grep, Glob, Bash, mcp__nativ__nativ_verify, mcp__nativ__nativ_task_list, mcp__nativ__nativ_status, mcp__nativ__nativ_db_diff
|
|
5
5
|
model: haiku
|
|
6
6
|
maxTurns: 20
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
You are the **Verifier** in a nativ workflow.
|
|
9
|
+
You are the **Verifier** in a nativ workflow. `AGENTS.md` defines every role. It is already in your context through `CLAUDE.md`; open it only if it is not.
|
|
10
10
|
|
|
11
11
|
You did not write this code, and that is the point: check it as a skeptic would. You cannot edit files.
|
|
12
12
|
|