Git for the intent behind agent-written code. Records what your coding agent decided and why, and links every commit to it.
JavaScript ai-codingclaudeclaude-codeclaude-code-pluginclicoding-agentsdeveloper-toolsgitllmtypescript
feat(init): name the project after its directory
Erenfb40d6a0d242
diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.mdindex ad05289..73c0ddb 100644--- a/docs/guide/getting-started.md+++ b/docs/guide/getting-started.md@@ -44,15 +44,16 @@ cd your-projectcogit init```-`init` asks two questions; the rest have sensible defaults, and every one has a flag so-`cogit init --yes` runs without asking.+`init` asks at most two questions; the rest have sensible defaults, and every one has a flag+so `cogit init --yes` runs without asking.| Question | Default | Flag ||---|---|---|-| Project name | the directory name | `--name` || Commit the session records to git? | yes | `--git commit\|ignore` || Keep Claude Code transcripts longer? Claude Code deletes them after 30 days by default. | keep as is | `--retention <days\|keep>` |+The project is named after its directory; `--name` overrides it.+Without asking, `init` lets the agent run the cogit skill without a permission prompt (so itupdates the record as it works), turns the plugin on for the project (writes`.claude/settings.json`, which a teammate's session reads to load the plugin and stops onediff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.tsindex 76cffdc..2fcb50e 100644--- a/packages/cli/src/commands/init.ts+++ b/packages/cli/src/commands/init.ts@@ -210,7 +210,8 @@ export async function init(dir: string, opts: InitOptions, io: Io): Promise<void"git config --global user.email [email protected]",);- const name = opts.name ?? (await io.prompt.input("Project name?", basename(root)));+ // The directory names the project; --name overrides it.+ const name = opts.name ?? basename(root);const config = await loadConfig(io.env);// Story 9.3: the record travels with the repository by default.diff --git a/packages/cli/test/init.test.ts b/packages/cli/test/init.test.tsindex cf62adf..1dcc60f 100644--- a/packages/cli/test/init.test.ts+++ b/packages/cli/test/init.test.ts@@ -78,7 +78,7 @@ describe("init", () => {});expect((await loadConfig(env)).language).toBe("auto");// name, git policy and retention; the rest take their defaults- expect(io.asked).toHaveLength(3);+ expect(io.asked).toHaveLength(2);expect(await readProjectSetup(root)).toBe(true);expect(await readSkillAllowed(env)).toBe(true);expect(io.lines.at(-2)).toMatch(/^Initialized proj/);@@ -149,7 +149,7 @@ describe("init", () => {it("asks for the git policy in a repo and writes .gitignore", async () => {await mkdir(join(root, ".git"));- const io = fakeIo(env, ["proj", "ignore"]);+ const io = fakeIo(env, ["ignore"]);await init(root, {}, io);expect(await readText(join(root, ".gitignore"))).toBe("# cogit\n/.cogit/\n");expect(io.lines).toContain("Added to .gitignore: /.cogit/");@@ -158,7 +158,7 @@ describe("init", () => {it("raises transcript retention when asked, keeping other settings", async () => {await mkdir(join(dir, "claude"));await writeFile(settingsFile(), JSON.stringify({ model: "x" }));- const io = fakeIo(env, ["proj", "commit", "365"]);+ const io = fakeIo(env, ["commit", "365"]);await init(root, {}, io);expect(JSON.parse(await readText(settingsFile()))).toEqual({model: "x",@@ -182,7 +182,7 @@ describe("init", () => {const io = fakeIo(env);await init(root, {}, io);expect(io.lines).toContain("Claude Code keeps transcripts for 365 days.");- expect(io.asked).toHaveLength(2);+ expect(io.asked).toHaveLength(1);});it("applies a retention option without asking, and skips an unchanged one", async () => {@@ -234,7 +234,7 @@ describe("init", () => {});it("takes the conversation's language without asking, and the option when given", async () => {- const io = fakeIo(env, ["proj", "commit", "keep"]);+ const io = fakeIo(env, ["commit", "keep"]);await init(root, {}, io);expect((await loadConfig(env)).language).toBe("auto");expect(io.asked.some((q) => q.startsWith("Language"))).toBe(false);@@ -250,7 +250,7 @@ describe("init", () => {settingsFile(),JSON.stringify({ permissions: { allow: ["Bash(ls)"], deny: [] } }),);- const io = fakeIo(env, ["proj", "commit", "keep", "yes"]);+ const io = fakeIo(env, ["commit", "keep", "yes"]);await init(root, {}, io);expect(JSON.parse(await readText(settingsFile())).permissions).toEqual({allow: ["Bash(ls)", SKILL_RULE],@@ -265,7 +265,7 @@ describe("init", () => {});it("leaves permissions alone when declined with the flag", async () => {- const io = fakeIo(env, ["proj", "commit", "keep"]);+ const io = fakeIo(env, ["commit", "keep"]);await init(root, { allowSkill: false }, io);expect(await readSkillAllowed(env)).toBe(false);expect(io.lines).toContain(