npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

codeapp-js-cli

v0.1.5

Published

CAP CLI and Node.js API for Power Apps code apps

Readme

CodeApp JS CLI

codeapp-js-cli supports two non-breaking use cases:

  1. Install it globally and use cap as a terminal command.
  2. Install it as a project dependency and either call the local CLI or import the Node.js API.

cap is a thin wrapper around the local @microsoft/power-apps-cli package and does not require an external pac installation.

Install And Use As A Standalone CLI

Install globally:

npm install -g codeapp-js-cli

Then run the CLI from any terminal:

cap
cap-p <prompt>
cap auth
cap environment --info
cap setup

Notes:

  • cap is the portable command name to document and script against.
  • The package also exposes CAP as an alias for shells where you want the uppercase form.
  • Global install is the right choice when you want one CLI available across multiple workspaces on the same machine.

Install And Use As A Dependency

Install into a project:

npm install codeapp-js-cli

Use the local CLI from that project directory without a global install:

npx cap --help
npx cap auth

Run the CLI from any directory without installing it globally:

npx --package codeapp-js-cli cap --help
npx --package codeapp-js-cli cap auth

Or wire it into package scripts:

{
	"scripts": {
		"cap": "cap",
		"cap:setup": "cap setup",
		"cap:deploy": "cap deploy"
	}
}

Node.js API

The package root continues to export the reusable command functions from lib/cap-core.js, so existing dependency consumers are not forced to change imports.

CommonJS:

const {
	capChat,
	capEnvironment,
	capSetup,
	parseCommandInput,
} = require('codeapp-js-cli');

async function run() {
	const parsed = parseCommandInput(process.argv.slice(2));
	if (parsed.target === 'setup') {
		await capSetup();
		return;
	}

	await capEnvironment(undefined, { namedArgs: { info: true } });
	await capChat();
}

run().catch((error) => {
	console.error(error.stderr || error.stdout || error.message);
	process.exit(typeof error.code === 'number' ? error.code : 1);
});

ES modules:

import cap from 'codeapp-js-cli';

await cap.capSetup();

Compatibility notes:

  • require('codeapp-js-cli') still resolves to the same lib/cap-core.js API surface.
  • Deep imports such as require('codeapp-js-cli/lib/cap-core') and require('codeapp-js-cli/lib/cap-core.js') remain available for older integrations.
  • The CLI entry point remains bin/cap.js, exposed through the cap and CAP executables.

npx Troubleshooting

If npx cap fails with a path under %APPDATA%\npm\node_modules\codeapp-js-cli\bin\cap.js, npx is running a stale global shim instead of a project-local install.

Use one of these fixes:

# From any directory, bypass the global shim entirely
npx --package codeapp-js-cli cap --help
# Repair the broken global install on Windows
npm uninstall -g codeapp-js-cli
Remove-Item "$env:APPDATA\npm\cap.cmd","$env:APPDATA\npm\cap.ps1","$env:APPDATA\npm\CAP.cmd","$env:APPDATA\npm\CAP.ps1" -Force -ErrorAction SilentlyContinue
npm install -g codeapp-js-cli

Commands

cap
cap auth
cap auth --change
cap auth --logout
cap copilot
cap copilot --token <githubToken>
cap copilot --logout
cap model
cap model --<publisher/model>
cap skills
cap skills --<skill>
cap instruction
cap instruction --edit
cap instruction --delete
cap instruction --<markdownPath>
cap session
cap session --<session>
cap edit
cap edit --<filePath>
cap mockup
cap mockup --<number>
cap environment
cap environment --<environmentURL>
cap environment --info
cap dataverse --<table-logical-name>
cap flow
cap flow --<flow-id>
cap connection --<apiName>
cap setup
cap deploy
cap deploy --debugger

