@njeybe/nativ 2.0.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.
Files changed (140) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/LICENSE +21 -0
  3. package/README.md +334 -0
  4. package/bin/cli.js +31 -0
  5. package/dist/commands/bench.d.ts +8 -0
  6. package/dist/commands/bench.js +52 -0
  7. package/dist/commands/db.d.ts +22 -0
  8. package/dist/commands/db.js +415 -0
  9. package/dist/commands/doctor.d.ts +38 -0
  10. package/dist/commands/doctor.js +169 -0
  11. package/dist/commands/hook.d.ts +31 -0
  12. package/dist/commands/hook.js +105 -0
  13. package/dist/commands/init.d.ts +3 -0
  14. package/dist/commands/init.js +144 -0
  15. package/dist/commands/mcp.d.ts +5 -0
  16. package/dist/commands/mcp.js +16 -0
  17. package/dist/commands/setup.d.ts +17 -0
  18. package/dist/commands/setup.js +51 -0
  19. package/dist/commands/status.d.ts +5 -0
  20. package/dist/commands/status.js +75 -0
  21. package/dist/commands/task.d.ts +83 -0
  22. package/dist/commands/task.js +807 -0
  23. package/dist/commands/test-gen.d.ts +14 -0
  24. package/dist/commands/test-gen.js +52 -0
  25. package/dist/commands/triage.d.ts +70 -0
  26. package/dist/commands/triage.js +343 -0
  27. package/dist/commands/update.d.ts +14 -0
  28. package/dist/commands/update.js +112 -0
  29. package/dist/commands/validate.d.ts +1 -0
  30. package/dist/commands/validate.js +89 -0
  31. package/dist/commands/verify.d.ts +8 -0
  32. package/dist/commands/verify.js +65 -0
  33. package/dist/commands/worktree.d.ts +47 -0
  34. package/dist/commands/worktree.js +396 -0
  35. package/dist/core/benchmark.d.ts +57 -0
  36. package/dist/core/benchmark.js +772 -0
  37. package/dist/core/enforcement.d.ts +80 -0
  38. package/dist/core/enforcement.js +271 -0
  39. package/dist/core/legacy-templates.d.ts +24 -0
  40. package/dist/core/legacy-templates.js +60 -0
  41. package/dist/core/lock-manager.d.ts +54 -0
  42. package/dist/core/lock-manager.js +260 -0
  43. package/dist/core/root-resolver.d.ts +32 -0
  44. package/dist/core/root-resolver.js +149 -0
  45. package/dist/core/setup-assets.d.ts +123 -0
  46. package/dist/core/setup-assets.js +438 -0
  47. package/dist/core/telemetry.d.ts +156 -0
  48. package/dist/core/telemetry.js +416 -0
  49. package/dist/core/test-generator-types.d.ts +227 -0
  50. package/dist/core/test-generator-types.js +179 -0
  51. package/dist/core/test-generator.d.ts +34 -0
  52. package/dist/core/test-generator.js +1690 -0
  53. package/dist/core/tier1-liaison.d.ts +139 -0
  54. package/dist/core/tier1-liaison.js +320 -0
  55. package/dist/core/verifier.d.ts +52 -0
  56. package/dist/core/verifier.js +249 -0
  57. package/dist/core/version.d.ts +5 -0
  58. package/dist/core/version.js +14 -0
  59. package/dist/core/worktree-merge.d.ts +30 -0
  60. package/dist/core/worktree-merge.js +98 -0
  61. package/dist/db/data-engine.d.ts +46 -0
  62. package/dist/db/data-engine.js +802 -0
  63. package/dist/db/diff.d.ts +39 -0
  64. package/dist/db/diff.js +420 -0
  65. package/dist/db/env-parser.d.ts +86 -0
  66. package/dist/db/env-parser.js +549 -0
  67. package/dist/db/introspector.d.ts +21 -0
  68. package/dist/db/introspector.js +835 -0
  69. package/dist/db/types.d.ts +217 -0
  70. package/dist/db/types.js +9 -0
  71. package/dist/governor/circuit-breaker.d.ts +100 -0
  72. package/dist/governor/circuit-breaker.js +231 -0
  73. package/dist/governor/evaluator.d.ts +67 -0
  74. package/dist/governor/evaluator.js +851 -0
  75. package/dist/governor/index.d.ts +6 -0
  76. package/dist/governor/index.js +6 -0
  77. package/dist/governor/rules/api-rules.d.ts +2 -0
  78. package/dist/governor/rules/api-rules.js +140 -0
  79. package/dist/governor/rules/db-rules.d.ts +2 -0
  80. package/dist/governor/rules/db-rules.js +180 -0
  81. package/dist/governor/store.d.ts +33 -0
  82. package/dist/governor/store.js +84 -0
  83. package/dist/governor/types.d.ts +64 -0
  84. package/dist/governor/types.js +1 -0
  85. package/dist/index.d.ts +3 -0
  86. package/dist/index.js +358 -0
  87. package/dist/mcp/server.d.ts +3 -0
  88. package/dist/mcp/server.js +309 -0
  89. package/dist/providers/claude-api.d.ts +5 -0
  90. package/dist/providers/claude-api.js +75 -0
  91. package/dist/providers/claude-cli.d.ts +13 -0
  92. package/dist/providers/claude-cli.js +134 -0
  93. package/dist/providers/gemini.d.ts +8 -0
  94. package/dist/providers/gemini.js +78 -0
  95. package/dist/providers/index.d.ts +5 -0
  96. package/dist/providers/index.js +5 -0
  97. package/dist/providers/registry.d.ts +38 -0
  98. package/dist/providers/registry.js +121 -0
  99. package/dist/providers/types.d.ts +74 -0
  100. package/dist/providers/types.js +25 -0
  101. package/dist/runner/agent-supervisor.d.ts +363 -0
  102. package/dist/runner/agent-supervisor.js +1672 -0
  103. package/dist/scanner/context-builder.d.ts +2 -0
  104. package/dist/scanner/context-builder.js +29 -0
  105. package/dist/scanner/detector.d.ts +2 -0
  106. package/dist/scanner/detector.js +760 -0
  107. package/dist/scanner/types.d.ts +80 -0
  108. package/dist/scanner/types.js +50 -0
  109. package/dist/server/studio-server.d.ts +39 -0
  110. package/dist/server/studio-server.js +1931 -0
  111. package/dist/server/studio-ui.d.ts +15 -0
  112. package/dist/server/studio-ui.js +5321 -0
  113. package/package.json +70 -0
  114. package/plugin/.claude-plugin/plugin.json +18 -0
  115. package/plugin/.mcp.json +10 -0
  116. package/plugin/agents/architect.md +28 -0
  117. package/plugin/agents/verifier.md +28 -0
  118. package/plugin/agents/worker.md +26 -0
  119. package/plugin/hooks/hooks.json +28 -0
  120. package/plugin/skills/nativ/SKILL.md +75 -0
  121. package/templates/.claudeignore +45 -0
  122. package/templates/AGENTS.md +67 -0
  123. package/templates/CLAUDE.md +32 -0
  124. package/templates/GEMINI.md +66 -0
  125. package/templates/claude-agents/architect.md +28 -0
  126. package/templates/claude-agents/verifier.md +28 -0
  127. package/templates/claude-agents/worker.md +26 -0
  128. package/templates/dot-ai/api_contracts.json +66 -0
  129. package/templates/dot-ai/context.md +38 -0
  130. package/templates/dot-ai/db_schema.json +39 -0
  131. package/templates/dot-ai/master_plan.json +28 -0
  132. package/templates/dot-ai/subagents/backend.md +11 -0
  133. package/templates/dot-ai/subagents/database.md +10 -0
  134. package/templates/dot-ai/subagents/db-migration.md +11 -0
  135. package/templates/dot-ai/subagents/devops-agent.md +11 -0
  136. package/templates/dot-ai/subagents/flutter-developer.md +11 -0
  137. package/templates/dot-ai/subagents/frontend.md +126 -0
  138. package/templates/dot-ai/subagents/qa-tester.md +13 -0
  139. package/templates/dot-ai/subagents/security-auditor.md +11 -0
  140. package/templates/dot-ai/ui_specs.md +78 -0
