* chore(#2143): markdown table model + schema registry + fail-loud pilot — Phase 1 Phase 1 of epic #2143 (ADR-2143): consolidate markdown table parsing onto a canonical seam and migrate the pilot reader. - Add src/markdown-table.cts: parseMarkdownTable (GFM tables -> typed {columns, rows} addressed by column NAME; ragged rows are typed parse errors, not silent), a single-source TABLE_SCHEMAS registry (RoadmapProgress / RequirementsTraceability / QuickTasks / Security, with variants under one id), matchTableSchema, and findTableBySchema. Result<T> is scoped to this seam (distinct from the dispatch Result). - Migrate deriveProgressFromRoadmap (src/phase-lifecycle.cts) off the position-anchored regex to name-based resolution via the seam — fixes #2137 (the 5-column milestone-grouped Progress table previously returned all-null). - Add a schema-backed `gsd-tools quick-tasks-append` subcommand and route fast.md's log_to_state through it, retiring the inline `awk NF-2` column arithmetic — fixes #2133 (addresses #2012, #2119). Cell values are escaped (| and newlines) and the STATE.md read-modify-write is atomic under readModifyWriteStateMd (lost-update race, cf. #500/#905/#1230). - Writer/reader/template parity test guards TABLE_SCHEMAS against drift (ADR-2143 §3 Generative-Fix-Divergence). Registration: .gitignore, eslint.config.mjs, docs/INVENTORY.md + INVENTORY-MANIFEST.json, CONTEXT.md glossary, docs/CLI-TOOLS.md. Behaviour-preserving for the canonical 4-column Progress table; the named bugs are driven fail-first. Extend-never-mutate (ADR-2143 §2). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * chore(#2242): backfill changeset PR number (#2248) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#2242): escape backslash before pipe in markdown-table cell escaping CodeQL js/incomplete-sanitization (high): escapeCell escaped | -> \| but not the backslash itself. Now escapes \ -> \\ before | -> \|, and splitTableRow unescapes both \\ -> \ and \| -> | symmetrically so cell values (incl. literal backslashes) round-trip exactly. Added backslash round-trip tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#2242): read ROADMAP Progress table by column name — supersede #2168 ad-hoc scan Rebase reconciliation with #2168 (the tactical #2137 fix that marked itself "pending #2143"). deriveProgressFromRoadmap now resolves the Progress table via a new seam helper findTableWithColumns (first table whose header is a superset of Phase/Plans Complete/Status/Completed, any order, extra columns ignored) and reads cells by NAME — order/injection-invariant per ADR-2143 §3 — instead of the exact TABLE_SCHEMAS match. This satisfies #2168's column-invariance property test while staying seam-based and preserving its `## Progress` scoping (#2012/#1445). Ragged Progress tables now resolve to null (ADR-2143 fail-loud); updated the stale state.test.cjs assertion that predated the Phase-1 migration. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,12 @@
|
||||
* list-todos [area] Count and enumerate pending todos
|
||||
* list-seeds [status] List captured seeds (optional status filter)
|
||||
* verify-path-exists <path> Check file/directory existence
|
||||
* quick-tasks-append --task <text> Append a row to STATE.md's "Quick Tasks
|
||||
* Completed" table (schema-backed via
|
||||
* markdown-table.cjs; #2133/ADR-2143).
|
||||
* Fails loud (non-zero exit) on a missing
|
||||
* or unrecognized table instead of the old
|
||||
* awk NF-2 silent-skip guess.
|
||||
* config-ensure-section Initialize .planning/config.json
|
||||
* history-digest Aggregate all SUMMARY.md data
|
||||
* summary-extract <path> [--fields] Extract structured data from SUMMARY.md
|
||||
@@ -693,7 +699,7 @@ async function main() {
|
||||
'from-gsd2, frontmatter, gap-analysis, generate-claude-md, generate-claude-profile, ' +
|
||||
'generate-dev-preferences, generate-slug, graphify, history-digest, init, intel, ' +
|
||||
'capability, classify-confidence, git, learnings, list-seeds, list-todos, loop, milestone, package-legitimacy, phase, phase-plan-index, phases, profile-questionnaire, ' +
|
||||
'profile-sample, progress, project-instruction-file, prompt-budget, requirements, research-plan, research-store, resolve-granularity, resolve-model, roadmap, scaffold, smart-entry, state, ' +
|
||||
'profile-sample, progress, project-instruction-file, prompt-budget, quick-tasks-append, requirements, research-plan, research-store, resolve-granularity, resolve-model, roadmap, scaffold, smart-entry, state, ' +
|
||||
'task, template, user-story, validate, verify, verify-path-exists, verify-summary, eval, workstream, worktree\n\n' +
|
||||
'Global flags:\n' +
|
||||
' --raw Emit raw output without post-processing\n' +
|
||||
@@ -1213,6 +1219,59 @@ async function runCommand(command, args, cwd, raw, defaultValue, originalCommand
|
||||
break;
|
||||
}
|
||||
|
||||
case 'quick-tasks-append': {
|
||||
// #2133 / ADR-2143 §3,§7: schema-backed replacement for fast.md's inline
|
||||
// `awk NF-2` Quick Tasks column arithmetic. Row construction is delegated
|
||||
// to the pure appendQuickTaskRow (markdown-table.cjs); this case only
|
||||
// handles the I/O (read STATE.md, resolve date/commit, write STATE.md).
|
||||
const qtaArgs = args.slice(1);
|
||||
const qtaTask = parseNamedArgs(qtaArgs, ['task']).task || args[1];
|
||||
if (!qtaTask) {
|
||||
error('quick-tasks-append requires --task <description> (or a positional description)', ERROR_REASON.USAGE);
|
||||
}
|
||||
|
||||
const statePath = path.join(cwd, '.planning', 'STATE.md');
|
||||
if (!fs.existsSync(statePath)) {
|
||||
error(`quick-tasks-append: STATE.md not found at ${statePath}`, ERROR_REASON.USAGE);
|
||||
}
|
||||
|
||||
const date = new Date().toISOString().slice(0, 10);
|
||||
const { execGit } = require('./lib/shell-command-projection.cjs');
|
||||
const hashResult = execGit(['rev-parse', '--short', 'HEAD'], { cwd });
|
||||
const commit = hashResult.exitCode === 0 && hashResult.stdout ? hashResult.stdout : '—';
|
||||
|
||||
const { appendQuickTaskRow } = require('./lib/markdown-table.cjs');
|
||||
|
||||
// #2242 review fix: route the read -> mutate -> write cycle through
|
||||
// state.readModifyWriteStateMd (lib/state.cjs) instead of a raw
|
||||
// fs.readFileSync + fs.writeFileSync pair, so the whole read-modify-write
|
||||
// is atomic under STATE.md's lockfile — closing the lost-update race a
|
||||
// raw read/write pair left open (cf. #500/#905/#1230). This mirrors the
|
||||
// pattern every other STATE.md-mutating case in state.cts uses (e.g.
|
||||
// cmdStateAddBlocker, cmdStateAddDecision): a mutable outer variable
|
||||
// captures the pure helper's side output, and a fail-loud reason throws
|
||||
// ExitError from INSIDE the transform (readModifyWriteStateMd's finally
|
||||
// still releases the lock before the throw propagates; the transform
|
||||
// throws before returning new content, so nothing is ever written).
|
||||
let mutation;
|
||||
state.readModifyWriteStateMd(statePath, (content) => {
|
||||
const result = appendQuickTaskRow(content, { description: qtaTask, date, commit });
|
||||
if (!result.ok) {
|
||||
// Mirrors fast.md's old "skip with a brief log" behaviour (#2133): this
|
||||
// is an expected, recoverable condition (no table / unrecognized
|
||||
// schema), not a hard crash. ExitError sets a non-zero exit code (so
|
||||
// fast.md's `|| echo ...` fallback fires) without calling
|
||||
// process.exit() directly — stdout stays flushed and untouched.
|
||||
throw new ExitError(1, `⚠ quick-tasks-append: ${result.reason}`);
|
||||
}
|
||||
mutation = result.value;
|
||||
return result.value.content;
|
||||
}, cwd);
|
||||
|
||||
output({ ok: true, row: mutation.row, variant: mutation.variant }, raw, mutation.row);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'config-ensure-section': {
|
||||
// Phase 6 (#3575): dispatch via SDK executeForCjs. The catalog rebinds
|
||||
// 'config-ensure-section' to configNewProject in
|
||||
|
||||
Reference in New Issue
Block a user