Behavior

  • cap starts the interactive Copilot chat session, loads the active session from agent/, reads prompt and instruction files from the CLI setup directory, and runs the conversation through the official GitHub Copilot CLI SDK while saving local session metadata back into agent/*.session.json. Inside chat, slash commands now run either CAP commands such as /model or shell commands such as /git status and /cd ...
  • cap-p <prompt> runs a one-off Copilot turn using the current CAP prompt and instruction files, but does not create or reuse any saved CAP session.
  • cap auth starts an interactive browser login using the bundled MSAL auth provider and caches credentials locally for later CAP commands.
  • cap auth --change clears the local auth cache and forces an account-picker login.
  • cap auth --logout clears the cached login.
  • cap copilot launches the official GitHub Copilot CLI login flow when you press Enter in an interactive shell, or saves a token accepted by Copilot CLI when you paste one.
  • cap copilot --logout clears the CAP-saved Copilot metadata and, on Windows, also removes bundled Copilot OAuth credentials stored by copilot login.
  • cap model reads the live GitHub Copilot model list through @github/copilot-sdk and stores the selected model in the CLI setup workspace config.
  • cap model --debug prints the live GitHub Copilot model source, auth identity, and available model ids seen by the current Copilot account.
  • cap model --<model> updates the CLI-selected model without opening the picker.
  • cap skills opens a bundled skill file from the installed codeapp-js/AI/skills/ folder; cap skills --<skill> quick-opens a matching packaged skill.
  • cap instruction prints the CLI instruction file.
  • cap instruction --edit opens the CLI instruction file in VS Code or the platform fallback editor.
  • cap instruction --delete removes the CLI instruction file.
  • cap instruction --docs/rules.md copies that Markdown file into the CLI instruction file.
  • cap session lists saved chats from agent/ and marks the selected one as the active context for the next cap chat session.
  • cap edit lists workspace files and opens the selected file in VS Code or the platform fallback editor.
  • cap mockup lists HTML files under agent/, then opens the selected mockup in the default browser.
  • cap mockup --1 opens the first listed mockup directly.
  • cap environment lists tenant environments, lets you filter/select one, and writes the selected environment ID to power.config.json.
  • cap environment --<environmentURL> selects the environment whose Dynamics URL matches the provided URL.
  • cap environment --info prints the current environment display name, Dynamics URL, and environment ID.
  • cap dataverse --account adds the Dataverse table data source through the bundled action layer.
  • cap flow runs power-apps list-flows --json, lets you filter/select, then runs power-apps add-flow --flow-id <id>.
  • cap flow --<flow-id> directly runs power-apps add-flow --flow-id <id>.
  • cap connection --<apiName> lists connections for that connector through the bundled service layer, selects the first one, then adds it as a data source.
  • cap setup copies the bundled codeapp-js/codeApp template contents into the current working directory, then prompts for the app display name and description and writes them into power.config.json.
  • cap deploy runs power-apps push, extracts the app ID from the returned play URL, and writes it to power.config.json as appId.
  • cap deploy --debugger prepends the debugger bootstrap to dist/index.js before pushing.

Copilot Backend

  • CAP now uses the official GitHub Copilot CLI SDK instead of the models.github.ai REST catalog and inference endpoints.
  • Available models come from the active Copilot account, so the picker now follows the Copilot model surface rather than the GitHub Models PAT catalog.
  • Tool execution and file changes are handled by the Copilot CLI runtime, with CAP prompting for per-action approval.

Copilot Auth Notes

  • Saved Copilot sign-in is stored in the local CAP user config.
  • Runtime auth prefers a Copilot CLI logged-in user, then COPILOT_GITHUB_TOKEN/GH_TOKEN/GITHUB_TOKEN, then the saved CAP token.
  • CAP copilot --logout now removes CAP-saved metadata and also clears bundled Copilot OAuth state on Windows by deleting the .copilot remembered-user entries plus the matching copilot-cli/... Windows Credential Manager target.
  • For environment variables, GitHub CLI auth, or explicit tokens, remove or change that source directly.
  • Running CAP copilot in an interactive shell launches Copilot device login when you press Enter at the token prompt.
  • If you prefer a non-interactive setup, set COPILOT_GITHUB_TOKEN, GH_TOKEN, or GITHUB_TOKEN.

Reuse Model

The command logic lives in lib/cap-core.js and is exported from the package root so other tools can build on top of the same command implementations without reimplementing shell behavior.

Lean Update Flow

  • Update the wrapped CLI with npm run update:power-apps-cli.
  • Remove non-production packages with npm run prune:production.
  • Package output stays lean because package.json whitelists only bin, lib, and README.md, while bundled assets come from the codeapp-js dependency.

Requirements

  • Node.js 20+