@@ -0,0 +1,80 @@
1
+ export interface ProjectInfo {
2
+ projectName: string;
3
+ projectType: string;
4
+ projectGoal: string;
5
+ runtime: string;
6
+ framework: string;
7
+ databaseOrm: string;
8
+ styling: string;
9
+ testing: string;
10
+ packageManager: string;
11
+ sourceRoot: string;
12
+ architecturePattern: string;
13
+ keyDirectories: string[];
14
+ verificationCommand: string;
15
+ repositoryType: string;
16
+ monorepoWorkspaces: string[];
17
+ detectedOrmConfig: string;
18
+ ecosystemManifests: string[];
19
+ }
20
+ export type SubagentType = 'backend' | 'frontend' | 'database' | 'qa-tester' | 'flutter-developer' | 'devops-agent' | 'security-auditor' | 'db-migration' | 'database-agent' | 'backend-agent' | 'frontend-agent' | 'qa-agent';
21
+ export declare const SUBAGENT_TYPES: readonly SubagentType[];
22
+ export declare function isSubagentType(value: string): value is SubagentType;
23
+ export type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'blocked';
24
+ export declare const TASK_STATUSES: readonly TaskStatus[];
25
+ export interface MasterPlanTask {
26
+ id: string;
27
+ title: string;
28
+ description: string;
29
+ assignedSubagent: SubagentType;
30
+ dependencies: string[];
31
+ targetFiles: string[];
32
+ status: TaskStatus;
33
+ verificationCommand: string;
34
+ notes?: string;
35
+ /**
36
+ * Fast-path task: a small, self-contained change added outside the Tier-1 planned milestones
37
+ * (e.g. via `nativ task add --fast-path`). Absent or false means a planned task.
38
+ */
39
+ fastPath?: boolean;
40
+ }
41
+ /** Lists every structural problem with a task; empty when the task is valid. */
42
+ export declare function validateMasterPlanTask(task: unknown): string[];
43
+ export interface MasterPlanMilestone {
44
+ id: string;
45
+ name: string;
46
+ status: 'pending' | 'in_progress' | 'completed';
47
+ tasks: MasterPlanTask[];
48
+ /** True for the milestone that collects fast-path tasks. */
49
+ fastPath?: boolean;
50
+ }
51
+ export interface MasterPlan {
52
+ $schema?: string;
53
+ version: string;
54
+ projectName: string;
55
+ lastUpdated: string;
56
+ overallStatus: 'pending' | 'in_progress' | 'completed';
57
+ activeMilestoneId: string;
58
+ milestones: MasterPlanMilestone[];
59
+ }
60
+ export type EscalationType = 'contract_drift' | 'schema_flaw' | 'missing_credential' | 'dependency_conflict' | 'architectural_ambiguity';
61
+ export interface EscalationRecord {
62
+ id: string;
63
+ taskId: string;
64
+ type: EscalationType;
65
+ reportedBy: SubagentType;
66
+ timestamp: string;
67
+ summary: string;
68
+ details?: string;
69
+ affectedContracts: string[];
70
+ recommendedAction?: string;
71
+ status: 'pending_review' | 'resolved' | 'dismissed';
72
+ resolutionNotes?: string;
73
+ }
74
+ export interface EscalationFile {
75
+ $schema?: string;
76
+ version: string;
77
+ projectName: string;
78
+ lastUpdated: string;
79
+ escalations: EscalationRecord[];
80
+ }
@@ -0,0 +1,50 @@
1
+ export const SUBAGENT_TYPES = [
2
+ 'backend',
3
+ 'frontend',
4
+ 'database',
5
+ 'qa-tester',
6
+ 'flutter-developer',
7
+ 'devops-agent',
8
+ 'security-auditor',
9
+ 'db-migration',
10
+ 'database-agent',
11
+ 'backend-agent',
12
+ 'frontend-agent',
13
+ 'qa-agent',
14
+ ];
15
+ export function isSubagentType(value) {
16
+ return SUBAGENT_TYPES.includes(value);
17
+ }
18
+ export const TASK_STATUSES = ['pending', 'in_progress', 'completed', 'blocked'];
19
+ /** Lists every structural problem with a task; empty when the task is valid. */
20
+ export function validateMasterPlanTask(task) {
21
+ if (!task || typeof task !== 'object' || Array.isArray(task))
22
+ return ['task must be an object'];
23
+ const t = task;
24
+ const label = typeof t.id === 'string' && t.id ? `task "${t.id}"` : 'task';
25
+ const errors = [];
26
+ const isStringArray = (v) => Array.isArray(v) && v.every((x) => typeof x === 'string');
27
+ for (const field of ['id', 'title']) {
28
+ if (typeof t[field] !== 'string' || !t[field].trim())
29
+ errors.push(`${label}: "${field}" must be a non-empty string`);
30
+ }
31
+ if (typeof t.description !== 'string')
32
+ errors.push(`${label}: "description" must be a string`);
33
+ if (typeof t.verificationCommand !== 'string')
34
+ errors.push(`${label}: "verificationCommand" must be a string`);
35
+ if (typeof t.assignedSubagent !== 'string' || !isSubagentType(t.assignedSubagent)) {
36
+ errors.push(`${label}: "assignedSubagent" must be one of ${SUBAGENT_TYPES.join(', ')}`);
37
+ }
38
+ if (typeof t.status !== 'string' || !TASK_STATUSES.includes(t.status)) {
39
+ errors.push(`${label}: "status" must be one of ${TASK_STATUSES.join(', ')}`);
40
+ }
41
+ if (!isStringArray(t.dependencies))
42
+ errors.push(`${label}: "dependencies" must be an array of task IDs`);
43
+ if (!isStringArray(t.targetFiles))
44
+ errors.push(`${label}: "targetFiles" must be an array of paths`);
45
+ if (t.notes !== undefined && typeof t.notes !== 'string')
46
+ errors.push(`${label}: "notes" must be a string`);
47
+ if (t.fastPath !== undefined && typeof t.fastPath !== 'boolean')
48
+ errors.push(`${label}: "fastPath" must be a boolean`);
49
+ return errors;
50
+ }
@@ -0,0 +1,39 @@
1
+ import http from 'node:http';
2
+ import type { DatabaseEnv, DatabaseStatus, TableSchema } from '../db/types.js';
3
+ import { type Tier1LiaisonOptions } from '../core/tier1-liaison.js';
4
+ import { type AgentSupervisorOptions } from '../runner/agent-supervisor.js';
5
+ /**
6
+ * Embedded Studio HTTP server (native node:http).
7
+ * Serves the REST endpoints from .ai/api_contracts.json plus the dashboard page.
8
+ *
9
+ * Air-gap rules: binds to loopback only, keeps raw connection URLs in this process's
10
+ * memory, and only ever returns masked URLs in responses.
11
+ */
12
+ export declare const DEFAULT_STUDIO_PORT = 4983;
13
+ export interface StudioServerOptions {
14
+ port?: number;
15
+ host?: string;
16
+ cwd?: string;
17
+ /** Dashboard HTML served at `/`. */
18
+ html?: string | (() => string);
19
+ /** Pre-seeded connection URLs; defaults to those resolved from .env files. */
20
+ connections?: Partial<Record<DatabaseEnv, string | null>>;
21
+ /** Interval between `heartbeat` events on /api/events. Defaults to 15s. */
22
+ heartbeatMs?: number;
23
+ /** Agent supervisor tuning (runner command, timeout budget, log buffer size). `cwd` is always the project root. */
24
+ supervisor?: Omit<AgentSupervisorOptions, 'cwd'>;
25
+ /** Tier 1 strategist transport (API key, model, fetch). Defaults to GEMINI_API_KEY and native fetch. */
26
+ triage?: Tier1LiaisonOptions;
27
+ }
28
+ export interface StudioServerHandle {
29
+ server: http.Server;
30
+ url: string;
31
+ port: number;
32
+ close(): Promise<void>;
33
+ }
34
+ /** Writes structure-only table metadata into .ai/db_schema.json, preserving other contract fields. */
35
+ export declare function writeContractSchema(cwd: string, status: DatabaseStatus, tables: TableSchema[]): string;
36
+ export declare const DEFAULT_HEARTBEAT_MS = 15000;
37
+ export declare function createStudioServer(options?: StudioServerOptions): http.Server;
38
+ /** Starts the studio on loopback, trying up to 10 consecutive ports if the preferred one is busy. */
39
+ export declare function startStudioServer(options?: StudioServerOptions): Promise<StudioServerHandle>;