@aiwg/cli 2026.10.11 → 2026.10.14
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/agentic/code/providers/model-catalog.v1.json +62 -12
- package/agentic/code/providers/pi/aiwg-bridge.ts +44 -1
- package/dist/src/artifacts/binding-target-identity.js +51 -0
- package/dist/src/artifacts/checksum-manifest.js +12 -0
- package/dist/src/artifacts/index-builder.js +11 -13
- package/dist/src/artifacts/query-engine.js +5 -11
- package/dist/src/cli/handlers/doctor-help.js +32 -0
- package/dist/src/cli/handlers/gates.js +19 -18
- package/dist/src/cli/handlers/models-help.js +7 -1
- package/dist/src/cli/handlers/models.js +3 -3
- package/dist/src/cli/handlers/script-runner.js +8 -5
- package/dist/src/cli/handlers/sessions-intake.js +104 -0
- package/dist/src/cli/handlers/sessions-tail.js +172 -0
- package/dist/src/cli/handlers/sessions.js +90 -17
- package/dist/src/cli/handlers/skill-lint.js +10 -3
- package/dist/src/cli/handlers/steward-format.js +100 -0
- package/dist/src/cli/handlers/steward-models.js +167 -0
- package/dist/src/cli/handlers/steward.js +14 -248
- package/dist/src/cli/handlers/use-bundle-counts.js +87 -0
- package/dist/src/cli/handlers/use-skill-assets.js +207 -0
- package/dist/src/cli/handlers/use.js +35 -216
- package/dist/src/cli/handlers/utilities.js +1 -24
- package/dist/src/config/aiwg-config.js +7 -0
- package/dist/src/config/authorization-cli.js +97 -0
- package/dist/src/config/cli-help.js +1 -0
- package/dist/src/config/cli.js +10 -1
- package/dist/src/decision/context-pruning-common.js +41 -0
- package/dist/src/decision/context-pruning-evaluation.js +366 -0
- package/dist/src/decision/context-pruning-pilot.js +431 -0
- package/dist/src/decision/context-pruning-types.js +19 -0
- package/dist/src/decision/context-pruning.js +5 -846
- package/dist/src/decision/ensemble/contract.js +17 -26
- package/dist/src/decision/ensemble-study/artifacts.js +5 -0
- package/dist/src/decision/ensemble-study/score.js +4 -3
- package/dist/src/decision/feature-export.js +3 -9
- package/dist/src/decision/heldout/collector.js +2 -2
- package/dist/src/decision/issue-triage/runtime.js +3 -9
- package/dist/src/decision/qualification/gates.js +2 -1
- package/dist/src/decision/qualification/release.js +6 -64
- package/dist/src/decision/routing/report.js +2 -0
- package/dist/src/decision/sdlc-screening.js +3 -5
- package/dist/src/decision/sensitivity/comparative.js +5 -3
- package/dist/src/extensions/manifest.js +8 -1
- package/dist/src/extensions/project-local-doctor.js +78 -2
- package/dist/src/extensions/validation.js +10 -11
- package/dist/src/gates/driver.js +6 -77
- package/dist/src/gates/evaluate.js +6 -23
- package/dist/src/gates/floors.js +4 -4
- package/dist/src/gates/index.js +3 -3
- package/dist/src/gates/lattice.js +26 -0
- package/dist/src/gates/registry.js +2 -1
- package/dist/src/gates/report.js +19 -7
- package/dist/src/gates/upstream-ceiling.js +111 -0
- package/dist/src/issues/audit-cli.js +120 -0
- package/dist/src/issues/audit-contract.js +64 -0
- package/dist/src/issues/audit-local.js +82 -0
- package/dist/src/issues/audit.js +220 -0
- package/dist/src/lint/rule-activation.js +15 -1
- package/dist/src/mission-protocol/canonical-codecs.js +270 -0
- package/dist/src/mission-protocol/codecs.js +22 -550
- package/dist/src/mission-protocol/health-trace-codecs.js +281 -0
- package/dist/src/mission-protocol/health-trace-types.js +43 -0
- package/dist/src/mission-protocol/types.js +2 -42
- package/dist/src/mission-protocol/worker-contract-json.js +10 -0
- package/dist/src/mission-protocol/worker-review-gate.js +100 -0
- package/dist/src/mission-protocol/worker-review-types.js +2 -0
- package/dist/src/models/catalog-policy.js +280 -0
- package/dist/src/models/index.js +1 -1
- package/dist/src/models/model-catalog.v1.json +62 -12
- package/dist/src/models/policy-resources.js +28 -0
- package/dist/src/models/provider-models.js +5 -8
- package/dist/src/models/provider-policy.js +10 -546
- package/dist/src/models/resolver.js +26 -8
- package/dist/src/models/router.js +15 -2
- package/dist/src/models/tiers.js +13 -0
- package/dist/src/models/types.js +0 -6
- package/dist/src/models/worker-ceilings.js +59 -0
- package/dist/src/models/worker-invocation-policy.js +243 -0
- package/dist/src/models/worker-plan.js +16 -20
- package/dist/src/models/worker-review-lineage.js +55 -0
- package/dist/src/models/worker-selection-policy.js +1 -1
- package/dist/src/models/wrapper-definitions.js +14 -0
- package/dist/src/models/wrapper-deployment.js +48 -25
- package/dist/src/models/wrapper-enforcement.js +72 -0
- package/dist/src/models/wrapper-route.js +6 -3
- package/dist/src/policy/authorization.js +1 -0
- package/dist/src/policy/hitl-check.js +80 -0
- package/dist/src/policy/hitl-config.js +63 -0
- package/dist/src/policy/hitl-receipt.js +57 -0
- package/dist/src/policy/hitl-types.js +4 -0
- package/dist/src/policy/hitl-validation.js +39 -0
- package/dist/src/policy/hitl.js +117 -0
- package/dist/src/rules/activation.d.mts +3 -1
- package/dist/src/rules/activation.mjs +23 -2
- package/dist/src/rules/gate-coverage.js +51 -0
- package/dist/src/rules/gate-references.js +16 -0
- package/dist/src/rules/rule-frontmatter.schema.json +7 -1
- package/dist/src/serve/worker-command-request.js +21 -4
- package/dist/src/serve/worker-invocation-preparation.js +3 -1
- package/dist/src/serve/worker-invocation.js +21 -10
- package/dist/src/sessions/adapters/deepseek-harness.js +1 -0
- package/dist/src/sessions/adapters/grok-build-native.js +269 -0
- package/dist/src/sessions/adapters/grok-build.js +57 -15
- package/dist/src/sessions/adapters/hermes-state-db.js +252 -0
- package/dist/src/sessions/adapters/hermes.js +42 -3
- package/dist/src/sessions/adapters/warp.js +1 -1
- package/dist/src/sessions/batch-import.js +10 -0
- package/dist/src/sessions/contracts.js +1 -1
- package/dist/src/sessions/discovery-capability.js +38 -0
- package/dist/src/sessions/importer.js +8 -251
- package/dist/src/sessions/index.js +4 -0
- package/dist/src/sessions/intake-dir.js +71 -0
- package/dist/src/sessions/normalization.js +251 -0
- package/dist/src/sessions/tail.js +91 -0
- package/dist/src/sessions/workspace-discovery.js +83 -7
- package/dist/src/skills/adapters/local.js +32 -9
- package/dist/src/skills/agent-skill-sidecar.js +28 -0
- package/dist/src/skills/agent-skills.js +6 -23
- package/dist/src/skills/claude-surface-projection.js +25 -0
- package/dist/src/skills/cli-display.js +33 -0
- package/dist/src/skills/cli.js +2 -26
- package/dist/src/skills/collision-discovery.js +84 -0
- package/dist/src/skills/deployer.js +26 -361
- package/dist/src/skills/deployment-ownership.js +74 -0
- package/dist/src/skills/deployment-policy.js +114 -0
- package/dist/src/skills/deployment-projection.js +152 -0
- package/dist/src/skills/deployment-types.js +20 -0
- package/dist/src/skills/doctor.js +2 -2
- package/dist/src/skills/exporter.js +8 -31
- package/dist/src/skills/importer.js +4 -26
- package/dist/src/skills/provider-extensions.js +41 -0
- package/dist/src/skills/registry.js +22 -7
- package/dist/src/skills/run.js +6 -0
- package/dist/src/skills/types.js +0 -8
- package/dist/src/skills/validator-resources.js +68 -0
- package/dist/src/skills/validator.js +6 -55
- package/dist/src/smiths/context-pipeline/parallelism-section.js +7 -3
- package/dist/src/storage/cli-migrate-options.js +125 -0
- package/dist/src/storage/cli-migrate.js +111 -0
- package/dist/src/storage/cli.js +4 -279
- package/dist/src/storage/migration-adapter.js +79 -0
- package/dist/src/storage/migration-copy.js +108 -0
- package/dist/src/storage/migration-protocol.js +14 -197
- package/dist/src/storage/migration-records.js +186 -0
- package/dist/src/storage/migration-types.js +12 -0
- package/dist/src/tracker/forge-http.js +2 -1
- package/dist/src/tracker/issue-pages.js +110 -0
- package/package.json +3 -1
- package/schemas/mission-v1.schema.json +335 -0
- package/schemas/models/model-catalog.v1.schema.json +19 -1
- package/schemas/models/model-config-compatibility.v1.schema.json +3 -2
- package/schemas/models/model-policy.v1.schema.json +1 -1
- package/tools/agents/providers/antigravity.mjs +3 -5
- package/tools/agents/providers/base.mjs +3 -3
- package/tools/agents/providers/claude.mjs +3 -5
- package/tools/agents/providers/codex.mjs +3 -5
- package/tools/agents/providers/copilot.mjs +3 -5
- package/tools/agents/providers/cursor.mjs +3 -5
- package/tools/agents/providers/factory.mjs +3 -5
- package/tools/agents/providers/grok-build.mjs +9 -7
- package/tools/agents/providers/model-wrapper.mjs +86 -0
- package/tools/agents/providers/omp.mjs +3 -1
- package/tools/agents/providers/openclaw.mjs +3 -5
- package/tools/agents/providers/opencode.mjs +3 -5
- package/tools/agents/providers/provider-paths-staging.mjs +44 -0
- package/tools/agents/providers/rule-binding-targets.mjs +146 -0
- package/tools/agents/providers/rule-delivery.mjs +9 -128
- package/tools/agents/providers/warp.mjs +3 -5
- package/tools/agents/providers/windsurf.mjs +3 -5
- package/tools/plugin/package-plugins.mjs +2 -2
- package/tools/skills/codex-skill-transform.mjs +232 -0
- package/tools/skills/deploy-skills-codex.mjs +8 -249
- package/tools/warp/warp-content.mjs +548 -0
- package/vscode-extension/schemas/aiwg.config.v1.json +177 -0
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Setup Warp - Intelligent WARP.md Merge Tool
|
|
4
|
+
*
|
|
5
|
+
* Mirrors the proven pattern from aiwg-setup-project and aiwg-update-claude.
|
|
6
|
+
* Aggregates all AIWG agents and commands into a single WARP.md file for Warp Terminal.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* node tools/warp/setup-warp.mjs [options]
|
|
10
|
+
*
|
|
11
|
+
* Options:
|
|
12
|
+
* --target <path> Target directory (default: cwd)
|
|
13
|
+
* --mode <type> Mode: general, sdlc, or both (default: both)
|
|
14
|
+
* --update Update mode (fail if no WARP.md exists)
|
|
15
|
+
* --dry-run Preview changes without writing
|
|
16
|
+
* --force Overwrite WARP.md (discard user content)
|
|
17
|
+
*
|
|
18
|
+
* Modes:
|
|
19
|
+
* general - Deploy only general-purpose agents and commands
|
|
20
|
+
* sdlc - Deploy only SDLC Complete framework agents and commands
|
|
21
|
+
* both - Deploy everything (default)
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { fileURLToPath } from 'node:url';
|
|
25
|
+
import fs from 'fs';
|
|
26
|
+
import path from 'path';
|
|
27
|
+
import { listOnDemandRuleFiles, renderOnDemandRuleSection } from '../agents/providers/base.mjs';
|
|
28
|
+
|
|
29
|
+
// AIWG-managed section headings (will be replaced on update)
|
|
30
|
+
const AIWG_MANAGED_SECTIONS = [
|
|
31
|
+
'AIWG SDLC Framework',
|
|
32
|
+
'AIWG SDLC Framework',
|
|
33
|
+
'SDLC Agents',
|
|
34
|
+
'SDLC Commands',
|
|
35
|
+
'Platform Compatibility',
|
|
36
|
+
'Core Orchestrator',
|
|
37
|
+
'Core Platform Orchestrator',
|
|
38
|
+
'Natural Language',
|
|
39
|
+
'Natural Language Command Translation',
|
|
40
|
+
'Phase Overview',
|
|
41
|
+
'Quick Start',
|
|
42
|
+
'Common Patterns',
|
|
43
|
+
'Troubleshooting',
|
|
44
|
+
'Resources'
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
export function parseArgs() {
|
|
48
|
+
const args = process.argv.slice(2);
|
|
49
|
+
const cfg = {
|
|
50
|
+
target: process.cwd(),
|
|
51
|
+
mode: 'both',
|
|
52
|
+
update: false,
|
|
53
|
+
dryRun: false,
|
|
54
|
+
force: false,
|
|
55
|
+
strict: false,
|
|
56
|
+
reportOnly: true
|
|
57
|
+
};
|
|
58
|
+
for (let i = 0; i < args.length; i++) {
|
|
59
|
+
const a = args[i];
|
|
60
|
+
if (a === '--target' && args[i + 1]) cfg.target = path.resolve(args[++i]);
|
|
61
|
+
else if (a === '--mode' && args[i + 1]) cfg.mode = String(args[++i]).toLowerCase();
|
|
62
|
+
else if (a === '--update') cfg.update = true;
|
|
63
|
+
else if (a === '--dry-run') cfg.dryRun = true;
|
|
64
|
+
else if (a === '--force') cfg.force = true;
|
|
65
|
+
else if (a === '--strict') cfg.strict = true;
|
|
66
|
+
else if (a === '--report-only') cfg.reportOnly = true;
|
|
67
|
+
}
|
|
68
|
+
return cfg;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Resolve AIWG installation path
|
|
73
|
+
* Priority: $AIWG_ROOT -> ~/.local/share/ai-writing-guide -> /usr/local/share/ai-writing-guide
|
|
74
|
+
*/
|
|
75
|
+
export function resolveAIWGRoot() {
|
|
76
|
+
const candidates = [
|
|
77
|
+
process.env.AIWG_ROOT,
|
|
78
|
+
path.join(process.env.HOME || '', '.local', 'share', 'ai-writing-guide'),
|
|
79
|
+
'/usr/local/share/ai-writing-guide',
|
|
80
|
+
// Development fallback (repo root)
|
|
81
|
+
path.resolve(path.dirname(new URL(import.meta.url).pathname), '..', '..')
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
for (const candidate of candidates) {
|
|
85
|
+
if (!candidate) continue;
|
|
86
|
+
const testPath = path.join(candidate, 'agentic', 'code', 'frameworks', 'sdlc-complete');
|
|
87
|
+
if (fs.existsSync(testPath)) {
|
|
88
|
+
return candidate;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
throw new Error(
|
|
93
|
+
'AIWG installation not found. Please install AIWG first:\n' +
|
|
94
|
+
' curl -fsSL https://raw.githubusercontent.com/jmagly/ai-writing-guide/refs/heads/main/tools/install/install.sh | bash\n\n' +
|
|
95
|
+
'Or set AIWG_ROOT environment variable if installed elsewhere.'
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Parse markdown into sections based on ## headings
|
|
101
|
+
*/
|
|
102
|
+
function parseMarkdownSections(content) {
|
|
103
|
+
const lines = content.split('\n');
|
|
104
|
+
const sections = [];
|
|
105
|
+
let currentSection = null;
|
|
106
|
+
|
|
107
|
+
for (let i = 0; i < lines.length; i++) {
|
|
108
|
+
const line = lines[i];
|
|
109
|
+
const match = line.match(/^##\s+(.+)$/);
|
|
110
|
+
|
|
111
|
+
if (match) {
|
|
112
|
+
// New section found
|
|
113
|
+
if (currentSection) {
|
|
114
|
+
sections.push(currentSection);
|
|
115
|
+
}
|
|
116
|
+
currentSection = {
|
|
117
|
+
heading: match[1].trim(),
|
|
118
|
+
startLine: i,
|
|
119
|
+
lines: [line]
|
|
120
|
+
};
|
|
121
|
+
} else if (currentSection) {
|
|
122
|
+
currentSection.lines.push(line);
|
|
123
|
+
} else {
|
|
124
|
+
// Before first ## heading (document header)
|
|
125
|
+
if (sections.length === 0) {
|
|
126
|
+
sections.push({
|
|
127
|
+
heading: '__HEADER__',
|
|
128
|
+
startLine: 0,
|
|
129
|
+
lines: [line]
|
|
130
|
+
});
|
|
131
|
+
} else {
|
|
132
|
+
sections[sections.length - 1].lines.push(line);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (currentSection) {
|
|
138
|
+
sections.push(currentSection);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return sections;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Check if a section heading is AIWG-managed (will be replaced)
|
|
146
|
+
*/
|
|
147
|
+
function isAIWGManagedSection(heading) {
|
|
148
|
+
if (heading === '__HEADER__') return false;
|
|
149
|
+
return AIWG_MANAGED_SECTIONS.some(managed =>
|
|
150
|
+
heading.toLowerCase().includes(managed.toLowerCase())
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* List markdown files in a directory (non-recursive)
|
|
156
|
+
*/
|
|
157
|
+
function listMdFiles(dir) {
|
|
158
|
+
if (!fs.existsSync(dir)) return [];
|
|
159
|
+
const defaultExcluded = ['README.md', 'manifest.md', 'agent-template.md', 'openai-compat.md', 'DEVELOPMENT_GUIDE.md'];
|
|
160
|
+
return fs
|
|
161
|
+
.readdirSync(dir, { withFileTypes: true })
|
|
162
|
+
.filter((e) => e.isFile() && e.name.toLowerCase().endsWith('.md') && !defaultExcluded.includes(e.name))
|
|
163
|
+
.map((e) => path.join(dir, e.name));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Transform agent markdown file to WARP.md section format
|
|
168
|
+
*/
|
|
169
|
+
function transformAgentToSection(agentPath, opts = {}) {
|
|
170
|
+
const content = fs.readFileSync(agentPath, 'utf8');
|
|
171
|
+
if (opts.ruleDelivery?.bindings.has(path.resolve(agentPath))) return `### ${path.basename(agentPath, '.md')}\n\nRead and follow .warp/agents/${path.basename(agentPath)} before invocation.\n`;
|
|
172
|
+
const name = path.basename(agentPath, '.md');
|
|
173
|
+
|
|
174
|
+
// Extract frontmatter and body
|
|
175
|
+
const fmMatch = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
|
|
176
|
+
if (!fmMatch) return null;
|
|
177
|
+
|
|
178
|
+
const [, frontmatter, body] = fmMatch;
|
|
179
|
+
|
|
180
|
+
// Parse frontmatter
|
|
181
|
+
const fm = {};
|
|
182
|
+
frontmatter.split('\n').forEach(line => {
|
|
183
|
+
const match = line.match(/^(\w[\w-]*)\s*:\s*(.+)$/);
|
|
184
|
+
if (match) {
|
|
185
|
+
fm[match[1]] = match[2].trim();
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// Extract description and tools
|
|
190
|
+
const description = fm.description || '';
|
|
191
|
+
const tools = fm['allowed-tools'] || '';
|
|
192
|
+
|
|
193
|
+
// Format as WARP.md section
|
|
194
|
+
let section = `### ${name.split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ')}\n\n`;
|
|
195
|
+
if (tools) {
|
|
196
|
+
section += `**Tools**: ${tools}\n\n`;
|
|
197
|
+
}
|
|
198
|
+
if (description) {
|
|
199
|
+
section += `**Purpose**: ${description}\n\n`;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Add body content (strip excessive blank lines)
|
|
203
|
+
const cleanBody = body.trim().replace(/\n{3,}/g, '\n\n');
|
|
204
|
+
if (cleanBody) {
|
|
205
|
+
section += cleanBody + '\n';
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return section;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Transform command markdown file to WARP.md section format
|
|
213
|
+
*/
|
|
214
|
+
function transformCommandToSection(commandPath, opts = {}) {
|
|
215
|
+
const content = fs.readFileSync(commandPath, 'utf8');
|
|
216
|
+
if (opts.ruleDelivery?.bindings.has(path.resolve(commandPath))) return `### ${path.basename(commandPath, '.md')}\n\nRead and follow .warp/commands/${path.basename(commandPath)} before invocation.\n`;
|
|
217
|
+
const name = path.basename(commandPath, '.md');
|
|
218
|
+
|
|
219
|
+
// Extract frontmatter and body
|
|
220
|
+
const fmMatch = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
|
|
221
|
+
if (!fmMatch) return null;
|
|
222
|
+
|
|
223
|
+
const [, frontmatter, body] = fmMatch;
|
|
224
|
+
|
|
225
|
+
// Parse frontmatter
|
|
226
|
+
const fm = {};
|
|
227
|
+
frontmatter.split('\n').forEach(line => {
|
|
228
|
+
const match = line.match(/^(\w[\w-]*)\s*:\s*(.+)$/);
|
|
229
|
+
if (match) {
|
|
230
|
+
fm[match[1]] = match[2].trim();
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Extract description
|
|
235
|
+
const description = fm.description || '';
|
|
236
|
+
|
|
237
|
+
// Format as WARP.md section
|
|
238
|
+
let section = `### /${name}\n\n`;
|
|
239
|
+
if (description) {
|
|
240
|
+
section += `**Purpose**: ${description}\n\n`;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Add usage/parameters section if present in body
|
|
244
|
+
const cleanBody = body.trim().replace(/\n{3,}/g, '\n\n');
|
|
245
|
+
if (cleanBody) {
|
|
246
|
+
// Extract first paragraph or two for context
|
|
247
|
+
const paragraphs = cleanBody.split('\n\n');
|
|
248
|
+
const preview = paragraphs.slice(0, 2).join('\n\n');
|
|
249
|
+
section += preview + '\n';
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return section;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Transform rule markdown file to WARP.md section format.
|
|
257
|
+
* Rule content is inlined verbatim under an H3 heading (the rule name in
|
|
258
|
+
* Title Case), so Warp agents see the full rule body in their context.
|
|
259
|
+
* Per #1346 — closes cross-provider parity gap on the skill-discovery
|
|
260
|
+
* rule and other aiwg-utils rules that Warp's "rules via WARP.md only"
|
|
261
|
+
* convention previously left unwired.
|
|
262
|
+
*/
|
|
263
|
+
function transformRuleToSection(rulePath) {
|
|
264
|
+
const content = fs.readFileSync(rulePath, 'utf8');
|
|
265
|
+
const name = path.basename(rulePath, '.md');
|
|
266
|
+
|
|
267
|
+
// Strip frontmatter if present; the agent doesn't need the YAML.
|
|
268
|
+
const fmMatch = content.match(/^---\n[\s\S]*?\n---\n([\s\S]*)$/);
|
|
269
|
+
const body = (fmMatch ? fmMatch[1] : content).trim();
|
|
270
|
+
|
|
271
|
+
// Rules typically start with their own H1 (# Rule Name) — we want H3 in
|
|
272
|
+
// WARP.md so the rule slots under "## AIWG Rules". Strip a leading H1
|
|
273
|
+
// and rely on the section heading below; downshift surviving H2/H3.
|
|
274
|
+
const downshifted = body
|
|
275
|
+
.replace(/^# .+\n+/, '') // drop leading H1
|
|
276
|
+
.replace(/^## /gm, '#### ')
|
|
277
|
+
.replace(/^### /gm, '##### ');
|
|
278
|
+
|
|
279
|
+
const title = name.split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ');
|
|
280
|
+
return `### ${title}\n\n${downshifted}\n`;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Collect aiwg-utils rule file paths for inlining into WARP.md.
|
|
285
|
+
* Focused on cross-provider parity rules: discover-first is the linchpin
|
|
286
|
+
* (#1343, #1346); other aiwg-utils rules are included to match the
|
|
287
|
+
* intent of "rules via WARP.md" stated in tools/agents/providers/warp.mjs.
|
|
288
|
+
* Per the activity-log rule and feedback_parity_no_removal: always-deploy.
|
|
289
|
+
*/
|
|
290
|
+
function collectAiwgRulePaths(aiwgRoot) {
|
|
291
|
+
const utilsRules = path.join(aiwgRoot, 'agentic', 'code', 'addons', 'aiwg-utils', 'rules');
|
|
292
|
+
if (!fs.existsSync(utilsRules)) return [];
|
|
293
|
+
return listMdFiles(utilsRules)
|
|
294
|
+
// RULES-INDEX.md is a navigation aid for filesystem deployments; for
|
|
295
|
+
// Warp's inlined aggregation the full rule bodies are inlined directly,
|
|
296
|
+
// so the index would be duplicate content. Skip it.
|
|
297
|
+
.filter(p => !path.basename(p).startsWith('RULES-INDEX'));
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Generate AIWG content section (aggregate agents, commands, and rules)
|
|
302
|
+
*/
|
|
303
|
+
export function generateAIWGContent(aiwgRoot, mode, opts = {}) {
|
|
304
|
+
let content = '';
|
|
305
|
+
|
|
306
|
+
// Add marker comments
|
|
307
|
+
content += '<!-- AIWG SDLC Framework (auto-updated) -->\n';
|
|
308
|
+
content += '<!-- Managed by aiwg use -->\n\n';
|
|
309
|
+
content += '---\n\n';
|
|
310
|
+
|
|
311
|
+
// Add framework overview
|
|
312
|
+
content += '## AIWG SDLC Framework\n\n';
|
|
313
|
+
content += `**AIWG Installation**: ${aiwgRoot}\n\n`;
|
|
314
|
+
content += 'This project uses the **AIWG SDLC framework** for software development lifecycle management.\n\n';
|
|
315
|
+
content += '### What is AIWG?\n\n';
|
|
316
|
+
content += 'AIWG provides:\n\n';
|
|
317
|
+
content += '- **58+ specialized agents** covering all lifecycle phases (Inception → Elaboration → Construction → Transition → Production)\n';
|
|
318
|
+
content += '- **42+ commands** for project management, security, testing, deployment, and traceability\n';
|
|
319
|
+
content += '- **100+ templates** for requirements, architecture, testing, security, deployment artifacts\n';
|
|
320
|
+
content += '- **Phase-based workflows** with gate criteria and milestone tracking\n';
|
|
321
|
+
content += '- **Multi-agent orchestration** patterns for collaborative artifact generation\n\n';
|
|
322
|
+
|
|
323
|
+
// Aggregate agents
|
|
324
|
+
content += '---\n\n';
|
|
325
|
+
content += '## SDLC Agents (Specialized Roles)\n\n';
|
|
326
|
+
|
|
327
|
+
const agentPaths = [];
|
|
328
|
+
if (mode === 'general' || mode === 'both') {
|
|
329
|
+
const generalAgents = path.join(aiwgRoot, 'agents');
|
|
330
|
+
if (fs.existsSync(generalAgents)) {
|
|
331
|
+
agentPaths.push(...listMdFiles(generalAgents));
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Addon agents (dynamically discovered)
|
|
336
|
+
const addonsRoot = path.join(aiwgRoot, 'agentic', 'code', 'addons');
|
|
337
|
+
if (fs.existsSync(addonsRoot)) {
|
|
338
|
+
const addonDirs = fs.readdirSync(addonsRoot, { withFileTypes: true })
|
|
339
|
+
.filter(e => e.isDirectory())
|
|
340
|
+
.map(e => path.join(addonsRoot, e.name, 'agents'));
|
|
341
|
+
|
|
342
|
+
for (const addonAgentsDir of addonDirs) {
|
|
343
|
+
if (fs.existsSync(addonAgentsDir)) {
|
|
344
|
+
agentPaths.push(...listMdFiles(addonAgentsDir));
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (mode === 'sdlc' || mode === 'both') {
|
|
350
|
+
const sdlcAgents = path.join(aiwgRoot, 'agentic', 'code', 'frameworks', 'sdlc-complete', 'agents');
|
|
351
|
+
if (fs.existsSync(sdlcAgents)) {
|
|
352
|
+
agentPaths.push(...listMdFiles(sdlcAgents));
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
for (const agentPath of agentPaths) {
|
|
357
|
+
const section = transformAgentToSection(agentPath, opts);
|
|
358
|
+
if (section) {
|
|
359
|
+
content += section + '\n';
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// Aggregate commands
|
|
364
|
+
content += '---\n\n';
|
|
365
|
+
content += '## SDLC Commands (Workflows)\n\n';
|
|
366
|
+
|
|
367
|
+
const commandPaths = [];
|
|
368
|
+
if (mode === 'general' || mode === 'both') {
|
|
369
|
+
const generalCommands = path.join(aiwgRoot, 'commands');
|
|
370
|
+
if (fs.existsSync(generalCommands)) {
|
|
371
|
+
commandPaths.push(...listMdFiles(generalCommands));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// Addon commands (dynamically discovered)
|
|
376
|
+
if (fs.existsSync(addonsRoot)) {
|
|
377
|
+
const addonCommandDirs = fs.readdirSync(addonsRoot, { withFileTypes: true })
|
|
378
|
+
.filter(e => e.isDirectory())
|
|
379
|
+
.map(e => path.join(addonsRoot, e.name, 'commands'));
|
|
380
|
+
|
|
381
|
+
for (const addonCommandsDir of addonCommandDirs) {
|
|
382
|
+
if (fs.existsSync(addonCommandsDir)) {
|
|
383
|
+
commandPaths.push(...listMdFiles(addonCommandsDir));
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (mode === 'sdlc' || mode === 'both') {
|
|
389
|
+
const sdlcCommands = path.join(aiwgRoot, 'agentic', 'code', 'frameworks', 'sdlc-complete', 'commands');
|
|
390
|
+
if (fs.existsSync(sdlcCommands)) {
|
|
391
|
+
commandPaths.push(...listMdFiles(sdlcCommands));
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
for (const commandPath of commandPaths) {
|
|
396
|
+
const section = transformCommandToSection(commandPath, opts);
|
|
397
|
+
if (section) {
|
|
398
|
+
content += section + '\n';
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// Aggregate cross-provider rules into WARP.md (#1346 — Warp parity fix).
|
|
403
|
+
// Warp's only rule-delivery channel is WARP.md (no .warp/rules/ scan),
|
|
404
|
+
// so the aiwg-utils rules — including the load-bearing skill-discovery
|
|
405
|
+
// protocol — must be inlined here to reach Warp agents.
|
|
406
|
+
const rulePaths = collectAiwgRulePaths(aiwgRoot).filter(file => {
|
|
407
|
+
const rule = opts.ruleDelivery?.rules.find(rule => rule.file === file);
|
|
408
|
+
return rule ? !rule.tagged : true;
|
|
409
|
+
});
|
|
410
|
+
if (rulePaths.length > 0) {
|
|
411
|
+
content += '---\n\n';
|
|
412
|
+
content += '## AIWG Rules\n\n';
|
|
413
|
+
content += 'These rules govern agent behavior across all AIWG-supported providers. Warp delivers them via this aggregated section because Warp does not natively scan `.warp/rules/`. The full source for each rule lives at `$AIWG_ROOT/agentic/code/addons/aiwg-utils/rules/<rule-name>.md`.\n\n';
|
|
414
|
+
// Place skill-discovery first — it is the load-bearing rule the parity
|
|
415
|
+
// fix exists to surface (per #1343/#1346). Agents that read top-down
|
|
416
|
+
// hit the discover-first protocol immediately.
|
|
417
|
+
const sorted = [...rulePaths].sort((a, b) => {
|
|
418
|
+
const ax = path.basename(a, '.md');
|
|
419
|
+
const bx = path.basename(b, '.md');
|
|
420
|
+
if (ax === 'skill-discovery') return -1;
|
|
421
|
+
if (bx === 'skill-discovery') return 1;
|
|
422
|
+
return ax.localeCompare(bx);
|
|
423
|
+
});
|
|
424
|
+
for (const rulePath of sorted) {
|
|
425
|
+
const section = transformRuleToSection(rulePath);
|
|
426
|
+
if (section) {
|
|
427
|
+
content += section + '\n';
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// On-demand tier (#1675): the MEDIUM/LOW rules NOT inlined above. Warp has no
|
|
433
|
+
// scanned `.warp/rules/` dir, so the bridge notes the tier with fetch hints.
|
|
434
|
+
// Exclude anything already inlined verbatim in the AIWG Rules section.
|
|
435
|
+
const inlinedRuleNames = rulePaths.map((p) => path.basename(p, '.md'));
|
|
436
|
+
const onDemandSection = renderOnDemandRuleSection(
|
|
437
|
+
listOnDemandRuleFiles(aiwgRoot),
|
|
438
|
+
{ exclude: inlinedRuleNames },
|
|
439
|
+
);
|
|
440
|
+
if (onDemandSection) {
|
|
441
|
+
content += '---\n\n';
|
|
442
|
+
content += onDemandSection + '\n\n';
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// Add natural language section
|
|
446
|
+
content += '---\n\n';
|
|
447
|
+
content += '## Natural Language Command Translation\n\n';
|
|
448
|
+
content += 'You can use natural language to trigger SDLC workflows. Examples:\n\n';
|
|
449
|
+
content += '**Phase Transitions**:\n';
|
|
450
|
+
content += '- "Let\'s transition to Elaboration"\n';
|
|
451
|
+
content += '- "Move to Construction"\n';
|
|
452
|
+
content += '- "Ready to deploy"\n\n';
|
|
453
|
+
content += '**Review Cycles**:\n';
|
|
454
|
+
content += '- "Run security review"\n';
|
|
455
|
+
content += '- "Execute test suite"\n';
|
|
456
|
+
content += '- "Check compliance"\n\n';
|
|
457
|
+
content += '**Artifact Generation**:\n';
|
|
458
|
+
content += '- "Create architecture baseline"\n';
|
|
459
|
+
content += '- "Generate SAD"\n';
|
|
460
|
+
content += '- "Build test plan"\n\n';
|
|
461
|
+
content += '**Status Checks**:\n';
|
|
462
|
+
content += '- "Where are we?"\n';
|
|
463
|
+
content += '- "Can we transition?"\n';
|
|
464
|
+
content += '- "Check project health"\n\n';
|
|
465
|
+
|
|
466
|
+
// Add resources
|
|
467
|
+
content += '---\n\n';
|
|
468
|
+
content += '## Resources\n\n';
|
|
469
|
+
content += `- **AIWG Framework**: ${aiwgRoot}/agentic/code/frameworks/sdlc-complete/README.md\n`;
|
|
470
|
+
content += `- **Template Library**: ${aiwgRoot}/agentic/code/frameworks/sdlc-complete/templates/\n`;
|
|
471
|
+
content += `- **Agent Catalog**: ${aiwgRoot}/agentic/code/frameworks/sdlc-complete/agents/\n`;
|
|
472
|
+
content += `- **Natural Language Guide**: ${aiwgRoot}/agentic/code/frameworks/sdlc-complete/docs/simple-language-translations.md\n`;
|
|
473
|
+
content += '- **Warp Documentation**: https://docs.warp.dev/knowledge-and-collaboration/rules\n\n';
|
|
474
|
+
|
|
475
|
+
return content;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Merge WARP.md intelligently (preserve user content, replace AIWG sections)
|
|
480
|
+
*/
|
|
481
|
+
export function mergeWarpMd(existingContent, aiwgContent, force) {
|
|
482
|
+
const start = '<!-- AIWG:warp-context:start -->';
|
|
483
|
+
const end = '<!-- AIWG:warp-context:end -->';
|
|
484
|
+
const managed = `${start}\n${aiwgContent}\n${end}`;
|
|
485
|
+
const clean = (existingContent || '').replace(/\n?<!-- AIWG:rule-startup:start -->[\s\S]*?<!-- AIWG:rule-startup:end -->\n?/g, '');
|
|
486
|
+
if (clean.includes(start)) return clean.replace(/<!-- AIWG:warp-context:start -->[\s\S]*?<!-- AIWG:warp-context:end -->/, managed);
|
|
487
|
+
if (!clean || force) return `# Project Context\n\n${managed}\n`;
|
|
488
|
+
const sections = parseMarkdownSections(clean);
|
|
489
|
+
const user = sections.filter(section => !isAIWGManagedSection(section.heading)).map(section => section.lines.join('\n')).join('\n');
|
|
490
|
+
return `${user.trim()}\n\n${managed}\n`;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Create backup of existing WARP.md
|
|
495
|
+
*/
|
|
496
|
+
function createBackup(warpMdPath) {
|
|
497
|
+
if (!fs.existsSync(warpMdPath)) return null;
|
|
498
|
+
|
|
499
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
500
|
+
const backupPath = `${warpMdPath}.backup-${timestamp}`;
|
|
501
|
+
fs.copyFileSync(warpMdPath, backupPath);
|
|
502
|
+
return backupPath;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Validate WARP.md structure
|
|
507
|
+
*/
|
|
508
|
+
function validateWarpMd(warpMdPath) {
|
|
509
|
+
if (!fs.existsSync(warpMdPath)) {
|
|
510
|
+
return {
|
|
511
|
+
valid: false,
|
|
512
|
+
errors: ['WARP.md not found']
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
const content = fs.readFileSync(warpMdPath, 'utf8');
|
|
517
|
+
const errors = [];
|
|
518
|
+
const warnings = [];
|
|
519
|
+
|
|
520
|
+
// Check for AIWG section
|
|
521
|
+
if (!content.includes('## AIWG')) {
|
|
522
|
+
errors.push('Missing AIWG section');
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// Check for agents
|
|
526
|
+
const agentCount = (content.match(/^### /gm) || []).length;
|
|
527
|
+
if (agentCount < 10) {
|
|
528
|
+
warnings.push(`Only ${agentCount} agents found (expected 58+)`);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// Check for commands
|
|
532
|
+
const commandCount = (content.match(/^### \//gm) || []).length;
|
|
533
|
+
if (commandCount < 10) {
|
|
534
|
+
warnings.push(`Only ${commandCount} commands found (expected 42+)`);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
return {
|
|
538
|
+
valid: errors.length === 0,
|
|
539
|
+
errors,
|
|
540
|
+
warnings,
|
|
541
|
+
agentCount,
|
|
542
|
+
commandCount
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Main execution
|
|
548
|
+
*/
|