hadara 0.3.4-rc.0 → 0.4.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/README.md +29 -29
- package/dist/cli/dashboard.js +16 -4
- package/dist/cli/docs.js +50 -0
- package/dist/cli/doctor.js +74 -3
- package/dist/cli/evidence-json.js +3 -0
- package/dist/cli/evidence.js +72 -0
- package/dist/cli/help.js +4 -3
- package/dist/cli/init.js +608 -122
- package/dist/cli/legacy-boundary.js +77 -0
- package/dist/cli/main.js +28 -0
- package/dist/cli/package-smoke.js +1 -0
- package/dist/cli/release-artifact.js +10 -1
- package/dist/cli/release-publish.js +9 -0
- package/dist/cli/task.js +142 -24
- package/dist/cli/validation.js +81 -0
- package/dist/context/context-pack.js +113 -19
- package/dist/context/session-start.js +61 -21
- package/dist/context/task-extractors.js +3 -2
- package/dist/core/schema.js +14 -0
- package/dist/core/timing.js +12 -0
- package/dist/dev/docker-check.js +3 -2
- package/dist/evidence/evidence.js +134 -11
- package/dist/evidence/semantics.js +3 -1
- package/dist/handoff/handoff-stale-problems.js +6 -1
- package/dist/handoff/handoff-suggestion.js +7 -1
- package/dist/handoff/handoff.js +1 -0
- package/dist/harness/validate.js +434 -72
- package/dist/schemas/close-source.schema.json +33 -0
- package/dist/schemas/docs-inbox.schema.json +50 -0
- package/dist/schemas/docs-read-map.schema.json +83 -0
- package/dist/schemas/docs-register.schema.json +70 -0
- package/dist/schemas/evidence-projection.schema.json +35 -0
- package/dist/schemas/schema-index.json +51 -2
- package/dist/schemas/task-audit-close.schema.json +7 -0
- package/dist/schemas/task-close.schema.json +4 -0
- package/dist/schemas/task-finalize.schema.json +40 -1
- package/dist/schemas/task-status.schema.json +117 -0
- package/dist/schemas/task-workbench.schema.json +97 -2
- package/dist/schemas/validation-run.schema.json +103 -0
- package/dist/services/capability-registry.js +216 -51
- package/dist/services/ci-gate.js +5 -2
- package/dist/services/clean-checkout-smoke.js +4 -2
- package/dist/services/dashboard-bootstrap.js +19 -4
- package/dist/services/dashboard-cache.js +2 -0
- package/dist/services/dashboard-task-detail.js +43 -13
- package/dist/services/dashboard-timeline.js +2 -2
- package/dist/services/docs-registry.js +485 -30
- package/dist/services/evidence-lint.js +9 -3
- package/dist/services/lifecycle-guide.js +11 -12
- package/dist/services/operational-debt.js +8 -14
- package/dist/services/operations-status-service.js +7 -1
- package/dist/services/package-recycle.js +101 -45
- package/dist/services/package-smoke.js +7 -2
- package/dist/services/proof-status.js +2 -0
- package/dist/services/protocol-consistency.js +13 -6
- package/dist/services/protocol-migration.js +2 -1
- package/dist/services/release-artifact.js +3 -2
- package/dist/services/release-closeout.js +2 -1
- package/dist/services/release-diagnostics.js +5 -4
- package/dist/services/release-dry-run.js +3 -2
- package/dist/services/state-projection.js +31 -16
- package/dist/services/task-read-model.js +7 -7
- package/dist/services/task-workbench.js +598 -29
- package/dist/services/validation-run.js +333 -0
- package/dist/services/workbench-next-actions.js +31 -20
- package/dist/services/write-preflight.js +2 -20
- package/dist/task/acceptance.js +27 -5
- package/dist/task/authoring-guidance.js +76 -0
- package/dist/task/lifecycle-next-actions.js +0 -1
- package/dist/task/task-capsule.js +24 -18
- package/dist/task/task-close-repair-plan.js +3 -2
- package/dist/task/task-close.js +319 -39
- package/dist/task/task-complete-flow.js +4 -3
- package/dist/task/task-create.js +1 -0
- package/dist/task/task-finalize.js +161 -28
- package/dist/task/task-finish.js +36 -8
- package/dist/task/task-lifecycle.js +8 -3
- package/dist/task/task-templates.js +5 -24
- package/dist/task/task-upgrade-scaffold.js +11 -60
- package/dist/tui/constants.js +1 -7
- package/dist/tui/read-model.js +6 -4
- package/dist/tui/snapshot.js +14 -2
- package/package.json +1 -1
package/dist/cli/init.js
CHANGED
|
@@ -11,14 +11,15 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
11
11
|
const paths_1 = require("../core/paths");
|
|
12
12
|
const fs_1 = require("../core/fs");
|
|
13
13
|
const args_1 = require("./args");
|
|
14
|
+
const legacy_boundary_1 = require("./legacy-boundary");
|
|
14
15
|
const docs_registry_1 = require("../services/docs-registry");
|
|
15
16
|
const managed_sections_1 = require("../services/managed-sections");
|
|
16
17
|
const INIT_PROFILE_SPECS = {
|
|
17
18
|
basic: {
|
|
18
19
|
profile: 'basic',
|
|
19
|
-
generatedDocsDescription: 'Core
|
|
20
|
+
generatedDocsDescription: 'Core current-state docs, workflow reference, registries, and task directory',
|
|
20
21
|
intendedUse: 'Small projects that need Task Capsules, evidence, and handoff discipline without planning overhead.',
|
|
21
|
-
specialNotes: '
|
|
22
|
+
specialNotes: 'Basic keeps continuation fields in PROJECT_STATE instead of generating AGENT_HANDOFF.',
|
|
22
23
|
docs: {
|
|
23
24
|
architecture: false,
|
|
24
25
|
developmentSlices: false,
|
|
@@ -26,37 +27,40 @@ const INIT_PROFILE_SPECS = {
|
|
|
26
27
|
refactorLog: false,
|
|
27
28
|
securityModel: false,
|
|
28
29
|
testStrategy: false,
|
|
29
|
-
roadmap: false
|
|
30
|
+
roadmap: false,
|
|
31
|
+
agentHandoff: false
|
|
30
32
|
}
|
|
31
33
|
},
|
|
32
34
|
standard: {
|
|
33
35
|
profile: 'standard',
|
|
34
|
-
generatedDocsDescription: 'Core
|
|
35
|
-
intendedUse: 'Most multi-session projects that need
|
|
36
|
+
generatedDocsDescription: 'Core scaffold plus architecture, roadmap, and decision docs',
|
|
37
|
+
intendedUse: 'Most multi-session projects that need lightweight planning and decision context.',
|
|
36
38
|
specialNotes: 'Default profile. Optional integrations must be registered before agents rely on them.',
|
|
37
39
|
docs: {
|
|
38
40
|
architecture: true,
|
|
39
|
-
developmentSlices:
|
|
41
|
+
developmentSlices: false,
|
|
40
42
|
decisions: true,
|
|
41
43
|
refactorLog: false,
|
|
42
44
|
securityModel: false,
|
|
43
|
-
testStrategy:
|
|
44
|
-
roadmap:
|
|
45
|
+
testStrategy: false,
|
|
46
|
+
roadmap: true,
|
|
47
|
+
agentHandoff: false
|
|
45
48
|
}
|
|
46
49
|
},
|
|
47
50
|
governed: {
|
|
48
51
|
profile: 'governed',
|
|
49
|
-
generatedDocsDescription: 'Standard
|
|
52
|
+
generatedDocsDescription: 'Standard scaffold plus handoff and security docs',
|
|
50
53
|
intendedUse: 'Long-lived projects with stronger governance, security boundaries, refactor history, or roadmap-level planning.',
|
|
51
|
-
specialNotes: '
|
|
54
|
+
specialNotes: 'Governed projects generate AGENT_HANDOFF for compact continuation state.',
|
|
52
55
|
docs: {
|
|
53
56
|
architecture: true,
|
|
54
|
-
developmentSlices:
|
|
57
|
+
developmentSlices: false,
|
|
55
58
|
decisions: true,
|
|
56
|
-
refactorLog:
|
|
59
|
+
refactorLog: false,
|
|
57
60
|
securityModel: true,
|
|
58
|
-
testStrategy:
|
|
59
|
-
roadmap: true
|
|
61
|
+
testStrategy: false,
|
|
62
|
+
roadmap: true,
|
|
63
|
+
agentHandoff: true
|
|
60
64
|
}
|
|
61
65
|
}
|
|
62
66
|
};
|
|
@@ -99,17 +103,35 @@ function parseInitProfile(value) {
|
|
|
99
103
|
}
|
|
100
104
|
function handleInitCommand(input) {
|
|
101
105
|
const subcommand = input.args[1];
|
|
106
|
+
if (subcommand === 'help' || (0, args_1.getFlag)(input.args, '--help') || (0, args_1.getFlag)(input.args, '-h')) {
|
|
107
|
+
console.log(renderInitHelp());
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
102
110
|
if (subcommand === 'doctor') {
|
|
103
111
|
printInitFollowUpReport(createInitDoctorReport(input.projectRoot), input.jsonOutput);
|
|
104
112
|
return true;
|
|
105
113
|
}
|
|
106
114
|
if (subcommand === 'upgrade') {
|
|
115
|
+
const legacyReport = (0, legacy_boundary_1.createLegacyMutationBlockedReport)(input.projectRoot, 'init.upgrade');
|
|
116
|
+
if (legacyReport) {
|
|
117
|
+
(0, legacy_boundary_1.printLegacyMutationBlockedReport)(legacyReport, input.jsonOutput === true);
|
|
118
|
+
process.exitCode = 6;
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
107
121
|
const profile = parseInitProfile((0, args_1.getRequiredStringOption)(input.args, '--profile'));
|
|
108
122
|
const report = createInitUpgradeReport(input.projectRoot, profile, getInitFollowUpMode(input.args));
|
|
109
123
|
printInitFollowUpReport(report, input.jsonOutput);
|
|
110
124
|
return true;
|
|
111
125
|
}
|
|
112
126
|
if (subcommand === 'register-doc') {
|
|
127
|
+
if ((0, args_1.getFlag)(input.args, '--execute') === true) {
|
|
128
|
+
const legacyReport = (0, legacy_boundary_1.createLegacyMutationBlockedReport)(input.projectRoot, 'init.register-doc');
|
|
129
|
+
if (legacyReport) {
|
|
130
|
+
(0, legacy_boundary_1.printLegacyMutationBlockedReport)(legacyReport, input.jsonOutput === true);
|
|
131
|
+
process.exitCode = 6;
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
113
135
|
const report = createRequiredReadingRegistrationReport(input.projectRoot, {
|
|
114
136
|
documentPath: (0, args_1.getRequiredStringOption)(input.args, '--path'),
|
|
115
137
|
when: (0, args_1.getRequiredStringOption)(input.args, '--when'),
|
|
@@ -121,6 +143,14 @@ function handleInitCommand(input) {
|
|
|
121
143
|
return true;
|
|
122
144
|
}
|
|
123
145
|
if (subcommand === 'enable-integration') {
|
|
146
|
+
if ((0, args_1.getFlag)(input.args, '--execute') === true) {
|
|
147
|
+
const legacyReport = (0, legacy_boundary_1.createLegacyMutationBlockedReport)(input.projectRoot, 'init.enable-integration');
|
|
148
|
+
if (legacyReport) {
|
|
149
|
+
(0, legacy_boundary_1.printLegacyMutationBlockedReport)(legacyReport, input.jsonOutput === true);
|
|
150
|
+
process.exitCode = 6;
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
124
154
|
const report = createIntegrationEnableReport(input.projectRoot, {
|
|
125
155
|
integration: (0, args_1.getRequiredStringOption)(input.args, '--integration'),
|
|
126
156
|
mode: getInitFollowUpMode(input.args)
|
|
@@ -133,6 +163,25 @@ function handleInitCommand(input) {
|
|
|
133
163
|
console.log(JSON.stringify(report, null, 2));
|
|
134
164
|
return true;
|
|
135
165
|
}
|
|
166
|
+
function renderInitHelp() {
|
|
167
|
+
return `HADARA init
|
|
168
|
+
|
|
169
|
+
Usage:
|
|
170
|
+
hadara init [--profile basic|standard|governed] [--json]
|
|
171
|
+
hadara init doctor [--json]
|
|
172
|
+
hadara init upgrade --profile <profile> [--execute] [--json]
|
|
173
|
+
hadara init register-doc --path <path> --when <text> --purpose <text> [--execute] [--json]
|
|
174
|
+
hadara init enable-integration --integration <name> [--execute] [--json]
|
|
175
|
+
|
|
176
|
+
Profiles:
|
|
177
|
+
basic Core current-state docs, workflow reference, registries, and task directory.
|
|
178
|
+
standard Default profile with architecture, roadmap, and decision docs.
|
|
179
|
+
governed Standard profile plus handoff and security docs.
|
|
180
|
+
|
|
181
|
+
Notes:
|
|
182
|
+
--help is read-only and does not create scaffold files.
|
|
183
|
+
`;
|
|
184
|
+
}
|
|
136
185
|
function getInitFollowUpMode(args) {
|
|
137
186
|
return (0, args_1.getFlag)(args, '--execute') ? 'execute' : 'dry-run';
|
|
138
187
|
}
|
|
@@ -141,39 +190,58 @@ function createGeneratedScaffoldFiles(profile) {
|
|
|
141
190
|
const docsRegistry = (0, docs_registry_1.createSeedDocumentRegistry)(profile);
|
|
142
191
|
const files = [
|
|
143
192
|
{ path: '.hadara/context/HADARA_CONTEXT.md', content: (0, docs_registry_1.createHadaraContextDoc)(profile) },
|
|
193
|
+
{ path: '.hadara/scaffold.json', content: createScaffoldJson(profile) },
|
|
144
194
|
{ path: '.hadara/docs-registry.json', content: (0, docs_registry_1.registryJson)(docsRegistry) },
|
|
145
|
-
{ path: '
|
|
195
|
+
{ path: '.hadara/slot-registry.json', content: createSlotRegistryJson() },
|
|
146
196
|
{ path: 'docs/PROJECT_STATE.md', content: createProjectStateDoc(profile) },
|
|
147
197
|
{ path: 'docs/TASK_BOARD.md', content: createTaskBoardDoc() },
|
|
148
|
-
{ path: 'docs/
|
|
149
|
-
{ path: 'docs/IMPLEMENTATION_SOP.md', content: createImplementationSopDoc(spec) },
|
|
150
|
-
{ path: 'docs/TASK_WORKFLOW_COMMANDS.md', content: createTaskWorkflowCommandsDoc() },
|
|
198
|
+
{ path: 'docs/HADARA_WORKFLOW.md', content: createHadaraWorkflowDoc() },
|
|
151
199
|
{ path: 'AGENTS.md', content: createAgentsDoc(spec) },
|
|
152
|
-
{ path: '.gitignore', content: createGitignoreDoc() }
|
|
200
|
+
{ path: '.gitignore', content: createGitignoreDoc() },
|
|
201
|
+
{ path: 'tasks/.gitkeep', content: '' }
|
|
153
202
|
];
|
|
154
203
|
if (spec.docs.architecture)
|
|
155
204
|
files.push({ path: 'docs/ARCHITECTURE.md', content: createArchitectureDoc(profile) });
|
|
156
|
-
if (spec.docs.developmentSlices)
|
|
157
|
-
files.push({ path: 'docs/DEVELOPMENT_SLICES.md', content: createDevelopmentSlicesDoc() });
|
|
158
205
|
if (spec.docs.decisions)
|
|
159
206
|
files.push({ path: 'docs/DECISIONS.md', content: createDecisionsDoc() });
|
|
160
|
-
if (spec.docs.refactorLog)
|
|
161
|
-
files.push({ path: 'docs/REFACTOR_LOG.md', content: createRefactorLogDoc() });
|
|
162
207
|
if (spec.docs.securityModel)
|
|
163
208
|
files.push({ path: 'docs/SECURITY_MODEL.md', content: createSecurityModelDoc() });
|
|
164
|
-
if (spec.docs.testStrategy)
|
|
165
|
-
files.push({ path: 'docs/TEST_STRATEGY.md', content: createTestStrategyDoc() });
|
|
166
209
|
if (spec.docs.roadmap)
|
|
167
210
|
files.push({ path: 'docs/ROADMAP.md', content: createRoadmapDoc() });
|
|
211
|
+
if (spec.docs.agentHandoff)
|
|
212
|
+
files.push({ path: 'docs/AGENT_HANDOFF.md', content: createAgentHandoffDoc() });
|
|
168
213
|
return files;
|
|
169
214
|
}
|
|
170
215
|
function createInitDoctorReport(projectRoot) {
|
|
171
216
|
const issues = [];
|
|
172
217
|
const actions = [];
|
|
173
|
-
const requiredCore = [
|
|
174
|
-
|
|
218
|
+
const requiredCore = [
|
|
219
|
+
{ path: 'AGENTS.md', code: 'INIT_CORE_DOC_MISSING' },
|
|
220
|
+
{ path: '.gitignore', code: 'INIT_GITIGNORE_MISSING' },
|
|
221
|
+
{ path: '.hadara/context/HADARA_CONTEXT.md', code: 'INIT_CORE_DOC_MISSING' },
|
|
222
|
+
{ path: '.hadara/scaffold.json', code: 'INIT_PROTOCOL_MISSING' },
|
|
223
|
+
{ path: '.hadara/docs-registry.json', code: 'INIT_DOCS_REGISTRY_MISSING' },
|
|
224
|
+
{ path: '.hadara/slot-registry.json', code: 'INIT_SLOT_REGISTRY_MISSING' },
|
|
225
|
+
{ path: 'docs/PROJECT_STATE.md', code: 'INIT_CORE_DOC_MISSING' },
|
|
226
|
+
{ path: 'docs/TASK_BOARD.md', code: 'INIT_CORE_DOC_MISSING' },
|
|
227
|
+
{ path: 'docs/HADARA_WORKFLOW.md', code: 'INIT_WORKFLOW_DOC_MISSING' }
|
|
228
|
+
];
|
|
229
|
+
for (const required of requiredCore) {
|
|
230
|
+
const relativePath = required.path;
|
|
175
231
|
if (!node_fs_1.default.existsSync(node_path_1.default.join(projectRoot, relativePath))) {
|
|
176
|
-
issues.push({ severity: 'error', code:
|
|
232
|
+
issues.push({ severity: 'error', code: required.code, path: relativePath, message: `${relativePath} is missing from the init scaffold.` });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const scaffold = readProjectText(projectRoot, '.hadara/scaffold.json');
|
|
236
|
+
if (scaffold !== null) {
|
|
237
|
+
try {
|
|
238
|
+
const parsed = JSON.parse(scaffold);
|
|
239
|
+
if (parsed.hadaraProtocol !== '0.4') {
|
|
240
|
+
issues.push({ severity: 'error', code: 'INIT_PROTOCOL_UNSUPPORTED', path: '.hadara/scaffold.json', message: '.hadara/scaffold.json must declare hadaraProtocol "0.4".' });
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
issues.push({ severity: 'error', code: 'INIT_PROTOCOL_UNSUPPORTED', path: '.hadara/scaffold.json', message: `.hadara/scaffold.json could not be parsed: ${error instanceof Error ? error.message : String(error)}` });
|
|
177
245
|
}
|
|
178
246
|
}
|
|
179
247
|
for (const relativePath of ['HERMES.md', '.hermes.md']) {
|
|
@@ -192,6 +260,9 @@ function createInitDoctorReport(projectRoot) {
|
|
|
192
260
|
if (sop !== null && mentionsLegacyInitProfile(sop)) {
|
|
193
261
|
issues.push({ severity: 'warning', code: 'INIT_OLD_PROFILE_NAME', path: 'docs/IMPLEMENTATION_SOP.md', message: 'SOP mentions old init profile names.' });
|
|
194
262
|
}
|
|
263
|
+
issues.push(...detectEntryDocDuplication(projectRoot));
|
|
264
|
+
issues.push(...detectRequiredReadingTooBroad(projectRoot));
|
|
265
|
+
issues.push(...detectProductDefaultLeaks(projectRoot));
|
|
195
266
|
issues.push(...detectProfileMetadataMismatches(projectRoot));
|
|
196
267
|
for (const [relativePath, headers] of Object.entries(CANONICAL_TABLE_HEADERS)) {
|
|
197
268
|
const content = readProjectText(projectRoot, relativePath);
|
|
@@ -217,6 +288,110 @@ function createInitDoctorReport(projectRoot) {
|
|
|
217
288
|
function mentionsLegacyInitProfile(content) {
|
|
218
289
|
return /(?:initialized with|profile(?:\s+name)?|init profile)\s+(?:the\s+)?`?(minimal|full|hadara-protocol)`?/i.test(content);
|
|
219
290
|
}
|
|
291
|
+
function detectEntryDocDuplication(projectRoot) {
|
|
292
|
+
const issues = [];
|
|
293
|
+
const agents = readProjectText(projectRoot, 'AGENTS.md');
|
|
294
|
+
if (agents !== null && commandRecipeCount(agents) >= 2) {
|
|
295
|
+
issues.push({
|
|
296
|
+
severity: 'warning',
|
|
297
|
+
code: 'INIT_AGENTS_COMMAND_COOKBOOK',
|
|
298
|
+
path: 'AGENTS.md',
|
|
299
|
+
message: 'AGENTS.md appears to duplicate lifecycle or context command recipes; keep command usage in docs/HADARA_WORKFLOW.md.'
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
const context = readProjectText(projectRoot, '.hadara/context/HADARA_CONTEXT.md');
|
|
303
|
+
if (context !== null && (context.includes('| Document | When to Read | Purpose |') || context.includes('## Required Reading') || commandRecipeCount(context) >= 2)) {
|
|
304
|
+
issues.push({
|
|
305
|
+
severity: 'warning',
|
|
306
|
+
code: 'INIT_CONTEXT_DUPLICATES_WORKFLOW',
|
|
307
|
+
path: '.hadara/context/HADARA_CONTEXT.md',
|
|
308
|
+
message: 'HADARA_CONTEXT.md appears to duplicate Required Reading or command recipes; keep it as a compact routing anchor.'
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
return issues;
|
|
312
|
+
}
|
|
313
|
+
function commandRecipeCount(content) {
|
|
314
|
+
const matches = content.match(/^\s*`?hadara\s+(?:task|context|session|evidence|docs|harness|init)\s+[a-z-]+/gm);
|
|
315
|
+
return new Set(matches ?? []).size;
|
|
316
|
+
}
|
|
317
|
+
function detectRequiredReadingTooBroad(projectRoot) {
|
|
318
|
+
const registry = readDocsRegistryForDoctor(projectRoot);
|
|
319
|
+
if (registry === null)
|
|
320
|
+
return [];
|
|
321
|
+
const broad = registry.documents.filter((doc) => {
|
|
322
|
+
const raw = doc;
|
|
323
|
+
const defaultRead = doc.requiredReading || doc.readWhen.includes('session-start') || doc.readWhen.includes('task-start');
|
|
324
|
+
if (!defaultRead)
|
|
325
|
+
return false;
|
|
326
|
+
return doc.status === 'historical'
|
|
327
|
+
|| doc.status === 'superseded'
|
|
328
|
+
|| doc.status === 'archived'
|
|
329
|
+
|| raw.readTier === 'historical'
|
|
330
|
+
|| raw.readTier === 'excluded'
|
|
331
|
+
|| raw.readTier === 'drift-review'
|
|
332
|
+
|| raw.drift?.reviewRequiredBeforeUse === true
|
|
333
|
+
|| raw.drift?.risk === 'medium'
|
|
334
|
+
|| raw.drift?.risk === 'high';
|
|
335
|
+
});
|
|
336
|
+
return broad.map((doc) => ({
|
|
337
|
+
severity: 'warning',
|
|
338
|
+
code: 'INIT_REQUIRED_READING_TOO_BROAD',
|
|
339
|
+
path: doc.path,
|
|
340
|
+
message: `${doc.path} is in the default read path but is historical, excluded, superseded, archived, or drift-risk.`
|
|
341
|
+
}));
|
|
342
|
+
}
|
|
343
|
+
function readDocsRegistryForDoctor(projectRoot) {
|
|
344
|
+
const registryPath = node_path_1.default.join(projectRoot, docs_registry_1.DOCS_REGISTRY_PATH);
|
|
345
|
+
if (!node_fs_1.default.existsSync(registryPath))
|
|
346
|
+
return null;
|
|
347
|
+
try {
|
|
348
|
+
return JSON.parse(node_fs_1.default.readFileSync(registryPath, 'utf8'));
|
|
349
|
+
}
|
|
350
|
+
catch {
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
function detectProductDefaultLeaks(projectRoot) {
|
|
355
|
+
const paths = [
|
|
356
|
+
'AGENTS.md',
|
|
357
|
+
'.hadara/context/HADARA_CONTEXT.md',
|
|
358
|
+
'docs/HADARA_WORKFLOW.md',
|
|
359
|
+
'docs/PROJECT_STATE.md',
|
|
360
|
+
'docs/AGENT_HANDOFF.md',
|
|
361
|
+
'docs/ARCHITECTURE.md',
|
|
362
|
+
'docs/ROADMAP.md',
|
|
363
|
+
'docs/DECISIONS.md',
|
|
364
|
+
'docs/SECURITY_MODEL.md'
|
|
365
|
+
];
|
|
366
|
+
const issues = [];
|
|
367
|
+
for (const relativePath of paths) {
|
|
368
|
+
const content = readProjectText(projectRoot, relativePath);
|
|
369
|
+
if (content === null)
|
|
370
|
+
continue;
|
|
371
|
+
const token = productDefaultLeakToken(content);
|
|
372
|
+
if (token) {
|
|
373
|
+
issues.push({
|
|
374
|
+
severity: 'warning',
|
|
375
|
+
code: 'INIT_PRODUCT_DEFAULT_LEAK',
|
|
376
|
+
path: relativePath,
|
|
377
|
+
message: `${relativePath} appears to contain project-specific generated default text (${token}); product scaffolds must stay generic.`
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return issues;
|
|
382
|
+
}
|
|
383
|
+
function productDefaultLeakToken(content) {
|
|
384
|
+
const checks = [
|
|
385
|
+
[/\bHADARA-dev\b/, 'HADARA-dev'],
|
|
386
|
+
[/\bDocker\b|\bdocker\s+(?:exec|run|compose|ps|build)\b/i, 'Docker'],
|
|
387
|
+
[/\bnpm\s+(?:run|publish|view|ci|install|pack)\b/i, 'npm'],
|
|
388
|
+
[/\bnode\s+dist\/cli\/main\.js\b/i, 'node dist/cli/main.js'],
|
|
389
|
+
[/\bhadara\s+(?:release|package|smoke)\s+(?:publish|artifact|gate|dry-run|closeout|smoke|recycle|clean-checkout)\b/i, 'release/package command'],
|
|
390
|
+
[/\/workspace\b|\/mnt\/|[A-Za-z]:\\/, 'machine-local path'],
|
|
391
|
+
[/\bhadara@\d+\.\d+\.\d+/, 'package version']
|
|
392
|
+
];
|
|
393
|
+
return checks.find(([pattern]) => pattern.test(content))?.[1] ?? null;
|
|
394
|
+
}
|
|
220
395
|
function createInitUpgradeReport(projectRoot, profile, mode) {
|
|
221
396
|
const actions = [];
|
|
222
397
|
const issues = [];
|
|
@@ -415,7 +590,12 @@ function createSopRowUpdatePlan(projectRoot, input) {
|
|
|
415
590
|
const sopPath = node_path_1.default.join(projectRoot, 'docs', 'IMPLEMENTATION_SOP.md');
|
|
416
591
|
const sop = node_fs_1.default.existsSync(sopPath) ? node_fs_1.default.readFileSync(sopPath, 'utf8') : null;
|
|
417
592
|
if (sop === null) {
|
|
418
|
-
issues.push({
|
|
593
|
+
issues.push({
|
|
594
|
+
severity: 'error',
|
|
595
|
+
code: 'INIT_SOP_MISSING',
|
|
596
|
+
path: 'docs/IMPLEMENTATION_SOP.md',
|
|
597
|
+
message: 'Legacy SOP Required Reading cannot be updated because IMPLEMENTATION_SOP.md is missing. In 0.4 projects, use `hadara docs register` to write .hadara/docs-registry.json metadata instead.'
|
|
598
|
+
});
|
|
419
599
|
return { ok: false, actions, issues };
|
|
420
600
|
}
|
|
421
601
|
if (!input.allowMissingDocument && !node_fs_1.default.existsSync(node_path_1.default.join(projectRoot, input.relativePath))) {
|
|
@@ -456,10 +636,11 @@ function createSopRowUpdatePlan(projectRoot, input) {
|
|
|
456
636
|
};
|
|
457
637
|
}
|
|
458
638
|
const CANONICAL_TABLE_HEADERS = {
|
|
459
|
-
'AGENTS.md': ['|
|
|
639
|
+
'AGENTS.md': ['| Document | When to Read | Purpose |'],
|
|
460
640
|
'docs/PROJECT_STATE.md': ['| Field | Value |', '| Area | Status | Notes |', '| Source | Path | Purpose |'],
|
|
461
641
|
'docs/AGENT_HANDOFF.md': ['| Area | State | Notes |', '| Task | Summary | Evidence |', '| Issue | Impact | Next Step |', '| Step | Reason | Done Evidence |', '| Check | Latest Evidence | Notes |', '| History Type | Path | When to Use |'],
|
|
462
642
|
'docs/TASK_BOARD.md': ['| ID | Title | Status | Capsule | Notes |'],
|
|
643
|
+
'docs/HADARA_WORKFLOW.md': ['| Order | Authority | Allowed Reads |', '| Gate | Required State |', '| Timing | Update |', '| Situation | Use | Notes |', '| Surface | Human / Operator | Agent | CLI |'],
|
|
463
644
|
'docs/IMPLEMENTATION_SOP.md': ['| Document | When to Read | Purpose |', '| Profile | Scale | Generated Docs | Intended Use | Special Notes |', '| Document | Required Structure |'],
|
|
464
645
|
'docs/TASK_WORKFLOW_COMMANDS.md': ['| Command | Default Write Behavior | Notes |'],
|
|
465
646
|
'docs/ARCHITECTURE.md': ['| Field | Value |', '| Boundary | Rule | Notes |', '| Component | Path / Surface | Responsibility | Status |'],
|
|
@@ -696,21 +877,21 @@ function detectProfileMetadataMismatches(projectRoot) {
|
|
|
696
877
|
return issues;
|
|
697
878
|
}
|
|
698
879
|
function inferProfileFromGeneratedDocs(projectRoot) {
|
|
699
|
-
if (['docs/SECURITY_MODEL.md', 'docs/
|
|
880
|
+
if (['docs/SECURITY_MODEL.md', 'docs/AGENT_HANDOFF.md'].some((relativePath) => node_fs_1.default.existsSync(node_path_1.default.join(projectRoot, relativePath)))) {
|
|
700
881
|
return 'governed';
|
|
701
882
|
}
|
|
702
|
-
if (['docs/ARCHITECTURE.md', 'docs/
|
|
883
|
+
if (['docs/ARCHITECTURE.md', 'docs/DECISIONS.md', 'docs/ROADMAP.md'].some((relativePath) => node_fs_1.default.existsSync(node_path_1.default.join(projectRoot, relativePath)))) {
|
|
703
884
|
return 'standard';
|
|
704
885
|
}
|
|
705
886
|
return 'basic';
|
|
706
887
|
}
|
|
707
888
|
function requiredDocsForProfile(profile) {
|
|
708
|
-
const docs = ['docs/PROJECT_STATE.md', 'docs/
|
|
889
|
+
const docs = ['docs/PROJECT_STATE.md', 'docs/TASK_BOARD.md', 'docs/HADARA_WORKFLOW.md'];
|
|
709
890
|
if (profile === 'standard' || profile === 'governed') {
|
|
710
|
-
docs.push('docs/ARCHITECTURE.md', 'docs/
|
|
891
|
+
docs.push('docs/ARCHITECTURE.md', 'docs/DECISIONS.md', 'docs/ROADMAP.md');
|
|
711
892
|
}
|
|
712
893
|
if (profile === 'governed') {
|
|
713
|
-
docs.push('docs/
|
|
894
|
+
docs.push('docs/AGENT_HANDOFF.md', 'docs/SECURITY_MODEL.md');
|
|
714
895
|
}
|
|
715
896
|
return docs;
|
|
716
897
|
}
|
|
@@ -755,6 +936,339 @@ function parseIntegration(value) {
|
|
|
755
936
|
return value;
|
|
756
937
|
throw new Error(`unsupported init integration: ${value}; expected hermes or mcp`);
|
|
757
938
|
}
|
|
939
|
+
function createScaffoldJson(profile) {
|
|
940
|
+
return `${JSON.stringify({
|
|
941
|
+
schemaVersion: 'hadara.projectScaffold.v1',
|
|
942
|
+
hadaraProtocol: '0.4',
|
|
943
|
+
profile,
|
|
944
|
+
taskCapsuleSchema: 'hadara.taskCapsule.v1',
|
|
945
|
+
docsRegistrySchema: 'hadara.docsRegistry.v2',
|
|
946
|
+
managedSlotSchema: 'hadara.managedSlot.v2',
|
|
947
|
+
createdWith: 'hadara@0.4.0',
|
|
948
|
+
docsRegistryPath: '.hadara/docs-registry.json',
|
|
949
|
+
slotRegistryPath: '.hadara/slot-registry.json'
|
|
950
|
+
}, null, 2)}\n`;
|
|
951
|
+
}
|
|
952
|
+
function createSlotRegistryJson() {
|
|
953
|
+
return `${JSON.stringify({
|
|
954
|
+
schemaVersion: 'hadara.managedSlot.registry.v1',
|
|
955
|
+
registryVersion: 1,
|
|
956
|
+
slots: [
|
|
957
|
+
{
|
|
958
|
+
id: 'task.identity',
|
|
959
|
+
schemaVersion: 'hadara.managedSlot.v2',
|
|
960
|
+
owner: 'task.lifecycle',
|
|
961
|
+
allowedPaths: ['tasks/*/TASK.md'],
|
|
962
|
+
closeSourceRole: 'included',
|
|
963
|
+
kind: 'key-value-table',
|
|
964
|
+
fields: [
|
|
965
|
+
{ name: 'ID', required: true, editable: 'cli-only', pattern: '^T-[0-9]{4,}$' },
|
|
966
|
+
{ name: 'Title', required: true, editable: 'cli-on-create' },
|
|
967
|
+
{ name: 'Status', required: true, editable: 'lifecycle-or-constrained-md', allowedValues: ['Draft', 'In Progress', 'Blocked', 'Done', 'Partial', 'Superseded', 'Archived'] },
|
|
968
|
+
{ name: 'Created', required: true, editable: 'cli-only', pattern: '^\\\\d{4}-\\\\d{2}-\\\\d{2}$' },
|
|
969
|
+
{ name: 'Updated', required: true, editable: 'cli-or-managed', pattern: '^\\\\d{4}-\\\\d{2}-\\\\d{2}$' }
|
|
970
|
+
]
|
|
971
|
+
}
|
|
972
|
+
],
|
|
973
|
+
tableSchemas: [
|
|
974
|
+
{
|
|
975
|
+
id: 'task.acceptance',
|
|
976
|
+
kind: 'markdown-table',
|
|
977
|
+
allowedPaths: ['tasks/*/TASK.md'],
|
|
978
|
+
closeSourceRole: 'included',
|
|
979
|
+
columns: [
|
|
980
|
+
{ name: 'ID', pattern: '^AC-[0-9]+$', required: true },
|
|
981
|
+
{ name: 'Criterion', editable: 'agent-derived-prose', required: true },
|
|
982
|
+
{ name: 'Required', allowedValues: ['Yes', 'No'], required: true },
|
|
983
|
+
{ name: 'Status', allowedValues: ['Pending', 'Met', 'Not Met', 'Blocked', 'Not Applicable'], required: true },
|
|
984
|
+
{ name: 'Evidence', pattern: '^(TBD|ev:.*|)$', required: false },
|
|
985
|
+
{ name: 'Disposition', allowedValues: ['Required', 'Optional', 'Deferred', 'Accepted Risk', 'Not Applicable', 'Superseded'], required: true },
|
|
986
|
+
{ name: 'Reference', requiredWhenDispositionIn: ['Deferred', 'Accepted Risk', 'Superseded'] }
|
|
987
|
+
]
|
|
988
|
+
}
|
|
989
|
+
]
|
|
990
|
+
}, null, 2)}\n`;
|
|
991
|
+
}
|
|
992
|
+
function createHadaraWorkflowDoc() {
|
|
993
|
+
return `# HADARA_WORKFLOW
|
|
994
|
+
|
|
995
|
+
## Purpose
|
|
996
|
+
|
|
997
|
+
This document explains when to use HADARA CLI surfaces and when to update HADARA documents during normal project work.
|
|
998
|
+
|
|
999
|
+
Use HADARA read models first. Do not manually read broad project files unless a HADARA command points you there or the task explicitly requires it.
|
|
1000
|
+
|
|
1001
|
+
## Quickstart
|
|
1002
|
+
|
|
1003
|
+
Use this section for the first pass through a new scaffold. Read the detailed sections below only when you reach that situation.
|
|
1004
|
+
|
|
1005
|
+
| Situation | First Action |
|
|
1006
|
+
|---|---|
|
|
1007
|
+
| New project created | Read \`AGENTS.md\`, then \`.hadara/context/HADARA_CONTEXT.md\`, then this Quickstart. |
|
|
1008
|
+
| Need work to do | Run \`hadara task status --json\`. |
|
|
1009
|
+
| Need a task | Run \`hadara task create "task title" --json\`, then fill \`TASK.md\` Goal, Source Documents, Plan, and Acceptance. |
|
|
1010
|
+
| Need files to inspect | Run \`hadara session start --task T-XXXX --json\` or \`hadara context pack --task T-XXXX --json\`, then read only routed files. |
|
|
1011
|
+
| Ready to close | Run \`hadara task finalize --task T-XXXX --json\`, inspect the plan hash, then execute finalize with that hash. |
|
|
1012
|
+
|
|
1013
|
+
## Minimal Loop
|
|
1014
|
+
|
|
1015
|
+
\`\`\`text
|
|
1016
|
+
1. \`hadara task status --json\`
|
|
1017
|
+
2. \`hadara session start --task T-XXXX --json\` when resuming or changing tasks
|
|
1018
|
+
3. \`hadara task create "task title" --json\` only when no suitable capsule exists
|
|
1019
|
+
4. update \`TASK.md\`
|
|
1020
|
+
5. implement the scoped change
|
|
1021
|
+
6. run real validation
|
|
1022
|
+
7. record evidence
|
|
1023
|
+
8. update task/global docs
|
|
1024
|
+
9. review \`task finalize --json\`
|
|
1025
|
+
10. execute finalize only with the reviewed plan hash
|
|
1026
|
+
\`\`\`
|
|
1027
|
+
|
|
1028
|
+
## Read Authority Rules
|
|
1029
|
+
|
|
1030
|
+
Agents must follow this read order:
|
|
1031
|
+
|
|
1032
|
+
| Order | Authority | Allowed Reads |
|
|
1033
|
+
|---:|---|---|
|
|
1034
|
+
| 1 | HADARA CLI read models | \`session start\`, \`task status\`, \`context pack\`, docs registry/read-map reports. |
|
|
1035
|
+
| 2 | Command-returned paths | Files, ranges, candidates, or docs explicitly returned by those read models. |
|
|
1036
|
+
| 3 | Active Task Capsule | \`TASK.md\`, \`HANDOFF.md\`, \`EVIDENCE.md\`, and task-local evidence summaries for the selected task. |
|
|
1037
|
+
| 4 | Shared state docs | Only when Required Reading says every session, or when a read model/task explicitly references them. |
|
|
1038
|
+
| 5 | Conditional reference docs | Only when the task, registry, read-map, or source document table points to them. |
|
|
1039
|
+
|
|
1040
|
+
Agents must not scan the repository, open unrelated docs, or infer current state from directory structure when a HADARA read model can route the read.
|
|
1041
|
+
|
|
1042
|
+
## Project Start
|
|
1043
|
+
|
|
1044
|
+
Use \`hadara init\` only when creating a new HADARA project or initializing HADARA in an existing project that is not already governed by another HADARA protocol.
|
|
1045
|
+
|
|
1046
|
+
\`\`\`bash
|
|
1047
|
+
hadara init --json
|
|
1048
|
+
hadara init --profile basic --json
|
|
1049
|
+
hadara init --profile standard --json
|
|
1050
|
+
hadara init --profile governed --json
|
|
1051
|
+
hadara init doctor --json
|
|
1052
|
+
\`\`\`
|
|
1053
|
+
|
|
1054
|
+
After init, review:
|
|
1055
|
+
|
|
1056
|
+
| Step | Document | Purpose |
|
|
1057
|
+
|---|---|---|
|
|
1058
|
+
| 1 | \`AGENTS.md\` | Entry rules and required reading. |
|
|
1059
|
+
| 2 | \`.hadara/context/HADARA_CONTEXT.md\` | Compact read routing. |
|
|
1060
|
+
| 3 | \`docs/PROJECT_STATE.md\` | Initial project state and next recommended step. |
|
|
1061
|
+
| 4 | \`docs/TASK_BOARD.md\` | Task index. |
|
|
1062
|
+
| 5 | \`docs/HADARA_WORKFLOW.md\` | How to work with HADARA from this point forward. |
|
|
1063
|
+
|
|
1064
|
+
Use project-specific docs only after they are created and routed through the docs registry, a read-map, or the active task.
|
|
1065
|
+
|
|
1066
|
+
## Session Start
|
|
1067
|
+
|
|
1068
|
+
Use session start at the beginning of a work session, after switching tasks, or when project state is unclear.
|
|
1069
|
+
|
|
1070
|
+
\`\`\`bash
|
|
1071
|
+
hadara session start --json
|
|
1072
|
+
hadara session start --task T-XXXX --json
|
|
1073
|
+
\`\`\`
|
|
1074
|
+
|
|
1075
|
+
Session start is a read model. It does not create tasks, append evidence, warm caches, validate completion, or close work.
|
|
1076
|
+
|
|
1077
|
+
## Selecting or Creating Work
|
|
1078
|
+
|
|
1079
|
+
\`\`\`bash
|
|
1080
|
+
hadara task status --json
|
|
1081
|
+
hadara task create "task title" --json
|
|
1082
|
+
hadara task status --task T-XXXX --json
|
|
1083
|
+
\`\`\`
|
|
1084
|
+
|
|
1085
|
+
Use \`task status --json\` to decide what to work on when no task is selected. Use \`task create\` only when no suitable capsule exists. Use \`task status --task T-XXXX --json\` as a fast selected-task loop cockpit for evidence, loop phase, and suggested next actions. Use \`task finalize --task T-XXXX --json\` or \`task status --task T-XXXX --detail full --json\` when you need close-grade readiness diagnostics.
|
|
1086
|
+
|
|
1087
|
+
## Task Context
|
|
1088
|
+
|
|
1089
|
+
\`\`\`bash
|
|
1090
|
+
hadara context pack --task T-XXXX --json
|
|
1091
|
+
\`\`\`
|
|
1092
|
+
|
|
1093
|
+
Use context pack when starting implementation, resuming after a gap, deciding which files to inspect, or avoiding broad manual repo reads. Context pack is reading guidance, not validation.
|
|
1094
|
+
|
|
1095
|
+
After context pack:
|
|
1096
|
+
|
|
1097
|
+
1. Select only relevant files or candidates from the report.
|
|
1098
|
+
2. Use \`context slice\` for exact source reads when a range/candidate is available.
|
|
1099
|
+
3. Add or update \`TASK.md\` Source Documents for sources that constrain the work.
|
|
1100
|
+
|
|
1101
|
+
## Exact Source Slices
|
|
1102
|
+
|
|
1103
|
+
\`\`\`bash
|
|
1104
|
+
hadara context slice --path <path> --from <line> --to <line> --json
|
|
1105
|
+
hadara context slice --task T-XXXX --candidate <candidate-id> --json
|
|
1106
|
+
\`\`\`
|
|
1107
|
+
|
|
1108
|
+
Use context slice only after a read model points to a specific file or range.
|
|
1109
|
+
|
|
1110
|
+
## Task Capsule Lifecycle
|
|
1111
|
+
|
|
1112
|
+
The normal task lifecycle is:
|
|
1113
|
+
|
|
1114
|
+
\`\`\`text
|
|
1115
|
+
select or create task
|
|
1116
|
+
read task context
|
|
1117
|
+
author task contract
|
|
1118
|
+
do scoped work
|
|
1119
|
+
record evidence
|
|
1120
|
+
finish task docs and shared state
|
|
1121
|
+
review finalize plan
|
|
1122
|
+
execute finalize with the reviewed plan hash
|
|
1123
|
+
stop when finalize returns closed-valid
|
|
1124
|
+
\`\`\`
|
|
1125
|
+
|
|
1126
|
+
Use the high-level lifecycle path for ordinary work:
|
|
1127
|
+
|
|
1128
|
+
\`\`\`bash
|
|
1129
|
+
hadara task status --task T-XXXX --json
|
|
1130
|
+
hadara task finalize --task T-XXXX --json
|
|
1131
|
+
hadara task finalize --task T-XXXX --execute --plan-hash sha256:... --json
|
|
1132
|
+
\`\`\`
|
|
1133
|
+
|
|
1134
|
+
Low-level lifecycle commands are for debugging, recovery, or command implementation work:
|
|
1135
|
+
|
|
1136
|
+
\`\`\`bash
|
|
1137
|
+
hadara task finish --task T-XXXX --json
|
|
1138
|
+
hadara task ready --task T-XXXX --level done --json
|
|
1139
|
+
hadara task close --task T-XXXX --json
|
|
1140
|
+
\`\`\`
|
|
1141
|
+
|
|
1142
|
+
## Finalize Entry Gate
|
|
1143
|
+
|
|
1144
|
+
Before running \`hadara task finalize\`, all of these must be true:
|
|
1145
|
+
|
|
1146
|
+
| Gate | Required State |
|
|
1147
|
+
|---|---|
|
|
1148
|
+
| Goal | \`TASK.md\` has a concrete task goal. |
|
|
1149
|
+
| Source Documents | Relevant sources are listed, or the task explicitly records that none are required. |
|
|
1150
|
+
| Plan | \`TASK.md\` Plan has the intended work steps. |
|
|
1151
|
+
| Acceptance | \`TASK.md\` Acceptance has the completion criteria. |
|
|
1152
|
+
| Validation | At least one validation method is defined, or a documented reason explains why validation is not applicable. |
|
|
1153
|
+
|
|
1154
|
+
Do not use status/finalize to avoid authoring the task contract.
|
|
1155
|
+
|
|
1156
|
+
## Task Document Timing
|
|
1157
|
+
|
|
1158
|
+
HADARA 0.4 Task Capsules contain \`TASK.md\`, \`HANDOFF.md\`, \`EVIDENCE.md\`, and \`evidence.jsonl\`.
|
|
1159
|
+
|
|
1160
|
+
| Timing | Update |
|
|
1161
|
+
|---|---|
|
|
1162
|
+
| Capsule created | Start \`TASK.md\` Goal, Source Documents, Plan, and Acceptance. |
|
|
1163
|
+
| Before execution | Refine \`TASK.md\` Plan, Source Documents, and Acceptance. |
|
|
1164
|
+
| During execution | Update \`TASK.md\` Plan, Change Summary, Risks / Follow-ups; update \`HANDOFF.md\` warnings if continuity changes. |
|
|
1165
|
+
| After validation | Use \`validation run\` when possible; record evidence, then update \`TASK.md\` Validation and Acceptance deliberately with evidence ids or residual notes. |
|
|
1166
|
+
| Before finalize dry-run | Finish \`TASK.md\` Change Summary, Acceptance, Validation, Risks / Follow-ups; update \`HANDOFF.md\`; update shared state docs when the task changed them. |
|
|
1167
|
+
| Finalize review | Inspect \`task finalize --json\` dry-run output and fix reported blockers before execute. |
|
|
1168
|
+
| Finalize execute | Do not edit close-source docs during execute. |
|
|
1169
|
+
| After close | Only clarify docs if the task contract did not change; rerun finalize after close-source edits. |
|
|
1170
|
+
|
|
1171
|
+
Do not hand-edit \`evidence.jsonl\`. Treat \`EVIDENCE.md\` as a CLI-generated projection file.
|
|
1172
|
+
|
|
1173
|
+
## Evidence
|
|
1174
|
+
|
|
1175
|
+
\`\`\`bash
|
|
1176
|
+
hadara validation run --task T-XXXX --check "Focused tests" -- npm test
|
|
1177
|
+
hadara evidence add-command --task T-XXXX --summary "..." --result passed --category validation --json
|
|
1178
|
+
hadara evidence summary --task T-XXXX --json
|
|
1179
|
+
hadara evidence project --task T-XXXX --json
|
|
1180
|
+
\`\`\`
|
|
1181
|
+
|
|
1182
|
+
Use \`validation run\` for ordinary validation because it executes the command, records durable evidence from the real exit status, and refreshes \`EVIDENCE.md\`. Add \`--update-task\` only when you intentionally want the matching \`TASK.md\` Validation row updated by the CLI.
|
|
1183
|
+
|
|
1184
|
+
Use \`evidence add-command\` only when recording an already-run result supplied by the operator. It does not execute shell commands. Use \`evidence summary\` to find durable evidence ids for docs and resolution markers.
|
|
1185
|
+
|
|
1186
|
+
Evidence must reflect real execution results. Fabricated or assumed results are invalid.
|
|
1187
|
+
|
|
1188
|
+
\`evidence project\` is the 0.4 projection refresh surface. It refreshes the generated \`EVIDENCE.md\` projection file without rewriting canonical evidence.
|
|
1189
|
+
|
|
1190
|
+
## Repair and Diagnostics
|
|
1191
|
+
|
|
1192
|
+
\`\`\`bash
|
|
1193
|
+
hadara task audit-close --task T-XXXX --json
|
|
1194
|
+
hadara harness validate --task T-XXXX --level done --json
|
|
1195
|
+
hadara init doctor --json
|
|
1196
|
+
\`\`\`
|
|
1197
|
+
|
|
1198
|
+
Use finalize dry-run as the ordinary close-proof repair plan. Use diagnostics when finalize reports blockers. Do not repair close proof by editing evidence files by hand.
|
|
1199
|
+
|
|
1200
|
+
Agents must not run \`task finalize --execute\` without inspecting the dry-run output and using the current \`planHash\` from that reviewed dry-run.
|
|
1201
|
+
|
|
1202
|
+
## Useful CLI by Situation
|
|
1203
|
+
|
|
1204
|
+
| Situation | Use | Notes |
|
|
1205
|
+
|---|---|---|
|
|
1206
|
+
| New HADARA project | \`hadara init --profile <profile> --json\` | Creates scaffold docs and registries. |
|
|
1207
|
+
| Check scaffold health | \`hadara init doctor --json\` | Reports missing or inconsistent scaffold files. |
|
|
1208
|
+
| Find next work | \`hadara task status --json\` | Read-only selection cockpit. |
|
|
1209
|
+
| Inspect selected task | \`hadara task status --task T-XXXX --json\` | Fast loop phase and next-action projection. |
|
|
1210
|
+
| Inspect close-grade diagnostics | \`hadara task status --task T-XXXX --detail full --json\` | Heavier readiness/protocol projection for explicit diagnostics. |
|
|
1211
|
+
| Find task-specific context | \`hadara context pack --task T-XXXX --json\` | Use before broad manual reads. |
|
|
1212
|
+
| Read exact source text | \`hadara context slice ... --json\` | Use after a context candidate points to a range. |
|
|
1213
|
+
| Run and record validation | \`hadara validation run --task T-XXXX --check "..." -- <command>\` | Executes the command and records evidence without editing \`TASK.md\` by default. |
|
|
1214
|
+
| Run, record, and sync task row | \`hadara validation run --task T-XXXX --check "..." --update-task -- <command>\` | Executes the command, records evidence, and updates the matching \`TASK.md\` Validation row. |
|
|
1215
|
+
| Record already-run validation | \`hadara evidence add-command ... --json\` | Append-only evidence writer; does not execute commands. |
|
|
1216
|
+
| Find evidence ids | \`hadara evidence summary --task T-XXXX --json\` | Compact copy hints. |
|
|
1217
|
+
| Review loop phase | \`hadara task status --task T-XXXX --json\` | Normal lifecycle state and next action. |
|
|
1218
|
+
| Close ordinary work | \`hadara task finalize --task T-XXXX --json\` then execute with its \`planHash\` | Default close path. |
|
|
1219
|
+
| Repair close drift | \`hadara task finalize --task T-XXXX --json\` then execute with its \`planHash\` | Default repair path for stale close proof. |
|
|
1220
|
+
| Register project-specific docs | \`hadara docs register --path <path> --json\` | 0.4 registry surface. Canonical state belongs in \`.hadara/docs-registry.json\`; use registry-backed help for exact options. |
|
|
1221
|
+
| Discover command details | \`hadara help lifecycle\`, \`hadara help command <id>\`, \`hadara commands --json\` | Prefer registry-backed help over copied command tables. |
|
|
1222
|
+
|
|
1223
|
+
## Common Failure Modes
|
|
1224
|
+
|
|
1225
|
+
| Failure Mode | Correct Behavior |
|
|
1226
|
+
|---|---|
|
|
1227
|
+
| Skipping read models and scanning the repository. | Start with session/task/context read models and only open routed files. |
|
|
1228
|
+
| Opening unrelated specs or historical docs. | Use read tiers, registry metadata, and context pack candidates. |
|
|
1229
|
+
| Running lifecycle before \`TASK.md\` is authored. | Satisfy the Lifecycle Entry Gate first. |
|
|
1230
|
+
| Treating context pack as validation. | Use it only for read guidance; run real checks separately. |
|
|
1231
|
+
| Recording evidence for checks that were not run. | Record only real execution results, including failed or blocked checks. |
|
|
1232
|
+
| Running finalize execute from memory. | Review fresh dry-run output and copy its current plan hash. |
|
|
1233
|
+
| Putting same-capsule chores in \`HANDOFF.md\` Next Recommended Step. | Use that section for next capsule or global-state recommendations. |
|
|
1234
|
+
|
|
1235
|
+
## Design Source Documents and Read Maps
|
|
1236
|
+
|
|
1237
|
+
Design source documents may live under \`docs/specs/**\` or other registered paths. Use registry/read-map output to decide whether they are active, conditional, implemented, drift-risk, historical, or excluded.
|
|
1238
|
+
|
|
1239
|
+
Do not treat every file under \`docs/specs/**\` as default Required Reading.
|
|
1240
|
+
|
|
1241
|
+
Document registration writes registry metadata, not prose rows in entry docs. Do not append project-specific document rows to \`AGENTS.md\`, \`.hadara/context/HADARA_CONTEXT.md\`, or this workflow document.
|
|
1242
|
+
|
|
1243
|
+
## Authoring Model
|
|
1244
|
+
|
|
1245
|
+
| Surface | Human / Operator | Agent | CLI |
|
|
1246
|
+
|---|---|---|---|
|
|
1247
|
+
| Requirements and source docs | Provides and approves | Summarizes into task docs | Indexes/read-map only |
|
|
1248
|
+
| \`TASK.md\` identity | Reviews | Does not hand-edit CLI-owned fields | Creates and lifecycle-updates |
|
|
1249
|
+
| \`TASK.md\` prose/tables | Reviews | Authors goal, source documents, plan, acceptance, validation, change summary, risks, and follow-ups | Validates controlled values |
|
|
1250
|
+
| \`HANDOFF.md\` | Reviews | Writes continuation guidance | May suggest or project summaries |
|
|
1251
|
+
| \`evidence.jsonl\` | Supplies command result facts | Does not hand-edit | Appends canonical evidence |
|
|
1252
|
+
| \`EVIDENCE.md\` | Reads | Does not hand-edit generated projection | Regenerates projection file |
|
|
1253
|
+
| Close proof | Reviews | Does not write by hand | Appends proof and audits freshness |
|
|
1254
|
+
|
|
1255
|
+
## Automatic Writing Boundary
|
|
1256
|
+
|
|
1257
|
+
HADARA auto-writes deterministic state, managed slots, indexes, evidence projections, and close snapshots. It reports read-only guidance for missing task prose.
|
|
1258
|
+
|
|
1259
|
+
Agents write task-specific goal, source documents, plan, acceptance, validation, change summary, risks, follow-ups, and handoff guidance from user requirements and source documents.
|
|
1260
|
+
|
|
1261
|
+
## Drift Avoidance
|
|
1262
|
+
|
|
1263
|
+
Do not duplicate command registry metadata. For detailed options, point to registry-backed help:
|
|
1264
|
+
|
|
1265
|
+
\`\`\`bash
|
|
1266
|
+
hadara help lifecycle
|
|
1267
|
+
hadara help command <id>
|
|
1268
|
+
hadara commands --json
|
|
1269
|
+
\`\`\`
|
|
1270
|
+
`;
|
|
1271
|
+
}
|
|
758
1272
|
function createHermesIntegrationDoc() {
|
|
759
1273
|
return `# Hermes Integration
|
|
760
1274
|
|
|
@@ -795,6 +1309,9 @@ function createMcpIntegrationDoc() {
|
|
|
795
1309
|
`;
|
|
796
1310
|
}
|
|
797
1311
|
function createProjectStateDoc(profile) {
|
|
1312
|
+
const handoffRow = profile === 'governed'
|
|
1313
|
+
? '| Next-session handoff | `docs/AGENT_HANDOFF.md` | Compact continuation state. |\n'
|
|
1314
|
+
: '';
|
|
798
1315
|
const productTable = (0, managed_sections_1.managedSectionBlock)('project-state-metadata', {
|
|
799
1316
|
schema: 'hadara.managedSection.v1',
|
|
800
1317
|
owner: 'project-state.update',
|
|
@@ -836,7 +1353,7 @@ ${productTable}
|
|
|
836
1353
|
|---|---|---|
|
|
837
1354
|
| Current state | \`docs/PROJECT_STATE.md\` | Product and capability state. |
|
|
838
1355
|
| Work queue | \`docs/TASK_BOARD.md\` | Task status and queue. |
|
|
839
|
-
|
|
|
1356
|
+
${handoffRow}| Workflow | \`docs/HADARA_WORKFLOW.md\` | Generic HADARA lifecycle and evidence rules. |
|
|
840
1357
|
| Task details | \`tasks/T-*/\` | Task-local evidence and decisions. |
|
|
841
1358
|
`;
|
|
842
1359
|
}
|
|
@@ -869,7 +1386,7 @@ function createAgentHandoffDoc() {
|
|
|
869
1386
|
}, `| Area | State | Notes |
|
|
870
1387
|
|---|---|---|
|
|
871
1388
|
| Scaffold | Initialized | HADARA protocol scaffold is initialized. |
|
|
872
|
-
| Required Reading | Pending | Read \`PROJECT_STATE\`, \`AGENT_HANDOFF\`, \`TASK_BOARD\`,
|
|
1389
|
+
| Required Reading | Pending | Read \`PROJECT_STATE\`, \`AGENT_HANDOFF\`, \`TASK_BOARD\`, and \`HADARA_WORKFLOW\` before starting. |
|
|
873
1390
|
`);
|
|
874
1391
|
return `# AGENT_HANDOFF
|
|
875
1392
|
|
|
@@ -930,7 +1447,7 @@ function createArchitectureDoc(profile) {
|
|
|
930
1447
|
|---|---|---|---|
|
|
931
1448
|
| Task Capsules | \`tasks/T-*/\` | Task-local scope, evidence, decisions, and handoff. | Active |
|
|
932
1449
|
| Evidence records | \`EVIDENCE.md\`, \`evidence.jsonl\` | Validation evidence and artifact references. | Active |
|
|
933
|
-
| Handoff | \`docs/AGENT_HANDOFF.md\` | Next-session continuation state. | Active |
|
|
1450
|
+
| Handoff | \`docs/PROJECT_STATE.md\` or \`docs/AGENT_HANDOFF.md\` | Next-session continuation state. | Active |
|
|
934
1451
|
`;
|
|
935
1452
|
}
|
|
936
1453
|
function createImplementationSopDoc(spec) {
|
|
@@ -976,7 +1493,7 @@ function createImplementationSopDoc(spec) {
|
|
|
976
1493
|
if (spec.docs.roadmap) {
|
|
977
1494
|
requiredReadingRows.push(['`docs/ROADMAP.md`', 'Roadmap, milestone, release, or scope planning', 'Longer-term priorities and deferred work.']);
|
|
978
1495
|
}
|
|
979
|
-
requiredReadingRows.push(['Active `tasks/T-*/TASK.md`', 'Working a task', 'Task-specific goal, scope, and status.'], ['Active Task Capsule docs', 'Working a task', '`
|
|
1496
|
+
requiredReadingRows.push(['Active `tasks/T-*/TASK.md`', 'Working a task', 'Task-specific goal, scope, and status.'], ['Active Task Capsule docs', 'Working a task', '`TASK.md`, `HANDOFF.md`, `EVIDENCE.md`, and task-local evidence summaries.']);
|
|
980
1497
|
const requiredReadingTable = (0, managed_sections_1.managedSectionBlock)('required-reading', {
|
|
981
1498
|
schema: 'hadara.managedSection.v1',
|
|
982
1499
|
owner: 'init.register-doc',
|
|
@@ -1100,14 +1617,14 @@ Use distinct token families for persistent task state, close proof state, docume
|
|
|
1100
1617
|
|
|
1101
1618
|
\`DocStatus\` belongs only to the docs registry and uses \`canonical\`, \`active\`, \`reference\`, \`historical\`, \`superseded\`, and \`archived\`. Evidence outcomes are \`passed\`, \`failed\`, \`blocked\`, and \`unknown\`; preserve failed or blocked evidence and append newer corrective evidence instead of rewriting history.
|
|
1102
1619
|
|
|
1103
|
-
Ownership boundaries follow the lifecycle command model. \`task finalize --execute --plan-hash <hash>\` is the default 0.3.3 agent close path and preserves the underlying write boundaries: \`task finish --execute\` owns bounded status bookkeeping in \`TASK.md\` and command-owned \`docs/TASK_BOARD.md\` cells, and
|
|
1620
|
+
Ownership boundaries follow the lifecycle command model. \`task finalize --execute --plan-hash <hash>\` is the default 0.3.3 agent close and close-proof repair path and preserves the underlying write boundaries: \`task finish --execute\` owns bounded status bookkeeping in \`TASK.md\` and command-owned \`docs/TASK_BOARD.md\` cells, and close execution owns only close evidence append. Operators own close-source prose and shared state docs before finalize execute, then rerun finalize after any intentional close-source edit.
|
|
1104
1621
|
|
|
1105
1622
|
## Standard Task Workflow Loop
|
|
1106
1623
|
|
|
1107
|
-
The authoritative command semantics live in \`docs/TASK_WORKFLOW_COMMANDS.md\`. From 0.
|
|
1624
|
+
The authoritative command semantics live in \`docs/TASK_WORKFLOW_COMMANDS.md\`. From 0.4 onward, agents should start from \`task status\`, then use finalize for closure instead of starting with low-level proof-boundary commands:
|
|
1108
1625
|
|
|
1109
1626
|
\`\`\`bash
|
|
1110
|
-
hadara task
|
|
1627
|
+
hadara task status --json
|
|
1111
1628
|
|
|
1112
1629
|
# If a matching capsule already exists:
|
|
1113
1630
|
hadara task status --task T-XXXX --json
|
|
@@ -1124,29 +1641,27 @@ hadara evidence add-command --task T-XXXX --summary "..." --result passed --cate
|
|
|
1124
1641
|
|
|
1125
1642
|
# Finalize Task Capsule docs and tracked state docs before closing.
|
|
1126
1643
|
|
|
1127
|
-
hadara task lifecycle --task T-XXXX --json
|
|
1128
1644
|
hadara task finalize --task T-XXXX --json
|
|
1129
1645
|
hadara task finalize --task T-XXXX --execute --plan-hash sha256:... --json
|
|
1130
1646
|
\`\`\`
|
|
1131
1647
|
|
|
1132
1648
|
| Command | Default Write Behavior | Notes |
|
|
1133
1649
|
|---|---|---|
|
|
1134
|
-
| \`task
|
|
1135
|
-
| \`task
|
|
1650
|
+
| \`task status\` | Read-only | Without \`--task\`, selects next work. With \`--task\`, default output is a fast loop cockpit; use \`--detail full\` or \`task finalize\` for close-grade readiness diagnostics. |
|
|
1651
|
+
| \`task next\` | Read-only compatibility | Planned removal candidate; prefer \`task status --json\`. |
|
|
1136
1652
|
| \`evidence add-command\` | Write | Appends command-log evidence; does not execute shell commands; optional \`--category\`/\`--outcome\`/\`--resolves\`/\`--supersedes\` enrich v2 metadata, result/outcome mismatches are rejected, and optional \`--idempotency-key\` prevents duplicate same-key records. |
|
|
1137
|
-
| \`task lifecycle\` | Read-only |
|
|
1138
|
-
| \`task close-repair-plan\` | Read-only | Classifies close proof repair state and exact repair command. |
|
|
1653
|
+
| \`task lifecycle\` | Read-only compatibility | Planned removal candidate; prefer \`task status --task T-XXXX --json\`. |
|
|
1139
1654
|
| \`task finalize\` | Read-only by default; guarded execute requires \`--plan-hash\` | Default agent close path. Rechecks the current plan hash, executes phases serially, stops on blockers, and preserves finish/close write boundaries. |
|
|
1140
1655
|
| \`task finish\` / \`task ready\` / \`task close\` / \`task audit-close\` | Low-level proof-boundary commands | Use directly for debugging, recovery, or command implementation work. |
|
|
1141
1656
|
|
|
1142
|
-
Before running \`task finalize --execute\`, finish all close-source edits: Task Capsule docs, acceptance/tests/handoff notes, evidence summaries, \`docs/TASK_BOARD.md\`, and tracked state docs such as \`docs/PROJECT_STATE.md\`, \`docs/AGENT_HANDOFF.md\`, and roadmap/slice docs when they apply. After finalize closes the task, do not edit those close-source documents unless you intend to rerun finalize
|
|
1657
|
+
Before running \`task finalize --execute\`, finish all close-source edits: Task Capsule docs, acceptance/tests/handoff notes, evidence summaries, \`docs/TASK_BOARD.md\`, and tracked state docs such as \`docs/PROJECT_STATE.md\`, \`docs/AGENT_HANDOFF.md\`, and roadmap/slice docs when they apply. After finalize closes the task, do not edit those close-source documents unless you intend to rerun finalize and execute its fresh repair plan. Avoid writing volatile close evidence ids into close-source docs; use stable wording such as "close evidence appended; audit returned closed-valid".
|
|
1143
1658
|
|
|
1144
1659
|
## Validation
|
|
1145
1660
|
|
|
1146
1661
|
1. Run relevant tests.
|
|
1147
1662
|
2. Record meaningful evidence in \`EVIDENCE.md\` and \`evidence.jsonl\`.
|
|
1148
1663
|
3. Finalize Task Capsule docs and tracked state docs before close so the close source hash remains stable.
|
|
1149
|
-
4. Run \`hadara task
|
|
1664
|
+
4. Run \`hadara task status --task <task-id> --json\` when you need a compact phase check or next action.
|
|
1150
1665
|
5. Run \`hadara task finalize --task <task-id> --json\`, review the current plan hash and write boundaries, then execute \`hadara task finalize --task <task-id> --execute --plan-hash <hash> --json\`.
|
|
1151
1666
|
6. Use low-level \`task finish\`, \`task ready\`, \`task close\`, and \`task audit-close\` only when debugging or repairing one proof boundary directly.
|
|
1152
1667
|
7. Add project-specific integration or deployment smoke checks only after those surfaces exist and are documented for this project.
|
|
@@ -1268,7 +1783,7 @@ function createTestStrategyDoc() {
|
|
|
1268
1783
|
| 1 | Run the relevant suite from the table above. | Task Capsule \`EVIDENCE.md\` |
|
|
1269
1784
|
| 2 | Record meaningful evidence in the Task Capsule. | Task Capsule \`EVIDENCE.md\` and \`evidence.jsonl\` |
|
|
1270
1785
|
| 3 | Finalize Task Capsule docs and tracked state docs before close. | Task Capsule docs and tracked state docs |
|
|
1271
|
-
| 4 | Run \`hadara task
|
|
1786
|
+
| 4 | Run \`hadara task status --task <task-id> --json\` when you need a compact phase check or next action. | Task Capsule docs and evidence |
|
|
1272
1787
|
| 5 | Run \`hadara task finalize --task <task-id> --json\`, review the plan hash, then execute \`hadara task finalize --task <task-id> --execute --plan-hash <hash> --json\`. | Task Capsule close evidence |
|
|
1273
1788
|
| 6 | Use low-level \`task finish\`, \`task ready\`, \`task close\`, and \`task audit-close\` only when debugging or repairing one proof boundary directly. | Task Capsule evidence |
|
|
1274
1789
|
|
|
@@ -1317,10 +1832,10 @@ HADARA task workflow commands are split by responsibility. Similar-looking comma
|
|
|
1317
1832
|
|
|
1318
1833
|
## Standard Task Loop
|
|
1319
1834
|
|
|
1320
|
-
From 0.
|
|
1835
|
+
From 0.4 onward, agents should use the status-first finalize loop for ordinary implementation capsules:
|
|
1321
1836
|
|
|
1322
1837
|
\`\`\`bash
|
|
1323
|
-
hadara task
|
|
1838
|
+
hadara task status --json
|
|
1324
1839
|
|
|
1325
1840
|
# If a matching capsule already exists:
|
|
1326
1841
|
hadara task status --task T-XXXX --json
|
|
@@ -1337,7 +1852,6 @@ hadara evidence add-command --task T-XXXX --summary "..." --result passed --cate
|
|
|
1337
1852
|
|
|
1338
1853
|
# Finalize Task Capsule docs and tracked state docs before closing.
|
|
1339
1854
|
|
|
1340
|
-
hadara task lifecycle --task T-XXXX --json
|
|
1341
1855
|
hadara task finalize --task T-XXXX --json
|
|
1342
1856
|
hadara task finalize --task T-XXXX --execute --plan-hash sha256:... --json
|
|
1343
1857
|
\`\`\`
|
|
@@ -1437,15 +1951,14 @@ Serialize same-file writes, evidence append, Task Capsule doc writes, Task Board
|
|
|
1437
1951
|
|
|
1438
1952
|
| Command | Default Write Behavior | Notes |
|
|
1439
1953
|
|---|---|---|
|
|
1440
|
-
| \`task
|
|
1441
|
-
| \`task
|
|
1954
|
+
| \`task status\` | Read-only | Without \`--task\`, selects next work. With \`--task\`, default output is a fast loop cockpit; use \`--detail full\` or \`task finalize\` for close-grade readiness diagnostics. |
|
|
1955
|
+
| \`task next\` | Read-only compatibility | Planned removal candidate; prefer \`task status --json\`. |
|
|
1442
1956
|
| \`task create\` | Write | Creates a Draft Task Capsule and Task Board row. It does not imply the task is ready or done. |
|
|
1443
1957
|
| \`evidence add-command\` | Write | Appends operator-supplied command-log evidence. It does not execute shell commands or capture stdout/stderr; optional \`--category\`/\`--outcome\`/\`--resolves\`/\`--supersedes\` enrich v2 metadata, result/outcome mismatches are rejected, and optional \`--idempotency-key\` prevents duplicate same-key records. |
|
|
1444
|
-
| \`task lifecycle\` | Read-only |
|
|
1445
|
-
| \`task close-repair-plan\` | Read-only | Classifies close proof repair state and exact repair command. |
|
|
1958
|
+
| \`task lifecycle\` | Read-only compatibility | Planned removal candidate; prefer \`task status --task T-XXXX --json\`. |
|
|
1446
1959
|
| \`task finalize\` | Read-only by default; guarded execute requires \`--plan-hash\` | Default agent close path. Rechecks the current plan hash, executes phases serially, stops on blockers, and succeeds only after final audit is \`closed-valid\`. |
|
|
1447
1960
|
| \`task finish\` / \`task ready\` / \`task close\` / \`task audit-close\` | Low-level proof-boundary commands | Use directly for debugging, recovery, or command implementation work. |
|
|
1448
|
-
| \`task complete\` | Legacy read-only workflow compressor | Summarizes the current completion stage and next command; prefer \`task
|
|
1961
|
+
| \`task complete\` | Legacy read-only workflow compressor | Summarizes the current completion stage and next command; prefer \`task status\` and \`task finalize\` for current agent flows. |
|
|
1449
1962
|
|
|
1450
1963
|
## Non-Overlap Rules
|
|
1451
1964
|
|
|
@@ -1455,8 +1968,7 @@ Serialize same-file writes, evidence append, Task Capsule doc writes, Task Board
|
|
|
1455
1968
|
- \`harness validate\` is a direct diagnostic for Task Capsule structure and done-level gates; it is not a replacement for close evidence.
|
|
1456
1969
|
- \`task complete\` is a legacy read-only workflow compressor. It may report the next lifecycle command, but it must not execute finish, ready, close, or audit commands. Prefer \`task lifecycle\` and \`task finalize\` for 0.3.3 agent flows.
|
|
1457
1970
|
- \`task lifecycle\` is the read-only normalized phase API for agents.
|
|
1458
|
-
- \`task
|
|
1459
|
-
- \`task finalize\` is read-only by default. Guarded execute requires a matching current dry-run \`planHash\`, runs phases serially, stops on blockers, and returns success only after \`task audit-close\` is \`closed-valid\`.
|
|
1971
|
+
- \`task finalize\` is read-only by default and owns close-proof repair planning. Guarded execute requires a matching current dry-run \`planHash\`, runs phases serially, stops on blockers, and returns success only after the final audit is \`closed-valid\`.
|
|
1460
1972
|
- \`evidence list\` is the supported evidence id discovery surface. Text output shows \`[id] time | category/outcome | visibility | summary\`; JSON records expose \`id\`, \`idSource\`, \`idStability\`, \`persistedSchemaVersion\`, \`category\`, \`outcome\`, and \`tags\`. Use durable persisted \`ev:\` ids for long-lived \`--resolves\` and \`--supersedes\` references. Legacy compatibility ids are inspection-only and are not the preferred durable reference.
|
|
1461
1973
|
- \`evidence add-command\` records an operator-supplied command result; it does not run the command. \`--category\` and \`--outcome\` set persisted v2 metadata explicitly, while \`--result\` remains the legacy-compatible command result. When both are supplied, \`--result\` must match \`--outcome\` for \`passed\`, \`failed\`, \`blocked\`, and \`unknown\`; \`recorded\` and \`not-applicable\` require \`--result unknown\` or no explicit \`--result\`. \`--resolves\` and \`--supersedes\` append exact v2 resolution tags from passed or recorded follow-up evidence. \`--idempotency-key\` is optional; when supplied, same-key repeats return the existing record without appending duplicate Markdown or JSONL rows.
|
|
1462
1974
|
- Evidence v2 deferred scope remains explicit: rebuild preview/execute, \`check-id\`, \`subject\`, and a new add-command report schema id are future candidates. Do not infer those commands or schema changes from the current \`evidence list\` and \`evidence add-command\` ergonomics.
|
|
@@ -1472,91 +1984,65 @@ Serialize same-file writes, evidence append, Task Capsule doc writes, Task Board
|
|
|
1472
1984
|
}
|
|
1473
1985
|
function createAgentsDoc(spec) {
|
|
1474
1986
|
const requiredReadingRows = [
|
|
1475
|
-
['
|
|
1476
|
-
['
|
|
1477
|
-
['
|
|
1478
|
-
['
|
|
1479
|
-
['5', '`docs/IMPLEMENTATION_SOP.md`', 'Every session', 'Local workflow and required-reading registry.'],
|
|
1480
|
-
['6', '`docs/TASK_WORKFLOW_COMMANDS.md`', 'Starting, finishing, closing, auditing, or explaining task workflow commands', 'Standard task loop, dry-run boundaries, and command `ok` semantics.']
|
|
1987
|
+
['`.hadara/context/HADARA_CONTEXT.md`', 'Every session', 'Compact project-local context anchor and read-routing guide.'],
|
|
1988
|
+
['`docs/PROJECT_STATE.md`', 'Every session', 'Current state, active work, known problems, and next recommended step.'],
|
|
1989
|
+
['`docs/TASK_BOARD.md`', 'Every session', 'Task queue, task status, and capsule paths.'],
|
|
1990
|
+
['`docs/HADARA_WORKFLOW.md`', 'Every session; whenever using HADARA CLI workflow commands', 'Project start, task lifecycle, evidence, context, document timing, repair, and useful CLI guidance.']
|
|
1481
1991
|
];
|
|
1482
|
-
|
|
1992
|
+
if (spec.docs.agentHandoff)
|
|
1993
|
+
requiredReadingRows.push(['`docs/AGENT_HANDOFF.md`', 'When present in governed or long-running projects', 'Compact continuation handoff and current coordination notes.']);
|
|
1483
1994
|
if (spec.docs.architecture)
|
|
1484
|
-
requiredReadingRows.push([
|
|
1485
|
-
if (spec.docs.developmentSlices)
|
|
1486
|
-
requiredReadingRows.push([String(order++), '`docs/DEVELOPMENT_SLICES.md`', 'Starting, completing, or reclassifying a development slice', 'Roadmap ordering, prerequisites, and completion evidence.']);
|
|
1995
|
+
requiredReadingRows.push(['`docs/ARCHITECTURE.md`', 'Architecture, component, or boundary work', 'Current system shape and ownership boundaries.']);
|
|
1487
1996
|
if (spec.docs.decisions)
|
|
1488
|
-
requiredReadingRows.push([
|
|
1489
|
-
if (spec.docs.testStrategy)
|
|
1490
|
-
requiredReadingRows.push([String(order++), '`docs/TEST_STRATEGY.md`', 'Validation planning or completion checks', 'Routine suites and special-case checks.']);
|
|
1997
|
+
requiredReadingRows.push(['`docs/DECISIONS.md`', 'Project-level decision work', 'Durable project decisions.']);
|
|
1491
1998
|
if (spec.docs.securityModel)
|
|
1492
|
-
requiredReadingRows.push([
|
|
1999
|
+
requiredReadingRows.push(['`docs/SECURITY_MODEL.md`', 'Security, secret, permission, or evidence-safety work', 'Project security invariants.']);
|
|
1493
2000
|
if (spec.docs.roadmap)
|
|
1494
|
-
requiredReadingRows.push([
|
|
1495
|
-
requiredReadingRows.push([
|
|
1496
|
-
const trackedStateDocs = ['`docs/TASK_BOARD.md`', '`docs/PROJECT_STATE.md`', ...(spec.docs.developmentSlices ? ['`docs/DEVELOPMENT_SLICES.md`'] : [])];
|
|
1497
|
-
const ruleRows = [
|
|
1498
|
-
['Task boundary', 'Keep work inside one Task Capsule whenever possible.', 'Active Task Capsule'],
|
|
1499
|
-
['Task creation', 'If no suitable capsule exists, create one with `hadara task create <title>`.', '`docs/TASK_BOARD.md`'],
|
|
1500
|
-
['Evidence', 'Do not mark work done without evidence. Do not hand-edit `evidence.jsonl`; record failed or blocked checks honestly instead of replacing them with optimistic summaries.', '`EVIDENCE.md`, `evidence.jsonl`'],
|
|
1501
|
-
['Documentation timing', 'Do not defer all documentation until after implementation; keep capsule docs current as work changes.', 'Task Capsule docs and shared state docs'],
|
|
1502
|
-
['Write coordination', 'Parallelize read-only discovery and independent validation; serialize evidence append, Task Capsule doc writes, shared state doc writes, before-hash executes, `task finalize --execute`, low-level finish/close executes, and release/publish operations.', 'Task Capsule evidence'],
|
|
1503
|
-
['Task workflow', 'For task workflow commands, follow `docs/TASK_WORKFLOW_COMMANDS.md`: from 0.3.3 onward, agents should use `task lifecycle` and reviewed `task finalize --json` / `task finalize --execute --plan-hash <hash>` as the default close path. Use `task finish`, `task ready`, `task close`, and `task audit-close` only as low-level proof-boundary commands for debugging, recovery, or command implementation work.', 'Task Capsule evidence'],
|
|
1504
|
-
['Safety', 'Do not execute dangerous commands without explicit user approval.', 'Task Capsule evidence'],
|
|
1505
|
-
['Secrets', 'Do not write secrets, private logs, or machine-local state into committed files.', 'Changed-file review'],
|
|
1506
|
-
['Store boundary', 'Preserve the portable/project store boundary.', spec.docs.architecture ? '`.gitignore`, `docs/ARCHITECTURE.md`' : '`.gitignore`'],
|
|
1507
|
-
['Validation', 'Follow validation constraints recorded in `docs/AGENT_HANDOFF.md` and the active Task Capsule.', 'Task Capsule evidence'],
|
|
1508
|
-
['Tracked state', `Update ${formatInlineList(trackedStateDocs)} when tracked state changes.`, 'Tracked docs'],
|
|
1509
|
-
['Handoff', 'Update `docs/AGENT_HANDOFF.md` before stopping.', '`docs/AGENT_HANDOFF.md`'],
|
|
1510
|
-
['Required reading', 'Register project-specific docs in `docs/IMPLEMENTATION_SOP.md` before expecting agents to rely on them.', '`docs/IMPLEMENTATION_SOP.md`']
|
|
1511
|
-
];
|
|
1512
|
-
if (spec.docs.developmentSlices) {
|
|
1513
|
-
ruleRows.push(['Slice order', 'Respect prerequisite order in `docs/DEVELOPMENT_SLICES.md`.', '`docs/DEVELOPMENT_SLICES.md`']);
|
|
1514
|
-
}
|
|
2001
|
+
requiredReadingRows.push(['`docs/ROADMAP.md`', 'Roadmap, milestone, or scope planning', 'Longer-term priorities and deferred work.']);
|
|
2002
|
+
requiredReadingRows.push(['Active `tasks/T-*/TASK.md`', 'Every task-work session', 'Task scope, source documents, plan, acceptance, validation, and change summary.'], ['Active Task Capsule `HANDOFF.md` and `EVIDENCE.md`', 'Resuming, validating, finishing, or handing off a task', 'Continuation guidance and human-readable evidence projection.'], ['Project-specific docs referenced by the task, registry, or read-map', 'When referenced', 'Task-specific architecture, design, roadmap, validation, security, or integration constraints.']);
|
|
1515
2003
|
return `# AGENTS
|
|
1516
2004
|
|
|
1517
|
-
This repository
|
|
2005
|
+
This repository uses the HADARA protocol for scoped, evidenced, resumable AI-assisted development.
|
|
1518
2006
|
|
|
1519
2007
|
## Required Reading
|
|
1520
2008
|
|
|
1521
|
-
|
|
|
1522
|
-
|
|
2009
|
+
| Document | When to Read | Purpose |
|
|
2010
|
+
|---|---|---|
|
|
1523
2011
|
${requiredReadingRows.map(formatTableRow).join('\n')}
|
|
1524
2012
|
|
|
1525
|
-
\`
|
|
2013
|
+
\`AGENTS.md\` owns Required Reading. \`.hadara/context/HADARA_CONTEXT.md\` is a compact routing anchor that points to current-state and workflow documents; it is not a second Required Reading authority.
|
|
1526
2014
|
|
|
1527
2015
|
## Required Reading Tiers
|
|
1528
2016
|
|
|
1529
|
-
Use semantic tiers to keep session startup compact:
|
|
1530
|
-
|
|
1531
2017
|
| Tier | Meaning | Default Read Behavior |
|
|
1532
2018
|
|---|---|---|
|
|
1533
|
-
| \`current-state\` | Compact docs that establish
|
|
1534
|
-
| \`
|
|
1535
|
-
| \`
|
|
1536
|
-
| \`
|
|
1537
|
-
| \`
|
|
1538
|
-
|
|
1539
|
-
\`.hadara/context/HADARA_CONTEXT.md\` is the current-state entry point. It should route readers to compact state before task-work or conditional-reference docs. Full historical review of \`docs/PROJECT_STATE.md\` is not mandatory every session; use \`docs/AGENT_HANDOFF.md\` and its Historical Index when older history is needed. Historical and superseded docs are never default required reading.
|
|
2019
|
+
| \`current-state\` | Compact docs that establish live project state and route deeper reading. | Read first at session start or resume. |
|
|
2020
|
+
| \`workflow\` | Shared HADARA workflow and command-use guidance. | Read before selecting, creating, implementing, finishing, closing, or auditing tasks. |
|
|
2021
|
+
| \`task-work\` | Active Task Capsule docs and task-local evidence/handoff surfaces. | Read when working inside a task. |
|
|
2022
|
+
| \`conditional-reference\` | Architecture, roadmap, decisions, validation, security, integration, or project-specific specs. | Read only when the task or read-map points to them. |
|
|
2023
|
+
| \`historical\` | Completed-task history and older validation records. | Do not read by default; use only when investigating history. |
|
|
2024
|
+
| \`excluded\` | Superseded, archived, local-only, or intentionally non-default material. | Do not read unless explicitly reclassified. |
|
|
1540
2025
|
|
|
1541
|
-
##
|
|
2026
|
+
## Operating Rules
|
|
1542
2027
|
|
|
1543
|
-
|
|
2028
|
+
- Work inside one Task Capsule whenever possible.
|
|
2029
|
+
- If no suitable Task Capsule exists, create one through the HADARA workflow before implementation.
|
|
2030
|
+
- Prefer HADARA read models before broad manual file reading.
|
|
2031
|
+
- Keep committed state reproducible and project-local.
|
|
2032
|
+
- Do not write secrets, private logs, raw transcripts, credentials, or machine-local state into committed files.
|
|
2033
|
+
- Do not hand-edit canonical evidence logs.
|
|
2034
|
+
- Do not mark work done without evidence.
|
|
2035
|
+
- Keep Task Capsule docs current as work changes; do not defer all documentation until after implementation.
|
|
2036
|
+
- Do not execute destructive commands.
|
|
2037
|
+
- Do not run release, publish, package, installer, or other external mutation workflows without explicit operator approval.
|
|
1544
2038
|
|
|
1545
|
-
|
|
1546
|
-
hadara task next --json
|
|
1547
|
-
hadara session start --task T-XXXX --json
|
|
1548
|
-
hadara task lifecycle --task T-XXXX --json
|
|
1549
|
-
hadara task finalize --task T-XXXX --json
|
|
1550
|
-
hadara task finalize --task T-XXXX --execute --plan-hash sha256:... --json
|
|
1551
|
-
\`\`\`
|
|
2039
|
+
## Workflow Reference
|
|
1552
2040
|
|
|
1553
|
-
Use
|
|
2041
|
+
Use \`docs/HADARA_WORKFLOW.md\` for project start, task lifecycle, context, evidence, document timing, repair, docs read-map, and useful CLI guidance.
|
|
1554
2042
|
|
|
1555
|
-
##
|
|
2043
|
+
## Project Context
|
|
1556
2044
|
|
|
1557
|
-
|
|
1558
|
-
|---|---|---|
|
|
1559
|
-
${ruleRows.map(formatTableRow).join('\n')}
|
|
2045
|
+
Use \`.hadara/context/HADARA_CONTEXT.md\` as the compact project-local context anchor.
|
|
1560
2046
|
`;
|
|
1561
2047
|
}
|
|
1562
2048
|
function formatInlineList(items) {
|